Skip to main content

sp1_hypercube/operations/poseidon2/
mod.rs

1//! An AIR operation for the Poseidon2 hash function.
2
3use permutation::Poseidon2Degree3Cols;
4use sp1_derive::AlignedBorrow;
5
6pub mod air;
7pub mod permutation;
8pub mod trace;
9
10/// The width of the permutation.
11pub const WIDTH: usize = 16;
12
13/// The rate of the permutation.
14pub const RATE: usize = WIDTH / 2;
15
16/// The number of external rounds.
17pub const NUM_EXTERNAL_ROUNDS: usize = 8;
18
19/// The number of internal rounds.
20pub const NUM_INTERNAL_ROUNDS: usize = 20;
21
22/// The total number of rounds.
23pub const NUM_ROUNDS: usize = NUM_EXTERNAL_ROUNDS + NUM_INTERNAL_ROUNDS;
24
25/// The number of columns in the Poseidon2 operation.
26pub const NUM_POSEIDON2_OPERATION_COLUMNS: usize = std::mem::size_of::<Poseidon2Operation<u8>>();
27
28/// A set of columns needed to compute the Poseidon2 operation.
29#[derive(AlignedBorrow, Clone, Copy)]
30#[repr(C)]
31pub struct Poseidon2Operation<T: Copy> {
32    /// The permutation.
33    pub permutation: Poseidon2Degree3Cols<T>,
34}