Skip to content

Commit

Permalink
switch back to variable...
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanting Zhang committed Jan 11, 2024
1 parent 44fff73 commit 6876c06
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 22 deletions.
25 changes: 15 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ where

// fold the secondary circuit's instance
let nifs_secondary = NIFS::prove_mut(
// &pp.ck_secondary,
&pp.ck_secondary,
&self.buffer_secondary.msm_context,
&pp.ro_consts_secondary,
&scalar_as_base::<E1>(pp.digest()),
Expand Down Expand Up @@ -511,14 +511,16 @@ where

let zi_primary = circuit_primary.synthesize(&mut cs_primary)?;

let (l_u_primary, l_w_primary) = cs_primary.r1cs_fixed(
&pp.circuit_shape_primary.r1cs_shape,
&self.buffer_primary.msm_context,
)?;
// let (l_u_primary, l_w_primary) = cs_primary.r1cs_fixed(
// &pp.circuit_shape_primary.r1cs_shape,
// &self.buffer_primary.msm_context,
// )?;
let (l_u_primary, l_w_primary) =
cs_primary.r1cs_instance_and_witness(&pp.circuit_shape_primary.r1cs_shape, &pp.ck_primary)?;

// fold the primary circuit's instance
let nifs_primary = NIFS::prove_mut(
// &pp.ck_primary,
&pp.ck_primary,
&self.buffer_primary.msm_context,
&pp.ro_consts_primary,
&pp.digest(),
Expand Down Expand Up @@ -554,11 +556,14 @@ where
);
let zi_secondary = circuit_secondary.synthesize(&mut cs_secondary)?;

// let (l_u_secondary, l_w_secondary) = cs_secondary
// .r1cs_fixed(
// &pp.circuit_shape_secondary.r1cs_shape,
// &self.buffer_secondary.msm_context,
// )
// .map_err(|_e| NovaError::UnSat)?;
let (l_u_secondary, l_w_secondary) = cs_secondary
.r1cs_fixed(
&pp.circuit_shape_secondary.r1cs_shape,
&self.buffer_secondary.msm_context,
)
.r1cs_instance_and_witness(&pp.circuit_shape_secondary.r1cs_shape, &pp.ck_secondary)
.map_err(|_e| NovaError::UnSat)?;

// update the running instances and witnesses
Expand Down
6 changes: 3 additions & 3 deletions src/nifs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ impl<E: Engine> NIFS<E> {
#[allow(clippy::too_many_arguments)]
#[tracing::instrument(skip_all, level = "trace", name = "NIFS::prove_mut")]
pub fn prove_mut(
// ck: &CommitmentKey<E>,
context: &MSMContext<'_, E>,
_ck: &CommitmentKey<E>,
_context: &MSMContext<'_, E>,
ro_consts: &ROConstants<E>,
pp_digest: &E::Scalar,
S: &R1CSShape<E>,
Expand All @@ -109,7 +109,7 @@ impl<E: Engine> NIFS<E> {
U2.absorb_in_ro(&mut ro);

// compute a commitment to the cross-term
let comm_T = S.commit_T_into(context, U1, W1, U2, W2, T, ABC_Z_1, ABC_Z_2)?;
let comm_T = S.commit_T_into(_ck, _context, U1, W1, U2, W2, T, ABC_Z_1, ABC_Z_2)?;

// append `comm_T` to the transcript and obtain a challenge
comm_T.absorb_in_ro(&mut ro);
Expand Down
2 changes: 1 addition & 1 deletion src/provider/pasta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ macro_rules! impl_traits {
let zero_count = scalars.par_iter().filter(|s|<$name::Scalar as ff::Field>::is_zero_vartime(s)).count();
let start = std::time::Instant::now();
let ret = grumpkin_msm::pasta::$name::msm(bases, scalars);
eprintln!("zeros, scalars, preallocated-time: {}, {}, {:?}", zero_count, scalars.len(), start.elapsed());
eprintln!("zeros, scalars, time: {}, {}, {:?}", zero_count, scalars.len(), start.elapsed());
ret
} else {
cpu_best_msm(bases, scalars)
Expand Down
12 changes: 6 additions & 6 deletions src/r1cs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,8 @@ impl<E: Engine> R1CSShape<E> {
/// This is [`R1CSShape::commit_T`] but into a buffer.
pub fn commit_T_into(
&self,
// ck: &CommitmentKey<E>,
context: &MSMContext<'_, E>,
_ck: &CommitmentKey<E>,
_context: &MSMContext<'_, E>,
U1: &RelaxedR1CSInstance<E>,
W1: &RelaxedR1CSWitness<E>,
U2: &R1CSInstance<E>,
Expand Down Expand Up @@ -511,12 +511,12 @@ impl<E: Engine> R1CSShape<E> {
.collect_into_vec(T)
});


eprint!("commit T: ");
let commit_T_fixed = CE::<E>::commit_fixed(context, T);
// let commit_T = CE::<E>::commit(ck, T);
// let commit_T_fixed = CE::<E>::commit_fixed(_context, T);
let commit_T = CE::<E>::commit(_ck, T);
// assert_eq!(commit_T_fixed, commit_T);
Ok(commit_T_fixed)
// Ok(commit_T_fixed)
Ok(commit_T)
}

/// Pads the `R1CSShape` so that the number of variables is a power of two
Expand Down
4 changes: 2 additions & 2 deletions src/supernova/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ where

// fold the secondary circuit's instance
let nifs_secondary = NIFS::prove_mut(
// &pp.ck_secondary,
&pp.ck_secondary,
&self.buffer_secondary.msm_context,
&pp.ro_consts_secondary,
&scalar_as_base::<E1>(self.pp_digest),
Expand Down Expand Up @@ -767,7 +767,7 @@ where
};

let nifs_primary = NIFS::prove_mut(
// &pp.ck_primary,
&pp.ck_primary,
&self.buffer_primary.msm_context,
&pp.ro_consts_primary,
&self.pp_digest,
Expand Down

0 comments on commit 6876c06

Please sign in to comment.