Crates.io | rescue_poseidon |
lib.rs | rescue_poseidon |
version | 0.30.10 |
source | src |
created_at | 2024-07-05 06:22:25.887 |
updated_at | 2024-11-28 13:31:34.805278 |
description | Sponge construction based Algebraic Hash Functions |
homepage | https://zksync.io/ |
repository | https://github.com/matter-labs/zksync-crypto/ |
max_upload_size | |
id | 1292406 |
size | 279,080 |
This repo contains implementations of arithmetization oriented hash functions(Rescue, Poseidon, Rescue Prime) that constructed by a sponge construction over prime field for both out-of circuits and in-circuit usages. Each algebraic hash function uses same sponge construction with different round function or permutation function. Gadgets are optimal in the constraint systems while also supporting different scalar fields which supported by bellman.
Add dependency
rescue_poseidon = 0.1
use franklin_crypto::bellman::bn256::Fr;
use franklin_crypto::bellman::Field;
use rescue_poseidon::rescue_hash;
const L: usize = 2;
let input = [Fr::one(); L]; // dummy input
// fixed length rescue hash
let result = rescue_hash::<Bn256, L>(&input);
assert_eq!(result.len(), 2);
More examples can be found in examples
folder.
cargo test -- --nocapture
cargo bench -- --nocapture
CPU: 3,1 GHz Intel Core i5
hashes | 1x permutation runtime (μs) | 1x permutation gates | number of rounds |
---|---|---|---|
Poseidon | 13 | 166 | 8f + 33p |
Rescue | 680 | 266 | 44f |
Rescue Prime | 300 | 104 | 9f |