Pure Rust implementation of several Arimethization-Oriented primitives, providing two working modes:
- The normal hashing functionalities operating on the pairing Elliptic Curve
bls12-381, re-implemented by the Dusk company and shipped via the crate dusk-bls12_381. - The gadget hashing functionalities that build a Plonk circuit, based on it's Dusk implementation (Dusk-Plonk).
The primitives implemented are the following:
Each primitive is linked to its original documentation source, plus for redundancy has been stored a copy of each paper under the docs folder.
To simplify the usage and exploiting the cargo functionalities, for each function has been implemented a cargo features that enables all the inherent methods. Plus are also privided two additional features, which are encryption and zk, to specify the working mode both for the tests and the benchmarks.
The encryption feature enables hashing, encrypting and decrypting on bls12-381, while zk enables the zero-knowledge proof over a Plonk circuit.
To check the hashing functionalities of an primitive, the simplest command that can be run is the following:
cargo test --features={hash_name}where the available {hash_name} are:
- anemoi: to specify the
Anemoihashing - arion: to specify the
Arionhashing - gmimc: to specify the
GMiMChashing - griffin: to specify the
Griffinhashing - poseidon: to specify the
Poseidonhashing - rescue: to specify the
Rescuehashing - rescue_prime: to specify the
Rescue-Primehashing
therefore, the following shell code
cargo test --features=gmimcwill execute GMiMC.
Caution
For simplicity, this library has been organized in such a way that only an hashing algorithms can be run at a time, thus if are provided more than 1 primitive features all together, it will run only the first, in alphabetical order, {hash_name} among the ones provided.
To run a simple hash example that consumes the same input in two different ways and compare its final digest, run:
cargo run --example hash_example --features={hash_name}To execute the tests on the normal functionalities, run:
cargo test --features={hash_name},encryptionInstead, to test the gadget functionalities, use the command:
cargo test --features={hash_name},zkDepending if we want to test the primitive on scalar or Plonk circuit, you can alternate between the two features, otherwise encryption and zk, can also be run altogheter with the following command:
cargo test --features={hash_name},zk,encryptionTo perform some benchmarks, the commands and options are the same explained for the tests, except that we subsitute the cargo command test with bench, like that:
cargo bench --features={hash_name},encryption