Skip to main content

bench_poseidon2_perm/
lib.rs

1//! Poseidon2-WIDTH8 permutation-only benchmark — runs `PERM_COUNT`
2//! permutations on a chained state so each iteration's input depends
3//! on the previous output. Decomposes the hash cost out of the
4//! mini-verifier composite workload.
5
6#![cfg_attr(target_os = "none", no_std)]
7
8use subsoil as _;
9
10use gp::{canonical, permute};
11
12const PERM_COUNT: u32 = 1_000;
13
14pub fn poseidon2_perm_bench() -> u32 {
15    let mut state: [u64; 8] = [
16        0xdeadbeef_00000000,
17        0xdeadbeef_00000001,
18        0xdeadbeef_00000002,
19        0xdeadbeef_00000003,
20        0xdeadbeef_00000004,
21        0xdeadbeef_00000005,
22        0xdeadbeef_00000006,
23        0xdeadbeef_00000007,
24    ];
25    let mut i = 0;
26    while i < PERM_COUNT {
27        permute(&mut state);
28        i += 1;
29    }
30    (canonical(state[0]) & 0xFFFF_FFFF) as u32
31}