Skip to content

Commit

Permalink
chore: move shared pcs functionality to internal library in solidity …
Browse files Browse the repository at this point in the history
…and small refactorings in sumcheck (#11230)

* functionality that is shared in PCS between the ZK and non-ZK contract
has been moved to a separate internal library.
* simplified ZK sumcheck and pcs logic
  • Loading branch information
maramihali authored Jan 16, 2025
1 parent 642bce6 commit 507ae9d
Show file tree
Hide file tree
Showing 26 changed files with 395 additions and 460 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ std::vector<typename GeminiProver_<Curve>::Claim> GeminiProver_<Curve>::prove(
bool has_zk)

{
size_t log_n = numeric::get_msb(static_cast<uint32_t>(circuit_size));
size_t n = 1 << log_n;
const size_t log_n = numeric::get_msb(static_cast<uint32_t>(circuit_size));
const size_t n = 1 << log_n;

// Compute batched polynomials
Polynomial batched_unshifted(n);
Expand All @@ -66,10 +66,8 @@ std::vector<typename GeminiProver_<Curve>::Claim> GeminiProver_<Curve>::prove(
transcript->send_to_verifier("Gemini:masking_poly_comm", commitment_key->commit(batched_unshifted));
// In the provers, the size of multilinear_challenge is CONST_PROOF_SIZE_LOG_N, but we need to evaluate the
// hiding polynomial as multilinear in log_n variables
std::vector<Fr> multilinear_challenge_resized(multilinear_challenge.begin(), multilinear_challenge.end());
multilinear_challenge_resized.resize(log_n);
transcript->send_to_verifier("Gemini:masking_poly_eval",
batched_unshifted.evaluate_mle(multilinear_challenge_resized));
batched_unshifted.evaluate_mle(multilinear_challenge.subspan(0, log_n)));
}

// Get the batching challenge
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ template <typename Curve> class ShpleminiVerifier_ {
if (has_zk) {
hiding_polynomial_commitment =
transcript->template receive_from_prover<Commitment>("Gemini:masking_poly_comm");
batched_evaluation += transcript->template receive_from_prover<Fr>("Gemini:masking_poly_eval");
batched_evaluation = transcript->template receive_from_prover<Fr>("Gemini:masking_poly_eval");
}

// Get the challenge ρ to batch commitments to multilinear polynomials and their shifts
Expand Down Expand Up @@ -399,7 +399,7 @@ template <typename Curve> class ShpleminiVerifier_ {
Fr current_batching_challenge = Fr(1);

if (has_zk) {
// ρ⁰ is used to batch the hiding polynomial
// ρ⁰ is used to batch the hiding polynomial which has already been added to the commitments vector
current_batching_challenge *= multivariate_batching_challenge;
}

Expand Down Expand Up @@ -635,12 +635,12 @@ template <typename Curve> class ShpleminiVerifier_ {
// need to keep track of the contribution to the constant term
Fr& constant_term = scalars.back();

// add Libra commitments to the vector of commitments; compute corresponding scalars and the correction to
// the constant term
// add Libra commitments to the vector of commitments
for (size_t idx = 0; idx < libra_commitments.size(); idx++) {
commitments.push_back(libra_commitments[idx]);
}

// compute corresponding scalars and the correction to the constant term
std::array<Fr, NUM_LIBRA_EVALUATIONS> denominators;
std::array<Fr, NUM_LIBRA_EVALUATIONS> batching_scalars;
// compute Shplonk denominators and invert them
Expand Down
Loading

0 comments on commit 507ae9d

Please sign in to comment.