Skip to content

Commit

Permalink
More debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
moodlezoup committed Sep 19, 2024
1 parent a2f07ce commit 6db5a96
Show file tree
Hide file tree
Showing 16 changed files with 110 additions and 129 deletions.
6 changes: 6 additions & 0 deletions jolt-core/src/field/binius.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,3 +273,9 @@ impl<F: BiniusSpecific> ark_serialize::Valid for BiniusField<F> {
todo!()
}
}

impl<F: BiniusSpecific> std::fmt::Display for BiniusField<F> {
fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
todo!()
}
}
3 changes: 2 additions & 1 deletion jolt-core/src/field/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::fmt::Debug;
use std::fmt::{Debug, Display};
use std::ops::{Add, AddAssign, Div, Mul, MulAssign, Neg, Sub, SubAssign};

use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
Expand Down Expand Up @@ -31,6 +31,7 @@ pub trait JoltField:
+ Copy
+ Sync
+ Send
+ Display
+ Debug
+ Default
+ CanonicalSerialize
Expand Down
1 change: 1 addition & 0 deletions jolt-core/src/jolt/vm/bytecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub struct BytecodeStuff<T: CanonicalSerialize + CanonicalDeserialize> {
a_init_final: VerifierComputedOpening<T>,
v_init_final: VerifierComputedOpening<[T; 6]>,
}

pub type BytecodePolynomials<F: JoltField> = BytecodeStuff<DensePolynomial<F>>;
pub type BytecodeOpenings<F: JoltField> = BytecodeStuff<F>;
pub type BytecodeCommitments<PCS: CommitmentScheme> = BytecodeStuff<PCS::Commitment>;
Expand Down
15 changes: 5 additions & 10 deletions jolt-core/src/jolt/vm/instruction_lookups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use crate::{

use super::{JoltCommitments, JoltPolynomials, JoltTraceStep};

#[derive(Default, CanonicalSerialize, CanonicalDeserialize)]
#[derive(Debug, Default, CanonicalSerialize, CanonicalDeserialize)]
pub struct InstructionLookupStuff<T: CanonicalSerialize + CanonicalDeserialize> {
pub(crate) dim: Vec<T>,
read_cts: Vec<T>,
Expand Down Expand Up @@ -604,19 +604,10 @@ where
transcript,
);

// let sumcheck_opening_proof = PrimarySumcheckOpenings::prove_openings(
// generators,
// witness,
// &r_primary_sumcheck,
// &sumcheck_openings,
// transcript,
// );

let primary_sumcheck = PrimarySumcheck {
sumcheck_proof: primary_sumcheck_proof,
num_rounds,
openings: sumcheck_openings,
// opening_proof: sumcheck_opening_proof,
};

let memory_checking = Self::prove_memory_checking(
Expand Down Expand Up @@ -669,6 +660,9 @@ where
"Primary sumcheck check failed."
);

// TODO(moodlezoup)
opening_accumulator.append(&vec![], r_primary_sumcheck.clone(), &vec![], transcript);

// proof.primary_sumcheck.openings.verify_openings(
// generators,
// &proof.primary_sumcheck.opening_proof,
Expand Down Expand Up @@ -1072,6 +1066,7 @@ where
preprocessing: &InstructionLookupsPreprocessing<C, F>,
instruction_flags: &[F],
) -> Vec<F> {
debug_assert_eq!(instruction_flags.len(), Self::NUM_INSTRUCTIONS);
let mut memory_flags = vec![F::zero(); preprocessing.num_memories];
for instruction_index in 0..Self::NUM_INSTRUCTIONS {
for memory_index in &preprocessing.instruction_to_memory_indices[instruction_index] {
Expand Down
1 change: 1 addition & 0 deletions jolt-core/src/jolt/vm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ pub trait Jolt<F: JoltField, PCS: CommitmentScheme<Field = F>, const C: usize, c
Self::Constraints::construct_constraints(padded_trace_length, memory_start);
let spartan_key =
spartan::UniformSpartanProof::setup_precommitted(&r1cs_builder, padded_trace_length);
transcript.append_scalar(&spartan_key.vk_digest);

let r1cs_proof = R1CSProof {
key: spartan_key,
Expand Down
8 changes: 7 additions & 1 deletion jolt-core/src/jolt/vm/read_write_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,12 @@ where
"Output sumcheck check failed."
);

opening_accumulator.append(&[&commitment.v_final], r_sumcheck, &[&proof.opening]);
opening_accumulator.append(
&[&commitment.v_final],
r_sumcheck,
&[&proof.opening],
transcript,
);

Ok(())
}
Expand Down Expand Up @@ -1416,6 +1421,7 @@ where
TimestampValidityProof::verify(
&mut self.timestamp_validity_proof,
generators,
opening_accumulator,
// &commitment.timestamp_range_check,
// &commitment.read_write_memory,
transcript,
Expand Down
4 changes: 4 additions & 0 deletions jolt-core/src/jolt/vm/timestamp_range_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,7 @@ where
pub fn verify(
&mut self,
generators: &PCS::Setup,
opening_accumulator: &mut VerifierOpeningAccumulator<F, PCS>,
// TODO(moodlezoup)
// range_check_commitment: &RangeCheckCommitment<C>,
// memory_commitment: &MemoryCommitment<C>,
Expand Down Expand Up @@ -708,6 +709,9 @@ where
Some(generators),
);

// TODO(moodleozoup)
opening_accumulator.append(&vec![], r_grand_product.clone(), &vec![], transcript);

// // TODO(moodlezoup): Make indexing less disgusting
// let t_read_commitments = &memory_commitment.trace_commitments
// [1 + MEMORY_OPS_PER_INSTRUCTION + 5..1 + 2 * MEMORY_OPS_PER_INSTRUCTION + 5];
Expand Down
16 changes: 9 additions & 7 deletions jolt-core/src/lasso/memory_checking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,26 +235,26 @@ where
}

fn compute_openings(
_preprocessing: &Self::Preprocessing,
preprocessing: &Self::Preprocessing,
opening_accumulator: &mut ProverOpeningAccumulator<F>,
polynomials: &Self::Polynomials,
jolt_polynomials: &JoltPolynomials<F>,
r_read_write: &[F],
r_init_final: &[F],
transcript: &mut ProofTranscript,
) -> (Self::Openings, Self::ExogenousOpenings) {
let mut openings = Self::Openings::default();
let mut openings = Self::Openings::initialize(preprocessing);
let mut exogenous_openings = Self::ExogenousOpenings::default();

let eq_read_write = EqPolynomial::evals(r_read_write);
polynomials
.read_write_values()
.par_iter()
.zip(openings.read_write_values_mut().into_par_iter())
.zip_eq(openings.read_write_values_mut().into_par_iter())
.chain(
Self::ExogenousOpenings::exogenous_data(jolt_polynomials)
.par_iter()
.zip(exogenous_openings.openings_mut().into_par_iter()),
.zip_eq(exogenous_openings.openings_mut().into_par_iter()),
)
.for_each(|(poly, opening)| {
let claim = poly.evaluate_at_chi(&eq_read_write);
Expand All @@ -280,7 +280,7 @@ where
polynomials
.init_final_values()
.par_iter()
.zip(openings.init_final_values_mut().into_par_iter())
.zip_eq(openings.init_final_values_mut().into_par_iter())
.for_each(|(poly, opening)| {
let claim = poly.evaluate_at_chi(&eq_init_final);
*opening = claim;
Expand Down Expand Up @@ -426,7 +426,7 @@ where
pcs_setup: &PCS::Setup,
mut proof: MemoryCheckingProof<F, PCS, Self::Openings, Self::ExogenousOpenings>,
commitments: &Self::Commitments,
exogenous_commitments: &JoltCommitments<PCS>,
jolt_commitments: &JoltCommitments<PCS>,
opening_accumulator: &mut VerifierOpeningAccumulator<F, PCS>,
transcript: &mut ProofTranscript,
) -> Result<(), ProofVerifyError> {
Expand Down Expand Up @@ -457,7 +457,7 @@ where

let read_write_commits: Vec<_> = [
commitments.read_write_values(),
exogenous_commitments.read_write_values(),
Self::ExogenousOpenings::exogenous_data(jolt_commitments),
]
.concat();
let read_write_claims: Vec<_> = [
Expand All @@ -469,12 +469,14 @@ where
&read_write_commits,
r_read_write.to_vec(),
&read_write_claims,
transcript,
);

opening_accumulator.append(
&commitments.init_final_values(),
r_read_write.to_vec(),
&proof.openings.init_final_values(),
transcript,
);

// proof.read_write_openings.verify_openings(
Expand Down
8 changes: 7 additions & 1 deletion jolt-core/src/poly/opening_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,11 @@ impl<F: JoltField> ProverOpeningAccumulator<F> {
claims: &[&F],
transcript: &mut ProofTranscript,
) {
assert_eq!(polynomials.len(), claims.len());
// Generate batching challenge \rho and powers 1,...,\rho^{m-1}
let rho: F = transcript.challenge_scalar();
// let rho: F = F::one(); // TODO(moodlezoup)

let mut rho_powers = vec![F::one()];
for i in 1..polynomials.len() {
rho_powers.push(rho_powers[i - 1] * rho);
Expand Down Expand Up @@ -355,8 +358,11 @@ impl<F: JoltField, PCS: CommitmentScheme<Field = F>> VerifierOpeningAccumulator<
commitments: &[&PCS::Commitment],
opening_point: Vec<F>,

Check failure on line 359 in jolt-core/src/poly/opening_proof.rs

View workflow job for this annotation

GitHub Actions / clippy

unused variable: `opening_point`

Check failure on line 359 in jolt-core/src/poly/opening_proof.rs

View workflow job for this annotation

GitHub Actions / Onchain Verifier Tests

unused variable: `opening_point`

Check failure on line 359 in jolt-core/src/poly/opening_proof.rs

View workflow job for this annotation

GitHub Actions / test

unused variable: `opening_point`
claims: &[&F],
transcript: &mut ProofTranscript,
) {
todo!("Compute RLC commitment/claim");
assert_eq!(commitments.len(), claims.len());
let _: F = transcript.challenge_scalar();
// todo!("Compute RLC commitment/claim");
// self.openings
// .push(VerifierOpening::new(commitment, opening_point, claim));
}
Expand Down
Loading

0 comments on commit 6db5a96

Please sign in to comment.