ZK-SecreC Documentation

2024.09

Module Poseidon

Function poseidon

pub fn poseidon [ N : Nat, $S, @D ] ( data : list[uint[N] $S @D] $pre @public, t : uint[N] $S @public, r : uint[N] $S @public, o : uint[N] $S @public, alpha : uint[N] $S @public, R_F : uint[N] $S @public, R_P : uint[N] $S @public, round_constants : list[uint[N] $S @public] $pre @public, mds_matrix : list[list[uint[N] $S @public] $pre @public] $pre @public, rate_first : bool $pre @public ) -> list[uint[N] $S @D] $pre @public
where
  Field[N]

Hashing the data given as the first argument with Poseidon instance with parameters given as the other arguments.

Function poseidon_continue

pub fn poseidon_continue [ N : Nat, $S, @D ] ( poseidon_obj : PoseidonInstance[N, $S, @D] $pre @public, data : list[uint[N] $S @D] $pre @public ) -> PoseidonInstance[N, $S, @D] $pre @public
where
  Field[N]

Absorbing new data given as the second argument into the PoseidonInstance object given as the first argument. Fails if the length of the data list is not a multiple of the parameter r of the PoseidonSpongeParams object (in the sponge_params field of the PoseidonInstance object).

Function poseidon_finalize

pub fn poseidon_finalize [ N : Nat, $S, @D ] ( poseidon_obj : PoseidonInstance[N, $S, @D] $pre @public ) -> list[uint[N] $S @D] $pre @public
where
  Field[N]

Final output of the given PoseidonInstance object, assuming that it has absorbed all necessary data.

Function poseidon_initialize

pub fn poseidon_initialize [ N : Nat, $S, @D ] ( t : uint[N] $S @public, r : uint[N] $S @public, o : uint[N] $S @public, alpha : uint[N] $S @public, R_F : uint[N] $S @public, R_P : uint[N] $S @public, round_constants : list[uint[N] $S @public] $pre @public, mds_matrix : list[list[uint[N] $S @public] $pre @public] $pre @public, rate_first : bool $pre @public ) -> PoseidonInstance[N, $S, @D] $pre @public

A new PoseidonInstance object with the given parameters. Fails if the parameters do not satisfy two conditions assumed about Poseidon instances (r < t, R_F is even).

Function poseidon_perm

pub fn poseidon_perm [ N : Nat, $S, @D ] ( ref inner_state : list[uint[N] $S @D] $pre @public, perm_params : PoseidonPermParams[N, $S, @D] $pre @public, partial_round_pow_i : uint[18446744073709551616] $pre @public ) -> () $pre @public
where
  Field[N]

Applying the Poseidon permutation with parameters given as the second and third arguments to the state given as the first argument.