Skip to content

Commit

Permalink
fix: rename CircuitShape -> R1CSWithArity
Browse files Browse the repository at this point in the history
  • Loading branch information
huitseeker committed Jan 4, 2024
1 parent 0aca4cf commit ccd888d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
16 changes: 8 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ use traits::{
/// A type that holds parameters for the primary and secondary circuits of Nova and SuperNova
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(bound = "")]
pub struct CircuitShape<E: Engine> {
pub struct R1CSWithArity<E: Engine> {
F_arity: usize,
r1cs_shape: R1CSShape<E>,
}

impl<E: Engine> SimpleDigestible for CircuitShape<E> {}
impl<E: Engine> SimpleDigestible for R1CSWithArity<E> {}

impl<E: Engine> CircuitShape<E> {
impl<E: Engine> R1CSWithArity<E> {
/// Create a new `CircuitShape`
pub fn new(r1cs_shape: R1CSShape<E>, F_arity: usize) -> Self {
Self {
Expand All @@ -73,7 +73,7 @@ impl<E: Engine> CircuitShape<E> {

/// Return the [CircuitShape]' digest.
pub fn digest(&self) -> E::Scalar {
let dc: DigestComputer<'_, <E as Engine>::Scalar, CircuitShape<E>> = DigestComputer::new(self);
let dc: DigestComputer<'_, <E as Engine>::Scalar, R1CSWithArity<E>> = DigestComputer::new(self);
dc.digest().expect("Failure in computing digest")
}
}
Expand All @@ -93,11 +93,11 @@ where
ro_consts_primary: ROConstants<E1>,
ro_consts_circuit_primary: ROConstantsCircuit<E2>,
ck_primary: CommitmentKey<E1>,
circuit_shape_primary: CircuitShape<E1>,
circuit_shape_primary: R1CSWithArity<E1>,
ro_consts_secondary: ROConstants<E2>,
ro_consts_circuit_secondary: ROConstantsCircuit<E1>,
ck_secondary: CommitmentKey<E2>,
circuit_shape_secondary: CircuitShape<E2>,
circuit_shape_secondary: R1CSWithArity<E2>,
augmented_circuit_params_primary: NovaAugmentedCircuitParams,
augmented_circuit_params_secondary: NovaAugmentedCircuitParams,
#[serde(skip, default = "OnceCell::new")]
Expand Down Expand Up @@ -195,7 +195,7 @@ where
let mut cs: ShapeCS<E1> = ShapeCS::new();
let _ = circuit_primary.synthesize(&mut cs);
let (r1cs_shape_primary, ck_primary) = cs.r1cs_shape_and_key(ck_hint1);
let circuit_shape_primary = CircuitShape::new(r1cs_shape_primary, F_arity_primary);
let circuit_shape_primary = R1CSWithArity::new(r1cs_shape_primary, F_arity_primary);

// Initialize ck for the secondary
let circuit_secondary: NovaAugmentedCircuit<'_, E1, C2> = NovaAugmentedCircuit::new(
Expand All @@ -207,7 +207,7 @@ where
let mut cs: ShapeCS<E2> = ShapeCS::new();
let _ = circuit_secondary.synthesize(&mut cs);
let (r1cs_shape_secondary, ck_secondary) = cs.r1cs_shape_and_key(ck_hint2);
let circuit_shape_secondary = CircuitShape::new(r1cs_shape_secondary, F_arity_secondary);
let circuit_shape_secondary = R1CSWithArity::new(r1cs_shape_secondary, F_arity_secondary);

PublicParams {
F_arity_primary,
Expand Down
24 changes: 12 additions & 12 deletions src/supernova/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::{
commitment::{CommitmentEngineTrait, CommitmentTrait},
AbsorbInROTrait, Engine, ROConstants, ROConstantsCircuit, ROTrait,
},
CircuitShape, Commitment, CommitmentKey,
R1CSWithArity, Commitment, CommitmentKey,
};
use ff::Field;
use itertools::Itertools as _;
Expand Down Expand Up @@ -83,7 +83,7 @@ where
C2: StepCircuit<E2::Scalar>,
{
/// The internal circuit shapes
pub circuit_shapes: Vec<CircuitShape<E1>>,
pub circuit_shapes: Vec<R1CSWithArity<E1>>,

ro_consts_primary: ROConstants<E1>,
ro_consts_circuit_primary: ROConstantsCircuit<E2>,
Expand All @@ -93,7 +93,7 @@ where
ro_consts_secondary: ROConstants<E2>,
ro_consts_circuit_secondary: ROConstantsCircuit<E1>,
ck_secondary: CommitmentKey<E2>,
circuit_shape_secondary: CircuitShape<E2>,
circuit_shape_secondary: R1CSWithArity<E2>,
augmented_circuit_params_secondary: SuperNovaAugmentedCircuitParams,

/// Digest constructed from this `PublicParams`' parameters
Expand All @@ -120,7 +120,7 @@ where
ro_consts_secondary: ROConstants<E2>,
ro_consts_circuit_secondary: ROConstantsCircuit<E1>,
ck_secondary: CommitmentKey<E2>,
circuit_shape_secondary: CircuitShape<E2>,
circuit_shape_secondary: R1CSWithArity<E2>,
augmented_circuit_params_secondary: SuperNovaAugmentedCircuitParams,

digest: E1::Scalar,
Expand All @@ -133,7 +133,7 @@ where
C1: StepCircuit<E1::Scalar>,
C2: StepCircuit<E2::Scalar>,
{
type Output = CircuitShape<E1>;
type Output = R1CSWithArity<E1>;

fn index(&self, index: usize) -> &Self::Output {
&self.circuit_shapes[index]
Expand Down Expand Up @@ -206,7 +206,7 @@ where

// We use the largest commitment_key for all instances
let r1cs_shape_primary = cs.r1cs_shape();
CircuitShape::new(r1cs_shape_primary, F_arity)
R1CSWithArity::new(r1cs_shape_primary, F_arity)
})
.collect::<Vec<_>>();

Expand All @@ -231,7 +231,7 @@ where
.synthesize(&mut cs)
.expect("circuit synthesis failed");
let (r1cs_shape_secondary, ck_secondary) = cs.r1cs_shape_and_key(ck_hint2);
let circuit_shape_secondary = CircuitShape::new(r1cs_shape_secondary, F_arity_secondary);
let circuit_shape_secondary = R1CSWithArity::new(r1cs_shape_secondary, F_arity_secondary);

let pp = PublicParams {
circuit_shapes,
Expand All @@ -255,7 +255,7 @@ where
}

/// Breaks down an instance of [PublicParams] into the circuit params and auxiliary params.
pub fn into_parts(self) -> (Vec<CircuitShape<E1>>, AuxParams<E1, E2>) {
pub fn into_parts(self) -> (Vec<R1CSWithArity<E1>>, AuxParams<E1, E2>) {
let digest = self.digest();

let PublicParams {
Expand Down Expand Up @@ -290,7 +290,7 @@ where
}

/// Create a [PublicParams] from a vector of raw [CircuitShape] and auxiliary params.
pub fn from_parts(circuit_shapes: Vec<CircuitShape<E1>>, aux_params: AuxParams<E1, E2>) -> Self {
pub fn from_parts(circuit_shapes: Vec<R1CSWithArity<E1>>, aux_params: AuxParams<E1, E2>) -> Self {
let pp = PublicParams {
circuit_shapes,
ro_consts_primary: aux_params.ro_consts_primary,
Expand All @@ -316,7 +316,7 @@ where
/// Create a [PublicParams] from a vector of raw [CircuitShape] and auxiliary params.
/// We don't check that the `aux_params.digest` is a valid digest for the created params.
pub fn from_parts_unchecked(
circuit_shapes: Vec<CircuitShape<E1>>,
circuit_shapes: Vec<R1CSWithArity<E1>>,
aux_params: AuxParams<E1, E2>,
) -> Self {
PublicParams {
Expand All @@ -338,7 +338,7 @@ where
/// Compute primary and secondary commitment keys sized to handle the largest of the circuits in the provided
/// `CircuitShape`.
fn compute_primary_ck(
circuit_params: &[CircuitShape<E1>],
circuit_params: &[R1CSWithArity<E1>],
ck_hint1: &CommitmentKeyHint<E1>,
) -> CommitmentKey<E1> {
let size_primary = circuit_params
Expand Down Expand Up @@ -1059,7 +1059,7 @@ pub fn circuit_digest<
let _ = augmented_circuit.synthesize(&mut cs);

let F_arity = circuit.arity();
let circuit_params = CircuitShape::new(cs.r1cs_shape(), F_arity);
let circuit_params = R1CSWithArity::new(cs.r1cs_shape(), F_arity);
circuit_params.digest()
}

Expand Down

0 comments on commit ccd888d

Please sign in to comment.