Browse Source

fix sumcheck verifier for when poly=0 (#126)

Co-authored-by: NiDimi <moonkace24@gmail.com>
update-nifs-interface
arnaucube 4 months ago
committed by GitHub
parent
commit
bb44a3ad95
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 12 deletions
  1. +21
    -11
      folding-schemes/src/utils/espresso/sum_check/mod.rs
  2. +5
    -1
      folding-schemes/src/utils/espresso/sum_check/verifier.rs

+ 21
- 11
folding-schemes/src/utils/espresso/sum_check/mod.rs

@ -219,29 +219,39 @@ pub mod tests {
#[test]
pub fn sumcheck_poseidon() {
let n_vars = 5;
let mut rng = test_rng();
let poly_mle = DenseMultilinearExtension::rand(5, &mut rng);
let poly_mle = DenseMultilinearExtension::rand(n_vars, &mut rng);
let virtual_poly = VirtualPolynomial::new_from_mle(&Arc::new(poly_mle), Fr::ONE);
sumcheck_poseidon_opt(virtual_poly);
// test with zero poly
let poly_mle = DenseMultilinearExtension::from_evaluations_vec(
n_vars,
vec![Fr::ZERO; 2u32.pow(n_vars as u32) as usize],
);
let virtual_poly = VirtualPolynomial::new_from_mle(&Arc::new(poly_mle), Fr::ONE);
sumcheck_poseidon_opt(virtual_poly);
}
fn sumcheck_poseidon_opt(virtual_poly: VirtualPolynomial<Fr>) {
let poseidon_config = poseidon_canonical_config::<Fr>();
// sum-check prove
let mut poseidon_transcript_prove: PoseidonSponge<Fr> =
PoseidonSponge::<Fr>::new(&poseidon_config);
let sum_check = IOPSumCheck::<Fr, PoseidonSponge<Fr>>::prove(
&virtual_poly,
&mut poseidon_transcript_prove,
)
.unwrap();
let mut transcript_p: PoseidonSponge<Fr> = PoseidonSponge::<Fr>::new(&poseidon_config);
let sum_check =
IOPSumCheck::<Fr, PoseidonSponge<Fr>>::prove(&virtual_poly, &mut transcript_p).unwrap();
// sum-check verify
let claimed_sum = IOPSumCheck::<Fr, PoseidonSponge<Fr>>::extract_sum(&sum_check);
let mut poseidon_transcript_verify: PoseidonSponge<Fr> =
PoseidonSponge::<Fr>::new(&poseidon_config);
let mut transcript_v: PoseidonSponge<Fr> = PoseidonSponge::<Fr>::new(&poseidon_config);
let res_verify = IOPSumCheck::<Fr, PoseidonSponge<Fr>>::verify(
claimed_sum,
&sum_check,
&virtual_poly.aux_info,
&mut poseidon_transcript_verify,
&mut transcript_v,
);
assert!(res_verify.is_ok());

+ 5
- 1
folding-schemes/src/utils/espresso/sum_check/verifier.rs

@ -137,7 +137,11 @@ impl SumCheckVerifier for IOPVerifierState {
{
let poly = DensePolynomial::from_coefficients_slice(coeffs);
let eval_at_one: F = poly.iter().sum();
let eval_at_zero: F = poly.coeffs[0];
let eval_at_zero: F = if poly.coeffs.is_empty() {
F::zero()
} else {
poly.coeffs[0]
};
let eval = eval_at_one + eval_at_zero;
// the deferred check during the interactive phase:

Loading…
Cancel
Save