Skip to content

Commit

Permalink
add dummy logic to the IntroducerCircuit so that tests can be run
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaucube committed Nov 12, 2024
1 parent febd1cb commit 131b784
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
22 changes: 19 additions & 3 deletions pod2/src/pod/gadget/introducer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,31 @@ use crate::{PlonkyProof, C, D, F};
pub struct IntroducerCircuit {}

/// IntroducerCircuit defines the circuit whose plonky2 proof is verified in the RecursiveCircuit
/// (1-level recursion).
/// (1-level recursion). This is, the POD1-Introducer circuit.
// TODO probably traitify this, and in the RecursionCircuit use the trait and not this specific
// struct directly.
// But for the moment we can implement here the circuit that verifies a POD1 (POD1-Introducer).
impl IntroducerCircuit {
pub fn circuit_data() -> Result<CircuitData<F, C, D>> {
todo!();
let config = CircuitConfig::standard_recursion_zk_config();

let mut builder = CircuitBuilder::<F, D>::new(config.clone());
Self::circuit_logic(&mut builder);

let data = builder.build::<C>();
Ok(data)
}

pub fn dummy_proof(circuit_data: CircuitData<F, C, D>) -> Result<PlonkyProof> {
todo!();
let inputs = PartialWitness::new();
let proof = circuit_data.prove(inputs)?;
Ok(proof.proof)
}

pub fn circuit_logic(builder: &mut CircuitBuilder<F, D>) {
let num_dummy_gates = 5_000;
for _ in 0..num_dummy_gates {
builder.add_gate(NoopGate, vec![]);
}
}
}
16 changes: 10 additions & 6 deletions pod2/src/recursion/recursion_framework.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,10 @@ where
// pod1 proof verification
let pod1_common_data = verifier_data.common.clone();

let pod1_verifier_data_targ = builder.add_verifier_data_public_inputs();
// notice that pod1_verifier_data is not registered as public input, while the cyclic
// recursive verifier_data is registered as public input.
let pod1_verifier_data_targ = builder
.add_virtual_verifier_data(pod1_verifier_data.common.config.fri_config.cap_height);

let pod1_proofs_targ: Result<[ProofWithPublicInputsTarget<D>; L]> =
array::try_from_fn(|i| {
Expand Down Expand Up @@ -467,7 +470,8 @@ where
let _: O::Targets = O::add_targets(&mut builder)?;

// pod1 proofs // TODO group with N in a single loop
let pod1_verifier_data = builder.add_verifier_data_public_inputs();
let pod1_verifier_data =
builder.add_virtual_verifier_data(data.common.config.fri_config.cap_height);
for _ in 0..L {
let proof = builder.add_virtual_proof_with_pis(&data.common);
builder.verify_proof::<C>(&proof, &pod1_verifier_data, &data.common);
Expand Down Expand Up @@ -567,14 +571,14 @@ mod tests {
println!("\n--------------------------------------------------");
println!("\n--------------------------------------------------");
println!(
"\nrunning test:\n===test_tree_recursion_opt with M={} (num InnerCircuits) N={} (arity of the recursion tree)",
M, N
"\nrunning test:\n===test_tree_recursion_opt with L={} (num POD1-Introducer proofs) M={} (num InnerCircuits) N={} (arity of the recursion tree)",
L, M, N
);

let l: u32 = 2; // levels of the recursion (binary) tree
println!(
"Testing {} recursive iterations, where each iteration checks M={} InnerCircuits and N={} plonky2 proofs",
l, M, N
"Testing {} recursive iterations, where each iteration checks L={} POD1-Introducer plonky2 proofs, M={} InnerCircuits and N={} cyclic plonky2 proofs",
l, L, M, N
);

let mut rng: rand::rngs::ThreadRng = rand::thread_rng();
Expand Down

0 comments on commit 131b784

Please sign in to comment.