Skip to content

Commit 97bd5bd

Browse files
committed
witness: add poseidon 16 and 24 witnesses
1 parent 786e2ec commit 97bd5bd

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

crates/leanVm/src/witness/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
pub mod dot_product;
2+
pub mod poseidon;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
use crate::constant::F;
2+
3+
/// Holds the high-level witness data for a single Poseidon2 permutation over 16 elements.
4+
#[derive(Debug)]
5+
pub struct WitnessPoseidon16 {
6+
/// The CPU cycle at which this operation is initiated, if applicable.
7+
pub cycle: Option<usize>,
8+
/// The memory address (vectorized pointer, of size 1) of the first 8-element input vector.
9+
pub addr_input_a: usize,
10+
/// The memory address (vectorized pointer, of size 1) of the second 8-element input vector.
11+
pub addr_input_b: usize,
12+
/// The memory address (vectorized pointer, of size 2) where the two 8-element output vectors are stored.
13+
pub addr_output: usize,
14+
/// The full 16-element input state for the permutation.
15+
pub input: [F; 16],
16+
/// The full 16-element output state resulting from the permutation.
17+
pub output: [F; 16],
18+
}
19+
20+
/// Holds the high-level witness data for a single Poseidon2 permutation over 24 elements.
21+
#[derive(Debug)]
22+
pub struct WitnessPoseidon24 {
23+
/// The CPU cycle at which this operation is initiated, if applicable.
24+
pub cycle: Option<usize>,
25+
/// The memory address (vectorized pointer, of size 2) of the first two 8-element input vectors.
26+
pub addr_input_a: usize,
27+
/// The memory address (vectorized pointer, of size 1) of the third 8-element input vector.
28+
pub addr_input_b: usize,
29+
/// The memory address (vectorized pointer, of size 1) where the relevant 8-element output vector is stored.
30+
pub addr_output: usize,
31+
/// The full 24-element input state for the permutation.
32+
pub input: [F; 24],
33+
/// The last 8 elements of the 24-element output state from the permutation.
34+
pub output: [F; 8],
35+
}

0 commit comments

Comments
 (0)