Skip to main content

Crate starkom_poseidon2

Crate starkom_poseidon2 

Source
Expand description

§Poseidon2

CI crates.io license

§Overview

This is Starkom’s implementation of the Poseidon2 algebraic hash.

The implementation is generic and works on any prime field, but we always allocate exactly 1 state element for capacity, resulting in 128-bit security.

We also provide configurations for the BLS12-381 and BlueSky prime fields, for T=3 and T=4.

[!NOTE] The BLS12-381 configurations are controlled by the bls12_381 feature flag, which is disabled by default.

§Usage

The following example functions instantiate Poseidon2 with T=3 and T=4 respectively, squeezing a single element from the output.

use starkom_bluesky::Scalar;
use starkom_poseidon2;

fn hash_t3(inputs: &[Scalar]) -> Scalar {
    starkom_poseidon2::hash::<starkom_poseidon2::bluesky::BlueSkyConfig3, Scalar, 3>(inputs)[0]
}

fn hash_t4(inputs: &[Scalar]) -> Scalar {
    starkom_poseidon2::hash::<starkom_poseidon2::bluesky::BlueSkyConfig4, Scalar, 4>(inputs)[0]
}

Re-exports§

pub use bluesky::*;

Modules§

bluesky

Traits§

Config
Poseidon2 instance configuration trait.

Functions§

hash
Generic Poseidon2 implementation over the prime field F with state size T.
hash0
Convenience function for hashing with Poseidon2 and squeezing the first element.
sbox5
Standard x^5 S-box.