Skip to content

Commit

Permalink
feat: Implement Clone trait for various structs (#364)
Browse files Browse the repository at this point in the history
- Added `Clone` trait derivation to enhance cloning capabilities within the codebase.
- Improved duplication of `CompressedSNARK` and `NIFS` structures by integrating `Clone` trait.
- Optimized SNARK computations and funcs handling by cloning `CompressedSNARK` structure.

This is motivated by a companion update to Lurk, where the compression mechanism requires returning a uniform type upon calling `.compress()` on a proof that can be recursive or compressed.
  • Loading branch information
huitseeker authored Mar 19, 2024
1 parent b4bfe89 commit 09eb1eb
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ where
}

/// A SNARK that proves the knowledge of a valid `RecursiveSNARK`
#[derive(Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(bound = "")]
pub struct CompressedSNARK<E1, S1, S2>
where
Expand Down
2 changes: 1 addition & 1 deletion src/nifs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use serde::{Deserialize, Serialize};

/// A SNARK that holds the proof of a step of an incremental computation
#[allow(clippy::upper_case_acronyms)]
#[derive(Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(bound = "")]
pub struct NIFS<E: Engine> {
pub(crate) comm_T: CompressedCommitment<E>,
Expand Down
2 changes: 1 addition & 1 deletion src/spartan/batched.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use crate::{
/// A succinct proof of knowledge of a witness to a batch of relaxed R1CS instances
/// The proof is produced using Spartan's combination of the sum-check and
/// the commitment to a vector viewed as a polynomial commitment
#[derive(Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(bound = "")]
pub struct BatchedRelaxedR1CSSNARK<E: Engine, EE: EvaluationEngineTrait<E>> {
sc_proof_outer: SumcheckProof<E>,
Expand Down
2 changes: 1 addition & 1 deletion src/spartan/batched_ppsnark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl<E: Engine, EE: EvaluationEngineTrait<E>> DigestHelperTrait<E> for VerifierK
/// A succinct proof of knowledge of a witness to a relaxed R1CS instance
/// The proof is produced using Spartan's combination of the sum-check and
/// the commitment to a vector viewed as a polynomial commitment
#[derive(Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(bound = "")]
pub struct BatchedRelaxedR1CSSNARK<E: Engine, EE: EvaluationEngineTrait<E>> {
// commitment to oracles: the first three are for Az, Bz, Cz,
Expand Down
2 changes: 1 addition & 1 deletion src/supernova/snark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ where
}

/// A SNARK that proves the knowledge of a valid `RecursiveSNARK`
#[derive(Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(bound = "")]
pub struct CompressedSNARK<E1, S1, S2>
where
Expand Down

1 comment on commit 09eb1eb

@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/8338706844

Benchmark Results

RecursiveSNARK-NIVC-2

ref=b4bfe89 ref=09eb1eb
Prove-NumCons-6540 47.55 ms (✅ 1.00x) 47.39 ms (✅ 1.00x faster)
Verify-NumCons-6540 35.13 ms (✅ 1.00x) 34.84 ms (✅ 1.01x faster)
Prove-NumCons-1028888 346.59 ms (✅ 1.00x) 344.64 ms (✅ 1.01x faster)
Verify-NumCons-1028888 259.46 ms (✅ 1.00x) 256.45 ms (✅ 1.01x faster)

CompressedSNARK-NIVC-Commitments-2

ref=b4bfe89 ref=09eb1eb
Prove-NumCons-6540 13.44 s (✅ 1.00x) 13.51 s (✅ 1.01x slower)
Verify-NumCons-6540 63.15 ms (✅ 1.00x) 62.62 ms (✅ 1.01x faster)
Prove-NumCons-1028888 58.26 s (✅ 1.00x) 58.69 s (✅ 1.01x slower)
Verify-NumCons-1028888 62.36 ms (✅ 1.00x) 62.86 ms (✅ 1.01x slower)

Made with criterion-table

Please sign in to comment.