Crates.io | poseidon-primitives |
lib.rs | poseidon-primitives |
version | 0.1.1 |
source | src |
created_at | 2023-11-16 04:59:50.939861 |
updated_at | 2023-11-16 04:59:50.939861 |
description | Native rust implementation of the Poseidon hash function. This is forked from Scroll's audited Poseidon halo2 circuit implementation, but this crate does not include the circuit. |
homepage | |
repository | https://github.com/axiom-crypto/poseidon-circuit |
max_upload_size | |
id | 1037329 |
size | 690,423 |
Poseidon hash circuit and primitives. It integrated several poseidon hash schemes from zcash and iden3 and support sponge progress for hashing messages in any length.
To connect to the hash circuit, see spec/hash-table.md
.
The circuit code can be implied with field which have satisified Hashable
trait and currently only poseidon-circuit::Bn256Fr
(the alias of halo2_proofs::halo2curves::bn256::Fr
) has satisified this trait.
The circuit type under hash::HashCircuit
prove poseidon hash progress base on permutation with 3 fields and a 2 fields rate. You also need to set a fixed step size for proving message hashing with variable length. A message has to be complied with an initial capacity size and for each sponge step the capacity would be substracted by the fixed step size. In the final step the capacity has to be equal or less than the fixed step.
For example, when we hashing a message with 19 fields:
You can use a circuit with fixed step size as 2
, and set the initialized capacity as 19
(i.e. the field len of input message). In each sponge progess the capacity is reduced by 2
and in final step it became 1
;
You can use a circuit with fixed step size as 32
and a initialized capacity between 298
to 320
.
The DEFAULT_STEP
being decalred in the crate is 32
.
Add Cargo.toml
under [dependencies]
:
[dependencies]
poseidon-circuit = { git = "https://github.com/scroll-tech/poseidon-circuit.git" }
Licensed under either of
at your option.