From 0de3e7de202e0b7f1654f85839fd656af8de8550 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Garillot?= Date: Sat, 19 Aug 2023 18:07:49 -0400 Subject: [PATCH] feat: Refactor nova.rs for new Public Parameters tuned to a SNARK - Updated code comments in `src/proof/nova.rs` to clearly state that `SS1` and `SS2` do not utilize computational commitments - Enhanced `public_params` function with two new parameters: `commitment_size_hint1` and `commitment_size_hint2`, aligning the setup of `nova::PublicParams` with https://github.com/lurk-lab/arecibo/pull/5 --- src/proof/nova.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/proof/nova.rs b/src/proof/nova.rs index 231b1cf8e1..d654e5d556 100644 --- a/src/proof/nova.rs +++ b/src/proof/nova.rs @@ -14,7 +14,7 @@ use nova::{ traits::{ circuit::{StepCircuit, TrivialTestCircuit}, commitment::CommitmentEngineTrait, - Group, + Group, snark::RelaxedR1CSSNARKTrait, }, CompressedSNARK, ProverKey, RecursiveSNARK, VerifierKey, }; @@ -108,8 +108,12 @@ pub type EE1 = nova::provider::ipa_pc::EvaluationEngine>; pub type EE2 = nova::provider::ipa_pc::EvaluationEngine>; /// Type alias for the Relaxed R1CS Spartan SNARK using G1 group elements, EE1. +// NOTE: this is not a SNARK that uses computational commitments, +// that SNARK would be found at nova::spartan::ppsnark::RelaxedR1CSSNARK, pub type SS1 = nova::spartan::snark::RelaxedR1CSSNARK, EE1>; /// Type alias for the Relaxed R1CS Spartan SNARK using G2 group elements, EE2. +// NOTE: this is not a SNARK that uses computational commitments, +// that SNARK would be found at nova::spartan::ppsnark::RelaxedR1CSSNARK, pub type SS2 = nova::spartan::snark::RelaxedR1CSSNARK, EE2>; /// Type alias for a MultiFrame with S1 field elements. @@ -188,7 +192,10 @@ where { let (circuit_primary, circuit_secondary) = C1::circuits(num_iters_per_step, lang); - let pp = nova::PublicParams::setup(&circuit_primary, &circuit_secondary); + let commitment_size_hint1 = as RelaxedR1CSSNARKTrait>>::commitment_key_floor(); + let commitment_size_hint2 = as RelaxedR1CSSNARKTrait>>::commitment_key_floor(); + + let pp = nova::PublicParams::setup(&circuit_primary, &circuit_secondary, Some(commitment_size_hint1),Some(commitment_size_hint2)); let (pk, vk) = CompressedSNARK::setup(&pp).unwrap(); PublicParams { pp, pk, vk } }