Skip to content

Commit

Permalink
refactor: Optimize tau generation with PowPolynomial in snark.rs
Browse files Browse the repository at this point in the history
- 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 lurk-lang#155
  • Loading branch information
huitseeker committed Feb 24, 2024
1 parent 74792f9 commit f2c1d15
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/spartan/snark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -141,9 +145,7 @@ impl<E: Engine, EE: EvaluationEngineTrait<E>> RelaxedR1CSSNARKTrait<E> for Relax
);

// outer sum-check
let tau = (0..num_rounds_x)
.map(|_i| transcript.squeeze(b"t"))
.collect::<Result<EqPolynomial<_>, 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) = {
Expand Down Expand Up @@ -284,9 +286,7 @@ impl<E: Engine, EE: EvaluationEngineTrait<E>> RelaxedR1CSSNARKTrait<E> for Relax
);

// outer sum-check
let tau = (0..num_rounds_x)
.map(|_i| transcript.squeeze(b"t"))
.collect::<Result<EqPolynomial<_>, NovaError>>()?;
let tau: EqPolynomial<_> = PowPolynomial::new(&transcript.squeeze(b"t")?, num_rounds_x).into();

let (claim_outer_final, r_x) =
self
Expand Down

0 comments on commit f2c1d15

Please sign in to comment.