Skip to content

Commit

Permalink
refactor: Optimize tau generation with PowPolynomial in snark.rs (#343)
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 #155
  • Loading branch information
huitseeker authored Feb 24, 2024
1 parent 74792f9 commit 4b47563
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

1 comment on commit 4b47563

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmarks

Table of Contents

Overview

This benchmark report shows the Arecibo GPU benchmarks.
NVIDIA L4
Intel(R) Xeon(R) CPU @ 2.20GHz
32 vCPUs
125 GB RAM
Workflow run: https://github.com/lurk-lab/arecibo/actions/runs/8030903608

Benchmark Results

RecursiveSNARK-NIVC-2

ref=74792f9 ref=4b47563
Prove-NumCons-6540 45.12 ms (✅ 1.00x) 45.81 ms (✅ 1.02x slower)
Verify-NumCons-6540 34.86 ms (✅ 1.00x) 34.78 ms (✅ 1.00x faster)
Prove-NumCons-1028888 321.17 ms (✅ 1.00x) 322.59 ms (✅ 1.00x slower)
Verify-NumCons-1028888 251.79 ms (✅ 1.00x) 249.58 ms (✅ 1.01x faster)

CompressedSNARK-NIVC-Commitments-2

ref=74792f9 ref=4b47563
Prove-NumCons-6540 10.78 s (✅ 1.00x) 10.66 s (✅ 1.01x faster)
Verify-NumCons-6540 51.09 ms (✅ 1.00x) 51.10 ms (✅ 1.00x slower)
Prove-NumCons-1028888 52.70 s (✅ 1.00x) 53.26 s (✅ 1.01x slower)
Verify-NumCons-1028888 51.58 ms (✅ 1.00x) 51.02 ms (✅ 1.01x faster)

Made with criterion-table

Please sign in to comment.