diff --git a/codex-plonky2-circuits/benches/prove_cells.rs b/codex-plonky2-circuits/benches/prove_cells.rs index aaa60b3..3a561e9 100644 --- a/codex-plonky2-circuits/benches/prove_cells.rs +++ b/codex-plonky2-circuits/benches/prove_cells.rs @@ -27,17 +27,18 @@ macro_rules! pretty_print { // Hash function used type HF = PoseidonHash; -fn prepare_data(N: usize) -> Result<( - SlotTreeCircuit, +fn prepare_data< + F: RichField + Extendable + Poseidon2, + C: GenericConfig, + const D: usize, + H: Hasher + AlgebraicHasher, +>(N: usize) -> Result<( + SlotTreeCircuit, Vec, Vec>, -)> -where - F: RichField + Extendable<2> + Poseidon2, - H: Hasher + AlgebraicHasher + Hasher, -{ +)> { // Initialize the slot tree with default data - let slot_tree = SlotTreeCircuit::::default(); + let slot_tree = SlotTreeCircuit::::default(); // Select N leaf indices to prove let leaf_indices: Vec = (0..N).collect(); @@ -51,15 +52,16 @@ where Ok((slot_tree, leaf_indices, proofs)) } -fn build_circuit( - slot_tree: &SlotTreeCircuit, +fn build_circuit< + F: RichField + Extendable + Poseidon2, + C: GenericConfig, + const D: usize, + H: Hasher + AlgebraicHasher, +>( + slot_tree: &SlotTreeCircuit, leaf_indices: &[usize], proofs: &[MerkleProof], ) -> Result<(CircuitData, PartialWitness)> -where - F: RichField + Extendable + Poseidon2, - C: GenericConfig, - H: Hasher + AlgebraicHasher + Hasher, { // Create the circuit let config = CircuitConfig::standard_recursion_config(); @@ -68,19 +70,13 @@ where // Create a PartialWitness let mut pw = PartialWitness::new(); - // Initialize the circuit instance - let mut circuit_instance = MerkleTreeCircuit:: { - tree: slot_tree.tree.clone(), - _phantom: PhantomData, - }; - // For each proof, create targets, add constraints, and assign witnesses for (i, &leaf_index) in leaf_indices.iter().enumerate() { // Build the circuit for each proof - let mut targets = circuit_instance.prove_single_cell2(&mut builder); + let mut targets = SlotTreeCircuit::::prove_single_cell(&mut builder); // Assign witnesses for each proof - circuit_instance.single_cell_assign_witness( + slot_tree.single_cell_assign_witness( &mut pw, &mut targets, leaf_index, @@ -106,7 +102,7 @@ fn single_cell_proof_benchmark(c: &mut Criterion) { // Prepare the data that will be used in all steps let N = 5; // Number of leaves to prove - let (slot_tree, leaf_indices, proofs) = prepare_data::(N).unwrap(); + let (slot_tree, leaf_indices, proofs) = prepare_data::(N).unwrap(); // Benchmark the circuit building group.bench_function("Single Cell Proof Build", |b| {