Skip to content

Commit

Permalink
rm .instances() since it's not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaucube committed Oct 4, 2024
1 parent 3402391 commit 9e4ca2f
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 88 deletions.
3 changes: 2 additions & 1 deletion examples/circom_full_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ fn main() {
let mut nova = N::init(&nova_params, f_circuit.clone(), z_0).unwrap();

// prepare the Decider prover & verifier params
let (decider_pp, decider_vp) = D::preprocess(&mut rng, nova_params, nova.clone()).unwrap();
let (decider_pp, decider_vp) =
D::preprocess(&mut rng, nova_params.clone(), nova.clone()).unwrap();

// run n steps of the folding iteration
for (i, external_inputs_at_step) in external_inputs.iter().enumerate() {
Expand Down
4 changes: 1 addition & 3 deletions examples/external_inputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,8 @@ fn main() {
folding_scheme.state()
);

let (running_instance, incoming_instance, cyclefold_instance) = folding_scheme.instances();

println!("Run the Nova's IVC verifier");
let ivc_proof = nova.ivc_proof();
let ivc_proof = folding_scheme.ivc_proof();
N::verify(
nova_params.1, // Nova's verifier params
ivc_proof,
Expand Down
4 changes: 1 addition & 3 deletions examples/multi_inputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,8 @@ fn main() {
println!("Nova::prove_step {}: {:?}", i, start.elapsed());
}

let (running_instance, incoming_instance, cyclefold_instance) = folding_scheme.instances();

println!("Run the Nova's IVC verifier");
let ivc_proof = nova.ivc_proof();
let ivc_proof = folding_scheme.ivc_proof();
N::verify(
nova_params.1, // Nova's verifier params
ivc_proof,
Expand Down
3 changes: 2 additions & 1 deletion examples/noir_full_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ fn main() {
let mut nova = N::init(&nova_params, f_circuit.clone(), z_0).unwrap();

// prepare the Decider prover & verifier params
let (decider_pp, decider_vp) = D::preprocess(&mut rng, nova_params, nova.clone()).unwrap();
let (decider_pp, decider_vp) =
D::preprocess(&mut rng, nova_params.clone(), nova.clone()).unwrap();

// run n steps of the folding iteration
for i in 0..5 {
Expand Down
3 changes: 2 additions & 1 deletion examples/noname_full_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ fn main() {
let mut nova = N::init(&nova_params, f_circuit.clone(), z_0).unwrap();

// prepare the Decider prover & verifier params
let (decider_pp, decider_vp) = D::preprocess(&mut rng, nova_params, nova.clone()).unwrap();
let (decider_pp, decider_vp) =
D::preprocess(&mut rng, nova_params.clone(), nova.clone()).unwrap();

// run n steps of the folding iteration
for (i, external_inputs_at_step) in external_inputs.iter().enumerate() {
Expand Down
4 changes: 1 addition & 3 deletions examples/sha256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,8 @@ fn main() {
println!("Nova::prove_step {}: {:?}", i, start.elapsed());
}

let (running_instance, incoming_instance, cyclefold_instance) = folding_scheme.instances();

println!("Run the Nova's IVC verifier");
let ivc_proof = nova.ivc_proof();
let ivc_proof = folding_scheme.ivc_proof();
N::verify(
nova_params.1, // Nova's verifier params
ivc_proof,
Expand Down
35 changes: 0 additions & 35 deletions folding-schemes/src/folding/hypernova/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -991,20 +991,6 @@ where
self.z_i.clone()
}

fn instances(
&self,
) -> (
Self::RunningInstance,
Self::IncomingInstance,
Self::CFInstance,
) {
(
(self.U_i.clone(), self.W_i.clone()),
(self.u_i.clone(), self.w_i.clone()),
(self.cf_U_i.clone(), self.cf_W_i.clone()),
)
}

fn ivc_proof(&self) -> Self::IVCProof {
Self::IVCProof {
i: self.i,
Expand Down Expand Up @@ -1168,18 +1154,6 @@ mod tests {
>(
poseidon_config: PoseidonConfig<Fr>,
F_circuit: CubicFCircuit<Fr>,
) -> (
HyperNova<Projective, GVar, Projective2, GVar2, CubicFCircuit<Fr>, CS1, CS2, 2, 3, H>,
(
ProverParams<Projective, Projective2, CS1, CS2, H>,
VerifierParams<Projective, Projective2, CS1, CS2, H>,
),
(LCCCS<Projective>, Witness<Fr>),
(CCCS<Projective>, Witness<Fr>),
(
CycleFoldCommittedInstance<Projective2>,
CycleFoldWitness<Projective2>,
),
) {
let mut rng = ark_std::test_rng();

Expand Down Expand Up @@ -1239,14 +1213,5 @@ mod tests {
ivc_proof,
)
.unwrap();

let (running_instance, incoming_instance, cyclefold_instance) = hypernova.instances();
(
hypernova,
hypernova_params,
running_instance,
incoming_instance,
cyclefold_instance,
)
}
}
4 changes: 3 additions & 1 deletion folding-schemes/src/folding/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ pub mod tests {
use crate::Error;
use crate::FoldingScheme;

/// tests the IVC proofs and its serializers for the 3 implemented IVCs: Nova, HyperNova and
/// ProtoGalaxy.
#[test]
fn test_serialize_ivc() {
fn test_serialize_ivc_nova_hypernova_protogalaxy() {
let poseidon_config = poseidon_canonical_config::<Fr>();
type FC = CubicFCircuit<Fr>;
let f_circuit = FC::new(()).unwrap();
Expand Down
20 changes: 3 additions & 17 deletions folding-schemes/src/folding/nova/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,13 +411,13 @@ where
// to serialize them, saving significant space in the VerifierParams serialized size.

// main circuit R1CS:
let f_circuit = FC::new(fcircuit_params).or(Err(SerializationError::InvalidData))?;
let f_circuit = FC::new(fcircuit_params).map_err(|_| SerializationError::InvalidData)?;
let cs = ConstraintSystem::<C1::ScalarField>::new_ref();
let augmented_F_circuit =
AugmentedFCircuit::<C1, C2, GC2, FC>::empty(&poseidon_config, f_circuit.clone());
augmented_F_circuit
.generate_constraints(cs.clone())
.or(Err(SerializationError::InvalidData))?;
.map_err(|_| SerializationError::InvalidData)?;
cs.finalize();
let cs = cs.into_inner().ok_or(SerializationError::InvalidData)?;
let r1cs = extract_r1cs::<C1::ScalarField>(&cs);
Expand All @@ -427,7 +427,7 @@ where
let cf_circuit = NovaCycleFoldCircuit::<C1, GC1>::empty();
cf_circuit
.generate_constraints(cs2.clone())
.or(Err(SerializationError::InvalidData))?;
.map_err(|_| SerializationError::InvalidData)?;
cs2.finalize();
let cs2 = cs2.into_inner().ok_or(SerializationError::InvalidData)?;
let cf_r1cs = extract_r1cs::<C1::BaseField>(&cs2);
Expand Down Expand Up @@ -933,20 +933,6 @@ where
self.z_i.clone()
}

fn instances(
&self,
) -> (
Self::RunningInstance,
Self::IncomingInstance,
Self::CFInstance,
) {
(
(self.U_i.clone(), self.W_i.clone()),
(self.u_i.clone(), self.w_i.clone()),
(self.cf_U_i.clone(), self.cf_W_i.clone()),
)
}

fn ivc_proof(&self) -> Self::IVCProof {
Self::IVCProof {
i: self.i,
Expand Down
13 changes: 0 additions & 13 deletions folding-schemes/src/folding/protogalaxy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -917,19 +917,6 @@ where
fn state(&self) -> Vec<C1::ScalarField> {
self.z_i.clone()
}
fn instances(
&self,
) -> (
Self::RunningInstance,
Self::IncomingInstance,
Self::CFInstance,
) {
(
(self.U_i.clone(), self.W_i.clone()),
(self.u_i.clone(), self.w_i.clone()),
(self.cf_U_i.clone(), self.cf_W_i.clone()),
)
}

fn ivc_proof(&self) -> Self::IVCProof {
Self::IVCProof {
Expand Down
10 changes: 0 additions & 10 deletions folding-schemes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,6 @@ where
/// returns the state at the current step
fn state(&self) -> Vec<C1::ScalarField>;

/// returns the instances at the current step, in the following order:
/// (running_instance, incoming_instance, cyclefold_instance)
fn instances(
&self,
) -> (
Self::RunningInstance,
Self::IncomingInstance,
Self::CFInstance,
);

/// returns the last IVC state proof, which can be verified in the `verify` method
fn ivc_proof(&self) -> Self::IVCProof;

Expand Down

0 comments on commit 9e4ca2f

Please sign in to comment.