Skip to content

Commit

Permalink
tidy: Cyclefold -> CycleFold
Browse files Browse the repository at this point in the history
  • Loading branch information
mpenciak committed Mar 22, 2024
1 parent 938877b commit 497aef7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
23 changes: 11 additions & 12 deletions src/cyclefold/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ use crate::{
use bellpepper::gadgets::boolean_utils::conditionally_select;

/// A structure containing the CycleFold circuit inputs and implementing the synthesize function
pub struct CyclefoldCircuit<E: Engine> {
pub struct CycleFoldCircuit<E: Engine> {
commit_1: Option<Commitment<E>>,
commit_2: Option<Commitment<E>>,
scalar: Option<[bool; NUM_CHALLENGE_BITS]>,
poseidon_constants: PoseidonConstants<E::Base, generic_array::typenum::U2>,
}

impl<E: Engine> Default for CyclefoldCircuit<E> {
impl<E: Engine> Default for CycleFoldCircuit<E> {
fn default() -> Self {
let poseidon_constants = PoseidonConstants::new();
Self {
Expand All @@ -34,7 +34,7 @@ impl<E: Engine> Default for CyclefoldCircuit<E> {
}
}
}
impl<E: Engine> CyclefoldCircuit<E> {
impl<E: Engine> CycleFoldCircuit<E> {
/// Create a new CycleFold circuit with the given inputs
pub fn new(
commit_1: Option<Commitment<E>>,
Expand Down Expand Up @@ -181,7 +181,7 @@ mod tests {
E1: CurveCycleEquipped,
{
// Instantiate the circuit with trivial inputs
let circuit: CyclefoldCircuit<Dual<E1>> = CyclefoldCircuit::default();
let circuit: CycleFoldCircuit<Dual<E1>> = CycleFoldCircuit::default();

// Synthesize the R1CS shape
let mut cs: ShapeCS<E1> = ShapeCS::new();
Expand Down Expand Up @@ -228,14 +228,13 @@ mod tests {
let r_bits = r
.to_le_bits()
.into_iter()
.map(Some)
.collect::<Option<Vec<_>>>()
.map(|mut vec| {
vec.resize_with(128, || false);
vec.try_into().unwrap()
});

let circuit: CyclefoldCircuit<Dual<E>> = CyclefoldCircuit::new(Some(C_1), Some(C_2), r_bits);
.take(128)
.collect::<Vec<_>>()
.try_into()
.unwrap();

let circuit: CycleFoldCircuit<Dual<E>> =
CycleFoldCircuit::new(Some(C_1), Some(C_2), Some(r_bits));

// Calculate the result out of circuit
let native_result = C_1 + C_2 * r;
Expand Down
10 changes: 5 additions & 5 deletions src/cyclefold/snark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{
BN_LIMB_WIDTH, BN_N_LIMBS, NIO_CYCLE_FOLD, NUM_CHALLENGE_BITS, NUM_FE_IN_EMULATED_POINT,
NUM_HASH_BITS,
},
cyclefold::circuit::CyclefoldCircuit,
cyclefold::circuit::CycleFoldCircuit,
errors::NovaError,
gadgets::scalar_as_base,
r1cs::{
Expand Down Expand Up @@ -98,7 +98,7 @@ where

let ro_consts_cyclefold = ROConstants::<Dual<E1>>::default();
let mut cs: ShapeCS<Dual<E1>> = ShapeCS::new();
let circuit_cyclefold: CyclefoldCircuit<E1> = CyclefoldCircuit::default();
let circuit_cyclefold: CycleFoldCircuit<E1> = CycleFoldCircuit::default();
let _ = circuit_cyclefold.synthesize(&mut cs);
let (r1cs_shape_cyclefold, ck_cyclefold) = cs.r1cs_shape_and_key(ck_hint_cyclefold);
let circuit_shape_cyclefold = R1CSWithArity::new(r1cs_shape_cyclefold, 0);
Expand Down Expand Up @@ -297,8 +297,8 @@ where
pp.circuit_shape_cyclefold.r1cs_shape.num_vars,
);

let circuit_cyclefold_E: CyclefoldCircuit<E1> =
CyclefoldCircuit::new(Some(self.r_U_primary.comm_E), Some(comm_T), r_bools);
let circuit_cyclefold_E: CycleFoldCircuit<E1> =
CycleFoldCircuit::new(Some(self.r_U_primary.comm_E), Some(comm_T), r_bools);

let _ = circuit_cyclefold_E.synthesize(&mut cs_cyclefold_E);

Expand All @@ -325,7 +325,7 @@ where
pp.circuit_shape_cyclefold.r1cs_shape.num_vars,
);

let circuit_cyclefold_W: CyclefoldCircuit<E1> = CyclefoldCircuit::new(
let circuit_cyclefold_W: CycleFoldCircuit<E1> = CycleFoldCircuit::new(
Some(self.r_U_primary.comm_W),
Some(self.l_u_primary.comm_W),
r_bools,
Expand Down

0 comments on commit 497aef7

Please sign in to comment.