From 4b47563666f6bfee43f210a0f73a628831d000e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Garillot?= <4142+huitseeker@users.noreply.github.com> Date: Sat, 24 Feb 2024 08:27:01 -0500 Subject: [PATCH] refactor: Optimize tau generation with PowPolynomial in snark.rs (#343) - Imported and implemented `PowPolynomial` into `src/spartan/snark.rs`, - Simplified and optimized `tau` variable generation using `PowPolynomial`, decreasing the transcript use, - Adjusted `tau` variable generation method in `prove` and `verify` functions Fixes #155 --- src/spartan/snark.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/spartan/snark.rs b/src/spartan/snark.rs index b22894b4a..4dc227561 100644 --- a/src/spartan/snark.rs +++ b/src/spartan/snark.rs @@ -10,7 +10,11 @@ use crate::{ r1cs::{R1CSShape, RelaxedR1CSInstance, RelaxedR1CSWitness, SparseMatrix}, spartan::{ compute_eval_table_sparse, - polys::{eq::EqPolynomial, multilinear::MultilinearPolynomial, multilinear::SparsePolynomial}, + polys::{ + eq::EqPolynomial, + multilinear::{MultilinearPolynomial, SparsePolynomial}, + power::PowPolynomial, + }, powers, sumcheck::SumcheckProof, PolyEvalInstance, PolyEvalWitness, @@ -141,9 +145,7 @@ impl> RelaxedR1CSSNARKTrait for Relax ); // outer sum-check - let tau = (0..num_rounds_x) - .map(|_i| transcript.squeeze(b"t")) - .collect::, NovaError>>()?; + let tau: EqPolynomial<_> = PowPolynomial::new(&transcript.squeeze(b"t")?, num_rounds_x).into(); let mut poly_tau = MultilinearPolynomial::new(tau.evals()); let (mut poly_Az, mut poly_Bz, poly_Cz, mut poly_uCz_E) = { @@ -284,9 +286,7 @@ impl> RelaxedR1CSSNARKTrait for Relax ); // outer sum-check - let tau = (0..num_rounds_x) - .map(|_i| transcript.squeeze(b"t")) - .collect::, NovaError>>()?; + let tau: EqPolynomial<_> = PowPolynomial::new(&transcript.squeeze(b"t")?, num_rounds_x).into(); let (claim_outer_final, r_x) = self