Skip to content

Commit

Permalink
refactor: add make_sumcheck_prover_state as a wrapper around `make_…
Browse files Browse the repository at this point in the history
…sumcheck_polynomial` and `ProverState::create`.

Note: this will eventually be refactored to compute the `ProverState` directly
  • Loading branch information
JayWhite2357 committed Dec 10, 2024
1 parent 117c91f commit 97b8c03
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
use super::{CompositePolynomialBuilder, SumcheckRandomScalars, SumcheckSubpolynomial};
use crate::base::{polynomial::CompositePolynomial, scalar::Scalar};
use crate::{
base::{polynomial::CompositePolynomial, scalar::Scalar},
proof_primitive::sumcheck::ProverState,
};

pub fn make_sumcheck_prover_state<S: Scalar>(
subpolynomials: &[SumcheckSubpolynomial<'_, S>],
num_vars: usize,
scalars: &SumcheckRandomScalars<S>,
) -> ProverState<S> {
ProverState::create(&make_sumcheck_polynomial(subpolynomials, num_vars, scalars))
}

/// Given random multipliers, construct an aggregatated sumcheck polynomial from all
/// the individual subpolynomials.
#[tracing::instrument(name = "proof::make_sumcheck_polynomial", level = "debug", skip_all)]
pub fn make_sumcheck_polynomial<S: Scalar>(
fn make_sumcheck_polynomial<S: Scalar>(
subpolynomials: &[SumcheckSubpolynomial<'_, S>],
num_vars: usize,
scalars: &SumcheckRandomScalars<S>,
Expand Down
2 changes: 1 addition & 1 deletion crates/proof-of-sql/src/sql/proof/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ pub(crate) use first_round_builder::FirstRoundBuilder;
#[cfg(all(test, feature = "arrow"))]
mod provable_query_result_test;

mod make_sumcheck_polynomial;
mod make_sumcheck_state;
19 changes: 7 additions & 12 deletions crates/proof-of-sql/src/sql/proof/query_proof.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::{
make_sumcheck_polynomial::make_sumcheck_polynomial, CountBuilder, FinalRoundBuilder,
ProofCounts, ProofPlan, QueryResult, SumcheckMleEvaluations, SumcheckRandomScalars,
VerificationBuilder,
make_sumcheck_state::make_sumcheck_prover_state, CountBuilder, FinalRoundBuilder,
FirstRoundBuilder, ProofCounts, ProofPlan, QueryData, QueryResult, SumcheckMleEvaluations,
SumcheckRandomScalars, VerificationBuilder,
};
use crate::{
base::{
Expand All @@ -17,8 +17,7 @@ use crate::{
proof::{Keccak256Transcript, ProofError, Transcript},
scalar::Scalar,
},
proof_primitive::sumcheck::{ProverState, SumcheckProof},
sql::proof::{FirstRoundBuilder, QueryData},
proof_primitive::sumcheck::SumcheckProof,
};
use alloc::{string::String, vec, vec::Vec};
use bumpalo::Bump;
Expand Down Expand Up @@ -157,19 +156,15 @@ impl<CP: CommitmentEvaluationProof> QueryProof<CP> {
core::iter::repeat_with(|| transcript.scalar_challenge_as_be())
.take(num_random_scalars)
.collect();
let poly = make_sumcheck_polynomial(
let state = make_sumcheck_prover_state(
builder.sumcheck_subpolynomials(),
num_sumcheck_variables,
&SumcheckRandomScalars::new(&random_scalars, range_length, num_sumcheck_variables),
);

// create the sumcheck proof -- this is the main part of proving a query
let mut evaluation_point = vec![Zero::zero(); poly.num_variables];
let sumcheck_proof = SumcheckProof::create(
&mut transcript,
&mut evaluation_point,
ProverState::create(&poly),
);
let mut evaluation_point = vec![Zero::zero(); state.num_vars];
let sumcheck_proof = SumcheckProof::create(&mut transcript, &mut evaluation_point, state);

// evaluate the MLEs used in sumcheck except for the result columns
let mut evaluation_vec = vec![Zero::zero(); range_length];
Expand Down

0 comments on commit 97b8c03

Please sign in to comment.