From 9a9002deeccbfecc4de9db7246f650c490c329c7 Mon Sep 17 00:00:00 2001 From: Michael Zhu Date: Mon, 4 Dec 2023 13:27:44 -0500 Subject: [PATCH] Consistently pass through random_tape --- jolt-core/src/benches/bench.rs | 5 +++-- jolt-core/src/jolt/vm/instruction_lookups.rs | 9 ++++----- jolt-core/src/jolt/vm/mod.rs | 7 ++++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/jolt-core/src/benches/bench.rs b/jolt-core/src/benches/bench.rs index 7503ba60c..69f368580 100644 --- a/jolt-core/src/benches/bench.rs +++ b/jolt-core/src/benches/bench.rs @@ -18,7 +18,7 @@ use crate::jolt::vm::instruction_lookups::InstructionLookupsProof; use crate::jolt::vm::rv32i_vm::{RV32IJoltVM, RV32I}; use crate::jolt::vm::Jolt; use crate::lasso::surge::Surge; -use crate::utils::math::Math; +use crate::utils::{math::Math, random::RandomTape}; use crate::{jolt::instruction::xor::XORInstruction, utils::gen_random_point}; use ark_curve25519::{EdwardsProjective, Fr}; use ark_std::{log2, test_rng}; @@ -145,8 +145,9 @@ fn rv32i_lookup_benchmarks() -> Vec<(tracing::Span, Box)> { let r: Vec = gen_random_point::(ops.len().log_2()); let mut prover_transcript = Transcript::new(b"example"); + let mut random_tape = RandomTape::new(b"test_tape"); let proof: InstructionLookupsProof = - RV32IJoltVM::prove_instruction_lookups(ops, r.clone(), &mut prover_transcript); + RV32IJoltVM::prove_instruction_lookups(ops, r.clone(), &mut prover_transcript, &mut random_tape); let mut verifier_transcript = Transcript::new(b"example"); assert!(RV32IJoltVM::verify_instruction_lookups(proof, r, &mut verifier_transcript).is_ok()); }); diff --git a/jolt-core/src/jolt/vm/instruction_lookups.rs b/jolt-core/src/jolt/vm/instruction_lookups.rs index c410a032d..6bd8a59bc 100644 --- a/jolt-core/src/jolt/vm/instruction_lookups.rs +++ b/jolt-core/src/jolt/vm/instruction_lookups.rs @@ -17,7 +17,7 @@ use crate::{ dense_mlpoly::{DensePolynomial, PolyCommitmentGens}, eq_poly::EqPolynomial, identity_poly::IdentityPolynomial, - structured_poly::{StructuredOpeningProof, BatchablePolynomials}, + structured_poly::{BatchablePolynomials, StructuredOpeningProof}, unipoly::{CompressedUniPoly, UniPoly}, }, subprotocols::{ @@ -751,6 +751,7 @@ where &self, r: Vec, transcript: &mut Transcript, + random_tape: &mut RandomTape, ) -> InstructionLookupsProof { >::append_protocol_name(transcript, Self::protocol_name()); let polynomials = self.polynomialize(); @@ -785,8 +786,6 @@ where transcript, ); - let mut random_tape = RandomTape::new(b"proof"); - // Create a single opening proof for the flag_evals and memory_evals let sumcheck_openings = PrimarySumcheckOpenings::prove_openings( &batched_polys, @@ -794,7 +793,7 @@ where &r_primary_sumcheck, (E_evals, flag_evals), transcript, - &mut random_tape, + random_tape, ); let primary_sumcheck = PrimarySumcheck { @@ -809,7 +808,7 @@ where &batched_polys, &commitment, transcript, - &mut random_tape, + random_tape, ); InstructionLookupsProof { diff --git a/jolt-core/src/jolt/vm/mod.rs b/jolt-core/src/jolt/vm/mod.rs index d06c0a125..3e72f8327 100644 --- a/jolt-core/src/jolt/vm/mod.rs +++ b/jolt-core/src/jolt/vm/mod.rs @@ -51,10 +51,11 @@ pub trait Jolt, const C: usize, co ops: Vec, r: Vec, transcript: &mut Transcript, + random_tape: &mut RandomTape, ) -> InstructionLookupsProof { let instruction_lookups = InstructionLookups::::new(ops); - instruction_lookups.prove_lookups(r, transcript) + instruction_lookups.prove_lookups(r, transcript, random_tape) } fn verify_instruction_lookups( @@ -91,6 +92,7 @@ pub trait Jolt, const C: usize, co memory_trace: Vec, memory_size: usize, transcript: &mut Transcript, + random_tape: &mut RandomTape, ) -> ( MemoryCheckingProof< G, @@ -110,13 +112,12 @@ pub trait Jolt, const C: usize, co let batched_polys = memory.batch(); let commitments: MemoryCommitment = ReadWriteMemory::commit(&batched_polys); - let mut random_tape = RandomTape::new(b"proof"); let memory_checking_proof = memory.prove_memory_checking( &memory, &batched_polys, &commitments, transcript, - &mut random_tape, + random_tape, ); let timestamp_validity_lookups: Vec = read_timestamps