diff --git a/src/cyclefold/circuit.rs b/src/cyclefold/circuit.rs index 7128b7e9c..1d13d1937 100644 --- a/src/cyclefold/circuit.rs +++ b/src/cyclefold/circuit.rs @@ -157,7 +157,10 @@ mod tests { .iter() .map(|b| Some(*b)) .collect::>>() - .map(|v| v.try_into().unwrap()); + .map(|mut vec| { + vec.resize_with(128, || false); + vec.try_into().unwrap() + }); let circuit: CyclefoldCircuit> = CyclefoldCircuit::new(Some(C_1), Some(C_2), r_bits); diff --git a/src/cyclefold/nifs.rs b/src/cyclefold/nifs.rs index 9021e8be3..5f17d6245 100644 --- a/src/cyclefold/nifs.rs +++ b/src/cyclefold/nifs.rs @@ -89,9 +89,15 @@ where ), NovaError, > { + let arity = U1.X.len(); + + if arity != U2.X.len() { + return Err(NovaError::InvalidInputLength); + } + let mut ro = E2::RO::new( ro_consts.clone(), - 1 + NUM_FE_IN_EMULATED_POINT + 2 + NUM_FE_IN_EMULATED_POINT, // pp_digest + u.W + u.X + T + 1 + NUM_FE_IN_EMULATED_POINT + arity + NUM_FE_IN_EMULATED_POINT, // pp_digest + u.W + u.X + T ); ro.absorb(*pp_digest); diff --git a/src/cyclefold/nova_circuit.rs b/src/cyclefold/nova_circuit.rs index e8aed6fd8..4a4b49043 100644 --- a/src/cyclefold/nova_circuit.rs +++ b/src/cyclefold/nova_circuit.rs @@ -524,7 +524,7 @@ mod test { use super::*; - fn test_circuit_size_with() + fn test_augmented_circuit_size_with() where E: CurveCycleEquipped, { @@ -552,9 +552,9 @@ mod test { } #[test] - fn test_circuit_size() { - test_circuit_size_with::(); - test_circuit_size_with::(); - test_circuit_size_with::(); + fn test_augmented_circuit_size() { + test_augmented_circuit_size_with::(); + test_augmented_circuit_size_with::(); + test_augmented_circuit_size_with::(); } } diff --git a/src/cyclefold/snark.rs b/src/cyclefold/snark.rs index b64e4cfc3..1d65d8571 100644 --- a/src/cyclefold/snark.rs +++ b/src/cyclefold/snark.rs @@ -526,5 +526,61 @@ where #[cfg(test)] mod test { - // use super::*; + use std::marker::PhantomData; + + use bellpepper_core::num::AllocatedNum; + + use super::*; + use crate::{ + provider::{Bn256Engine, PallasEngine, Secp256k1Engine}, + traits::snark::default_ck_hint, + }; + + #[derive(Clone)] + struct SquareCircuit { + _p: PhantomData, + } + + impl StepCircuit for SquareCircuit { + fn arity(&self) -> usize { + 1 + } + + fn synthesize>( + &self, + cs: &mut CS, + z: &[AllocatedNum], + ) -> Result>, SynthesisError> { + let x = &z[0]; + let x_sq = x.square(cs.namespace(|| "x_sq"))?; + + Ok(vec![x_sq]) + } + } + + fn test_trivial_cyclefold_prove_verify_with() { + let num_steps = 1; + let primary_circuit = SquareCircuit:: { _p: PhantomData }; + + let pp = PublicParams::::setup(&primary_circuit, &*default_ck_hint(), &*default_ck_hint()); + + let z0 = vec![E::Scalar::from(2u64)]; + + let mut recursive_snark = RecursiveSNARK::new(&pp, &primary_circuit, &z0).unwrap(); + + let res = recursive_snark.prove_step(&pp, &primary_circuit); + + assert!(res.is_ok()); + + let res = recursive_snark.verify(&pp, num_steps, &z0); + + assert!(res.is_ok()); + } + + #[test] + fn test_cyclefold_prove_verify() { + test_trivial_cyclefold_prove_verify_with::(); + test_trivial_cyclefold_prove_verify_with::(); + test_trivial_cyclefold_prove_verify_with::(); + } }