Skip to content

Commit

Permalink
write results too
Browse files Browse the repository at this point in the history
  • Loading branch information
winston-h-zhang committed Apr 18, 2024
1 parent 7110611 commit 7e645a4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
33 changes: 15 additions & 18 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,21 @@ where
};

if write_data() {
write_arecibo_data(format!("sparse_matrices_{:?}", pp.digest()), "A", &r1cs_primary.A);
write_arecibo_data(format!("sparse_matrices_{:?}", pp.digest()), "B", &r1cs_primary.B);
write_arecibo_data(format!("sparse_matrices_{:?}", pp.digest()), "C", &r1cs_primary.C);
write_arecibo_data(
format!("sparse_matrices_{:?}", pp.digest()),
"A",
&r1cs_primary.A,
);
write_arecibo_data(
format!("sparse_matrices_{:?}", pp.digest()),
"B",
&r1cs_primary.B,
);
write_arecibo_data(
format!("sparse_matrices_{:?}", pp.digest()),
"C",
&r1cs_primary.C,
);
}

Ok(Self {
Expand Down Expand Up @@ -601,21 +613,6 @@ where
&mut self.buffer_primary.ABC_Z_2,
)?;

if write_data() {
let W = l_w_primary.W;
write_arecibo_data(
format!("witness_{:?}", pp.digest()),
format!("len_{}", W.len()),
&W,
);
let T = &self.buffer_primary.T;
write_arecibo_data(
format!("cross_term_{:?}", pp.digest()),
format!("len_{}", T.len()),
&T,
);
}

let mut cs_secondary = SatisfyingAssignment::<Dual<E1>>::with_capacity(
pp.circuit_shape_secondary.r1cs_shape.num_io + 1,
pp.circuit_shape_secondary.r1cs_shape.num_vars,
Expand Down
2 changes: 1 addition & 1 deletion src/nifs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,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(ck, U1, W1, U2, W2, T, ABC_Z_1, ABC_Z_2)?;
let comm_T = S.commit_T_into(ck, pp_digest, 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
13 changes: 13 additions & 0 deletions src/r1cs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pub(crate) mod util;

use crate::{
constants::{BN_LIMB_WIDTH, BN_N_LIMBS},
data::{write_arecibo_data, write_data},
digest::{DigestComputer, SimpleDigestible},
errors::NovaError,
gadgets::{f_to_nat, nat_to_limbs, scalar_as_base},
Expand Down Expand Up @@ -465,6 +466,7 @@ impl<E: Engine> R1CSShape<E> {
pub fn commit_T_into(
&self,
ck: &CommitmentKey<E>,
pp_digest: &E::Scalar,
U1: &RelaxedR1CSInstance<E>,
W1: &RelaxedR1CSWitness<E>,
U2: &R1CSInstance<E>,
Expand All @@ -473,6 +475,11 @@ impl<E: Engine> R1CSShape<E> {
ABC_Z_1: &mut R1CSResult<E>,
ABC_Z_2: &mut R1CSResult<E>,
) -> Result<Commitment<E>, NovaError> {
if write_data() {
let witness = [&W1.W[..], &[U1.u], &U1.X[..]].concat();
write_arecibo_data(format!("witness_{:?}", pp_digest), "", &witness);
}

tracing::info_span!("AZ_1, BZ_1, CZ_1")
.in_scope(|| self.multiply_witness_into(&W1.W, &U1.u, &U1.X, ABC_Z_1))?;

Expand All @@ -482,6 +489,12 @@ impl<E: Engine> R1CSShape<E> {
CZ: CZ_1,
} = ABC_Z_1;

if write_data() {
write_arecibo_data(format!("result_{:?}", pp_digest), "AZ", &AZ_1);
write_arecibo_data(format!("result_{:?}", pp_digest), "BZ", &BZ_1);
write_arecibo_data(format!("result_{:?}", pp_digest), "CZ", &CZ_1);
}

tracing::info_span!("AZ_2, BZ_2, CZ_2")
.in_scope(|| self.multiply_witness_into(&W2.W, &E::Scalar::ONE, &U2.X, ABC_Z_2))?;

Expand Down

0 comments on commit 7e645a4

Please sign in to comment.