Crates.io | liminal-ark-poseidon |
lib.rs | liminal-ark-poseidon |
version | 0.1.0 |
source | src |
created_at | 2023-03-21 06:40:59.040013 |
updated_at | 2023-03-21 06:40:59.040013 |
description | An instantiation of the Poseidon SNARK-friendly hash function. |
homepage | https://alephzero.org |
repository | https://github.com/Cardinal-Cryptography/aleph-node |
max_upload_size | |
id | 815891 |
size | 289,262 |
This package contains two crates: a library exposing arkworks-based Poseidon hashing and a binary for regenerating parameters. Parameters are generated using https://github.com/penumbra-zone/poseidon377.
The lib crate liminal-ark-poseidon
provides two modules:
hash
module that exposes <x>_to_one_hash
method family for hashing raw field elementscircuit
module that exposes <x>_to_one_hash
method family for hashing circuit field elements;
it is available only under circuit
feature flagCurrently, <x>
is one, two and four, i.e. we support 1:1, 2:1 and 4:1 hashing.
Example usage:
fn hash_outside_circuit(left: Fr, right: Fr) -> Fr {
liminal_ark_poseidon::hash::two_to_one_hash([left, right])
}
fn hash_in_circuit(
cs: ConstraintSystemRef<CircuitField>,
left: FpVar<CircuitField>,
right: FpVar<CircuitField>,
) -> Result<FpVar<CircuitField>, SynthesisError> {
liminal_ark_poseidon::circuit::two_to_one_hash(cs, [left, right])
}
If you need fresh parameters, you can regenerate parameters module by running:
cargo run --release --features paramgen
You can also manipulate security level with SECURITY_LEVEL
env variable.