Skip to content

Commit

Permalink
add L to pex, and L=0 to constants to make it compile without using y…
Browse files Browse the repository at this point in the history
…et the POD1-Introducer recursive verifier
  • Loading branch information
arnaucube authored and ax0 committed Dec 6, 2024
1 parent 224cbe8 commit 0bfb067
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 17 deletions.
1 change: 1 addition & 0 deletions constants/src/constants.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub const NS: usize = 10; // Max number of statements in a POD
pub const VL: usize = 10; // Max length of vectors
pub const L: usize = 0; // Max number of POD1-Introducer (1 level recursion) verifications
pub const M: usize = 2; // Max number of Schnorr POD
pub const N: usize = 2; // Max number of recursive proof verification in the creation of a POD
10 changes: 5 additions & 5 deletions pex/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mod macros;
mod pex_constants;
use constants::{M, N, NS, VL};
use constants::{L, M, N, NS, VL};
pub mod repl;
pub mod store;

Expand All @@ -26,7 +26,7 @@ use plonky2::{
use pod2::{
pod::{
entry::Entry,
gadget::{plonky_pod::ProverParams, GadgetID, PlonkyButNotPlonkyGadget},
gadget::{plonky_pod::ProverParams, GadgetID},
origin::Origin,
payload::HashablePayload,
statement::{AnchoredKey, StatementRef},
Expand Down Expand Up @@ -214,7 +214,7 @@ pub struct Env {
bindings: Arc<Mutex<HashMap<String, Value>>>,
sk: Option<SchnorrSecretKey>,
script_id: Option<ScriptId>,
prover_params: Option<Arc<Mutex<ProverParams<M, N, NS, VL>>>>,
prover_params: Option<Arc<Mutex<ProverParams<L, M, N, NS, VL>>>>,
}

#[derive(Clone, Debug)]
Expand Down Expand Up @@ -744,7 +744,7 @@ impl PodBuilder {
.collect::<Vec<OpCmd>>()[..];
if let Some(prover_params) = &env.prover_params {
let mut params = prover_params.lock().unwrap();
POD::execute_plonky_gadget::<M, N, NS, VL>(&mut params, &gpg_input, pending_ops)
POD::execute_plonky_gadget::<L, M, N, NS, VL>(&mut params, &gpg_input, pending_ops)
} else {
POD::execute_oracle_gadget(&gpg_input, pending_ops)
}
Expand All @@ -759,7 +759,7 @@ impl Env {
pod_store: Arc<Mutex<MyPods>>,
sk: Option<SchnorrSecretKey>,
script_id: Option<ScriptId>,
prover_params: Option<Arc<Mutex<ProverParams<M, N, NS, VL>>>>,
prover_params: Option<Arc<Mutex<ProverParams<L, M, N, NS, VL>>>>,
) -> Self {
Self {
user,
Expand Down
15 changes: 12 additions & 3 deletions pex/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use pex::{
use pex::{Env, MyPods, Value};
use pod2::{
pod::gadget::PlonkyButNotPlonkyGadget,
recursion::traits::IntroducerCircuitTrait,
signature::schnorr::{SchnorrSecretKey, SchnorrSigner},
};
use reedline::{
Expand Down Expand Up @@ -130,9 +131,17 @@ async fn main() -> Result<()> {

let pod_store = Arc::new(Mutex::new(MyPods::default()));
let spinner = create_spinner("Generating prover parameters...");
let circuit_data = PlonkyButNotPlonkyGadget::<M, N, NS, VL>::circuit_data().unwrap();
let prover_params =
PlonkyButNotPlonkyGadget::<M, N, NS, VL>::build_prover_params(circuit_data).unwrap();

let pod1_circuit_data =
pod2::recursion::traits_examples::ExampleIntroducer::circuit_data().unwrap();
let pod1_verifier_data = pod1_circuit_data.verifier_data();
let circuit_data =
PlonkyButNotPlonkyGadget::<L, M, N, NS, VL>::circuit_data(pod1_verifier_data).unwrap();
let prover_params = PlonkyButNotPlonkyGadget::<L, M, N, NS, VL>::build_prover_params(
pod1_circuit_data,
circuit_data,
)
.unwrap();
spinner.finish_and_clear();
println!("⚙️ Prover parameters generated");
let env = Env::new(
Expand Down
15 changes: 10 additions & 5 deletions pod2/src/pod/gadget/plonky_pod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ use crate::pod::operation::OpList;
use crate::pod::payload::{PODPayload, StatementList};
use crate::pod::statement::Statement;
use crate::pod::{GPGInput, PODProof, POD};
use crate::recursion::{IntroducerCircuitTrait, RecursionCircuit};
use crate::recursion::{
traits_examples::ExampleIntroducer, IntroducerCircuitTrait, RecursionCircuit,
};
use crate::signature::schnorr::SchnorrSecretKey;

use crate::{PlonkyProof, C, D, F};
Expand Down Expand Up @@ -147,7 +149,8 @@ where
NS,
VL,
>::dummy_proof(circuit_data);
let pod1_dummy_proof = IntroducerCircuit::dummy_proof(pod1_circuit_data)?;
// let pod1_dummy_proof = IntroducerCircuit::dummy_proof(pod1_circuit_data)?;
let pod1_dummy_proof = ExampleIntroducer::dummy_proof(pod1_circuit_data)?;

Ok(ProverParams {
circuit,
Expand Down Expand Up @@ -443,7 +446,7 @@ mod tests {
statement::StatementRef,
POD,
},
recursion::IntroducerCircuitTrait,
recursion::{traits_examples::ExampleIntroducer, IntroducerCircuitTrait},
signature::schnorr::SchnorrSecretKey,
};

Expand Down Expand Up @@ -525,7 +528,8 @@ mod tests {

// build the circuit_data, this struct is reused for all the calls of
// PlonkyButNotPlonkyGadget::execute
let pod1_circuit_data = IntroducerCircuit::circuit_data()?;
// let pod1_circuit_data = IntroducerCircuit::circuit_data()?; // TODO
let pod1_circuit_data = ExampleIntroducer::circuit_data()?;
let pod1_verifier_data = pod1_circuit_data.verifier_data();
let circuit_data =
PlonkyButNotPlonkyGadget::<L, M, N, NS, VL>::circuit_data(pod1_verifier_data)?;
Expand Down Expand Up @@ -598,7 +602,8 @@ mod tests {
.collect(),
);

let pod1_circuit_data = IntroducerCircuit::circuit_data()?;
// let pod1_circuit_data = IntroducerCircuit::circuit_data()?; // TODO
let pod1_circuit_data = ExampleIntroducer::circuit_data()?;
let pod1_verifier_data = pod1_circuit_data.verifier_data();
let circuit_data =
PlonkyButNotPlonkyGadget::<L, M, N, NS, VL>::circuit_data(pod1_verifier_data)?;
Expand Down
10 changes: 6 additions & 4 deletions pod2/src/pod/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::pod::{
payload::{HashablePayload, PODPayload},
value::ScalarOrVec,
};
use crate::recursion::IntroducerCircuitTrait;
use crate::recursion::{traits_examples::ExampleIntroducer, IntroducerCircuitTrait};
use crate::signature::schnorr::{
SchnorrPublicKey, SchnorrSecretKey, SchnorrSignature, SchnorrSigner,
};
Expand Down Expand Up @@ -122,7 +122,8 @@ impl POD {
// get the verifier_data on the fly) takes a considerable amount of time to
// compute. Need to think how we modify the interface to pass the verifier_data to
// this method.
let pod1_circuit_data = IntroducerCircuit::circuit_data()?;
// let pod1_circuit_data = IntroducerCircuit::circuit_data()?; // TODO
let pod1_circuit_data = ExampleIntroducer::circuit_data()?;
let pod1_verifier_data = pod1_circuit_data.verifier_data();
let circuit_data =
PlonkyButNotPlonkyGadget::<L, M, N, NS, VL>::circuit_data(pod1_verifier_data)?;
Expand Down Expand Up @@ -464,7 +465,7 @@ impl GPGInput {

#[cfg(test)]
mod tests {
use crate::recursion::IntroducerCircuitTrait;
use crate::recursion::{traits_examples::ExampleIntroducer, IntroducerCircuitTrait};
use operation::Operation as Op;
use parcnet_pod::{pod::pod_impl::create_pod, pod_entries};
use statement::StatementRef;
Expand Down Expand Up @@ -905,7 +906,8 @@ mod tests {
),
];

let pod1_circuit_data = IntroducerCircuit::circuit_data()?;
// let pod1_circuit_data = IntroducerCircuit::circuit_data()?; // TODO
let pod1_circuit_data = ExampleIntroducer::circuit_data()?;
let pod1_verifier_data = pod1_circuit_data.verifier_data();
let circuit_data =
PlonkyButNotPlonkyGadget::<L, M, N, NS, VL>::circuit_data(pod1_verifier_data)?;
Expand Down

0 comments on commit 0bfb067

Please sign in to comment.