Trait Poseidon2Params

Source
pub trait Poseidon2Params<F: PrimeField, const T: usize>: Clone {
    const D: usize;
    const EXT_ROUNDS: usize;
    const INT_ROUNDS: usize;
    const T: usize = T;

    // Required methods
    fn external_rc() -> &'static [[F; T]];
    fn internal_rc() -> &'static [F];
    fn internal_mat_diag_m_1() -> &'static [F; T];

    // Provided method
    fn sanity_check() -> bool { ... }
}
Expand description

Parameters required for a Poseidon2 permutation instance.

§Generic parameters

  • F: field choice
  • T: state size = rate + capacity, T is made generic for easy trait bound on permute<F,T>(input: [F; N]) and type safety on external_rc() return type.

Required Associated Constants§

Source

const D: usize

d: sbox degree

Source

const EXT_ROUNDS: usize

round_F: number of external rounds (incl. initial and terminal) round_F = 2 * round_f

Source

const INT_ROUNDS: usize

round_P: number of internal rounds

Provided Associated Constants§

Source

const T: usize = T

t: state size = rate + capacity

Required Methods§

Source

fn external_rc() -> &'static [[F; T]]

round constants for all external rounds

Source

fn internal_rc() -> &'static [F]

round constants for internal rounds

Source

fn internal_mat_diag_m_1() -> &'static [F; T]

diffusion (diagonal) matrix minus one used in internal rounds

Provided Methods§

Source

fn sanity_check() -> bool

A default sanity check on the parameters and constant getters

State size only supports: 2, 3, 4, 8, 12, 16, 20, 24 for now S-box size only supports: 3, 5, 7, 11

§Round constants

Rust doesn’t permit generic param to be used in const operations, thus leveraging type system to ensure sanity such as const INT_RC: &'static [F; Self::INT_ROUNDS] is not allowed.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Poseidon2Params<Fp<MontBackend<FrConfig, 4>, 4>, 2> for Poseidon2ParamsBls2

Source§

const T: usize = 2usize

Source§

const D: usize = 5usize

Source§

const EXT_ROUNDS: usize = 8usize

Source§

const INT_ROUNDS: usize = 56usize

Source§

impl Poseidon2Params<Fp<MontBackend<FrConfig, 4>, 4>, 3> for Poseidon2ParamsBls3

Source§

const T: usize = 3usize

Source§

const D: usize = 5usize

Source§

const EXT_ROUNDS: usize = 8usize

Source§

const INT_ROUNDS: usize = 56usize

Source§

impl Poseidon2Params<Fp<MontBackend<FrConfig, 4>, 4>, 3> for Poseidon2ParamsBn3

Source§

const T: usize = 3usize

Source§

const D: usize = 5usize

Source§

const EXT_ROUNDS: usize = 8usize

Source§

const INT_ROUNDS: usize = 56usize