#poseidon-hash #sponge #prime-field #poseidon #rescue

nightly rescue_poseidon

Sponge construction based Algebraic Hash Functions

12 releases

new 0.30.8 Nov 19, 2024
0.30.7 Nov 18, 2024
0.30.6 Oct 31, 2024
0.30.1 Sep 5, 2024
0.4.1 Jul 5, 2024

#254 in Cryptography

Download history 10709/week @ 2024-07-30 7493/week @ 2024-08-06 10983/week @ 2024-08-13 13520/week @ 2024-08-20 18117/week @ 2024-08-27 19293/week @ 2024-09-03 17700/week @ 2024-09-10 6606/week @ 2024-09-17 5156/week @ 2024-09-24 6154/week @ 2024-10-01 10802/week @ 2024-10-08 8676/week @ 2024-10-15 9012/week @ 2024-10-22 8495/week @ 2024-10-29 5797/week @ 2024-11-05 5815/week @ 2024-11-12

31,053 downloads per month
Used in 16 crates (2 directly)

MIT/Apache

2MB
41K SLoC

Rescue and Poseidon

Overview

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.

Usage

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.

Testing

cargo test -- --nocapture

Benchmarks & Constraint System Costs

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

References

Dependencies

~17MB
~306K SLoC