mirror of
https://github.com/logos-storage/logos-storage-proofs-circuits.git
synced 2026-01-04 06:23:09 +00:00
33 lines
1.0 KiB
Plaintext
33 lines
1.0 KiB
Plaintext
pragma circom 2.0.0;
|
|
|
|
include "poseidon2_sponge.circom";
|
|
|
|
//------------------------------------------------------------------------------
|
|
// Hash `n` field elements into 1, with approximately 127-254 bits of preimage security
|
|
// Note that the output size must be at least twice than the desired security level (?)
|
|
// (assuming bn128 scalar field. We use capacity=2, rate=1, t=3).
|
|
|
|
template Poseidon2_hash_rate1(n) {
|
|
signal input inp[n];
|
|
signal output out;
|
|
|
|
component sponge = PoseidonSponge(3,2,n,1);
|
|
sponge.inp <== inp;
|
|
sponge.out[0] ==> out;
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
// Hash `n` field elements into 1, with approximately 127 bits of preimage security
|
|
// (assuming bn128 scalar field. We use capacity=1, rate=2, t=3).
|
|
|
|
template Poseidon2_hash_rate2(n) {
|
|
signal input inp[n];
|
|
signal output out;
|
|
|
|
component sponge = PoseidonSponge(3,1,n,1);
|
|
sponge.inp <== inp;
|
|
sponge.out[0] ==> out;
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|