Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions jolt-core/src/poly/opening_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ pub enum OpeningId {
TrustedAdvice,
}

pub type Openings<F> = BTreeMap<OpeningId, (OpeningPoint<BIG_ENDIAN, F>, F)>;
/// (point, claim)
pub type Opening<F> = (OpeningPoint<BIG_ENDIAN, F>, F);
pub type Openings<F> = BTreeMap<OpeningId, Opening<F>>;

#[derive(Clone, Debug, Allocative)]
pub struct SharedDensePolynomial<F: JoltField> {
Expand Down Expand Up @@ -391,15 +393,18 @@ impl<F, T: Transcript> SumcheckInstanceProver<F, T> for OpeningProofReductionSum
where
F: JoltField,
{
/// Returns the maximum degree of the sumcheck polynomial.
fn degree(&self) -> usize {
OPENING_SUMCHECK_DEGREE
}

/// Returns the number of rounds/variables in this sumcheck instance.
fn num_rounds(&self) -> usize {
self.opening_point.len()
}

fn input_claim(&self, _accumulator: &ProverOpeningAccumulator<F>) -> F {
/// Returns the initial claim of this sumcheck instance.
fn input_claim(&self, _: &ProverOpeningAccumulator<F>) -> F {
self.input_claim
}

Expand Down Expand Up @@ -464,15 +469,18 @@ impl<F: JoltField> OpeningProofReductionSumcheckVerifier<F> {
impl<F: JoltField, T: Transcript> SumcheckInstanceVerifier<F, T>
for OpeningProofReductionSumcheckVerifier<F>
{
/// Returns the maximum degree of the sumcheck polynomial.
fn degree(&self) -> usize {
OPENING_SUMCHECK_DEGREE
}

/// Returns the number of rounds/variables in this sumcheck instance.
fn num_rounds(&self) -> usize {
self.opening_point.len()
}

fn input_claim(&self, _accumulator: &VerifierOpeningAccumulator<F>) -> F {
/// Returns the initial claim of this sumcheck instance.
fn input_claim(&self, _: &VerifierOpeningAccumulator<F>) -> F {
self.input_claim
}

Expand Down
11 changes: 3 additions & 8 deletions jolt-core/src/poly/unipoly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,8 @@ impl<F: JoltField> UniPoly<F> {
/// - (ok, value) where `ok` is true iff the domain-sum equals `claim`, and `value` = s(x).
pub fn check_sum_evals_and_set_new_claim<const N: usize, const OUT_LEN: usize>(
&self,
claim: &F,
x: &F::Challenge,
) -> (bool, F) {
claim: F,
) -> bool {
// Relaxed: compute Σ_{t in symmetric N-window} s(t) via i128 power sums up to deg(s)
debug_assert_eq!(self.degree() + 1, OUT_LEN);
let power_sums = LagrangeHelper::power_sums::<N, OUT_LEN>();
Expand All @@ -339,11 +338,7 @@ impl<F: JoltField> UniPoly<F> {
for (j, coeff) in self.coeffs.iter().enumerate() {
sum += coeff.mul_i128(power_sums[j]);
}
let ok = sum == *claim;

// Horner evaluation at x
let value = self.evaluate(x);
(ok, value)
sum == claim
}
}

Expand Down
132 changes: 53 additions & 79 deletions jolt-core/src/subprotocols/booleanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,60 @@ use crate::{
unipoly::UniPoly,
},
subprotocols::{
sumcheck_prover::SumcheckInstanceProver, sumcheck_verifier::SumcheckInstanceVerifier,
sumcheck_prover::SumcheckInstanceProver,
sumcheck_verifier::{SumcheckInstanceParams, SumcheckInstanceVerifier},
},
transcripts::Transcript,
utils::{expanding_table::ExpandingTable, thread::drop_in_background_thread},
zkvm::witness::{CommittedPolynomial, VirtualPolynomial},
zkvm::witness::CommittedPolynomial,
};

/// Degree bound of the sumcheck round polynomials in [`BooleanitySumcheckVerifier`].
const DEGREE_BOUND: usize = 3;

pub struct BooleanitySumcheckParams<F: JoltField> {
/// Number of address chunks
pub d: usize,
/// Log of chunk size
pub log_k_chunk: usize,
/// Log of trace length
pub log_t: usize,
/// Batching challenges
pub gammas: Vec<F::Challenge>,
/// Address binding point
pub r_address: Vec<F::Challenge>,
/// Cycle binding point
pub r_cycle: Vec<F::Challenge>,
/// Polynomial types for opening accumulator
pub polynomial_types: Vec<CommittedPolynomial>,
/// Sumcheck ID for opening accumulator
pub sumcheck_id: SumcheckId,
}

impl<F: JoltField> SumcheckInstanceParams<F> for BooleanitySumcheckParams<F> {
fn degree(&self) -> usize {
DEGREE_BOUND
}

fn num_rounds(&self) -> usize {
self.log_k_chunk + self.log_t
}

fn input_claim(&self, _accumulator: &dyn OpeningAccumulator<F>) -> F {
F::zero()
}

fn normalize_opening_point(
&self,
sumcheck_challenges: &[F::Challenge],
) -> OpeningPoint<BIG_ENDIAN, F> {
let mut opening_point = sumcheck_challenges.to_vec();
opening_point[..self.log_k_chunk].reverse();
opening_point[self.log_k_chunk..].reverse();
opening_point.into()
}
}

/// Unified Booleanity Sumcheck implementation for RAM, Bytecode, and Instruction lookups
#[derive(Allocative)]
pub struct BooleanitySumcheckProver<F: JoltField> {
Expand Down Expand Up @@ -175,16 +219,8 @@ impl<F: JoltField> BooleanitySumcheckProver<F> {
}

impl<F: JoltField, T: Transcript> SumcheckInstanceProver<F, T> for BooleanitySumcheckProver<F> {
fn degree(&self) -> usize {
DEGREE_BOUND
}

fn num_rounds(&self) -> usize {
self.params.num_rounds()
}

fn input_claim(&self, _accumulator: &ProverOpeningAccumulator<F>) -> F {
F::zero()
fn get_params(&self) -> Box<&dyn SumcheckInstanceParams<F>> {
Box::new(&self.params)
}

#[tracing::instrument(skip_all, name = "BooleanitySumcheckProver::compute_message")]
Expand Down Expand Up @@ -238,7 +274,7 @@ impl<F: JoltField, T: Transcript> SumcheckInstanceProver<F, T> for BooleanitySum
transcript: &mut T,
sumcheck_challenges: &[F::Challenge],
) {
let opening_point = self.params.get_opening_point(sumcheck_challenges);
let opening_point = self.params.normalize_opening_point(sumcheck_challenges);
let claims: Vec<F> = self.H.iter().map(|H| H.final_sumcheck_claim()).collect();
accumulator.append_sparse(
transcript,
Expand Down Expand Up @@ -267,16 +303,8 @@ impl<F: JoltField> BooleanitySumcheckVerifier<F> {
}

impl<F: JoltField, T: Transcript> SumcheckInstanceVerifier<F, T> for BooleanitySumcheckVerifier<F> {
fn degree(&self) -> usize {
DEGREE_BOUND
}

fn num_rounds(&self) -> usize {
self.params.num_rounds()
}

fn input_claim(&self, _accumulator: &VerifierOpeningAccumulator<F>) -> F {
F::zero()
fn get_params(&self) -> Box<&dyn SumcheckInstanceParams<F>> {
Box::new(&self.params)
}

fn expected_output_claim(
Expand All @@ -295,15 +323,13 @@ impl<F: JoltField, T: Transcript> SumcheckInstanceVerifier<F, T> for BooleanityS
})
.collect::<Vec<F>>();

let r_cycle = self.params.get_r_cycle(accumulator);

let combined_r: Vec<F::Challenge> = self
.params
.r_address
.iter()
.cloned()
.rev()
.chain(r_cycle.iter().cloned().rev())
.chain(self.params.r_cycle.iter().cloned().rev())
.collect();

EqPolynomial::<F>::mle(sumcheck_challenges, &combined_r)
Expand All @@ -318,7 +344,7 @@ impl<F: JoltField, T: Transcript> SumcheckInstanceVerifier<F, T> for BooleanityS
transcript: &mut T,
sumcheck_challenges: &[F::Challenge],
) {
let opening_point = self.params.get_opening_point(sumcheck_challenges);
let opening_point = self.params.normalize_opening_point(sumcheck_challenges);
accumulator.append_sparse(
transcript,
self.params.polynomial_types.clone(),
Expand All @@ -327,55 +353,3 @@ impl<F: JoltField, T: Transcript> SumcheckInstanceVerifier<F, T> for BooleanityS
);
}
}

pub struct BooleanitySumcheckParams<F: JoltField> {
/// Number of address chunks
pub d: usize,
/// Log of chunk size
pub log_k_chunk: usize,
/// Log of trace length
pub log_t: usize,
/// Batching challenges
pub gammas: Vec<F::Challenge>,
/// Address binding point
pub r_address: Vec<F::Challenge>,
/// Cycle binding point
pub r_cycle: Vec<F::Challenge>,
/// Polynomial types for opening accumulator
pub polynomial_types: Vec<CommittedPolynomial>,
/// Sumcheck ID for opening accumulator
pub sumcheck_id: SumcheckId,
/// Optional virtual polynomial for r_cycle
pub virtual_poly: Option<VirtualPolynomial>,
}

impl<F: JoltField> BooleanitySumcheckParams<F> {
pub fn num_rounds(&self) -> usize {
self.log_k_chunk + self.log_t
}

fn get_r_cycle(&self, accumulator: &dyn OpeningAccumulator<F>) -> Vec<F::Challenge> {
if !self.r_cycle.is_empty() {
self.r_cycle.clone()
} else {
let virtual_poly = self
.virtual_poly
.expect("virtual_poly must be set when r_cycle is empty");
accumulator
.get_virtual_polynomial_opening(virtual_poly, SumcheckId::SpartanOuter)
.0
.r
.clone()
}
}

fn get_opening_point(
&self,
sumcheck_challenges: &[F::Challenge],
) -> OpeningPoint<BIG_ENDIAN, F> {
let mut opening_point = sumcheck_challenges.to_vec();
opening_point[..self.log_k_chunk].reverse();
opening_point[self.log_k_chunk..].reverse();
opening_point.into()
}
}
Loading
Loading