Skip to content

Commit

Permalink
feat: Refactor nova.rs for new Public Parameters tuned to a SNARK
Browse files Browse the repository at this point in the history
- Updated code comments in `src/proof/nova.rs` to clearly state that `SS1<F>` and `SS2<F>` 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 lurk-lang/arecibo#5
  • Loading branch information
huitseeker committed Aug 19, 2023
1 parent 58105dc commit fbabced
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/proof/nova.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use nova::{
traits::{
circuit::{StepCircuit, TrivialTestCircuit},
commitment::CommitmentEngineTrait,
snark::RelaxedR1CSSNARKTrait,
Group,
},
CompressedSNARK, ProverKey, RecursiveSNARK, VerifierKey,
Expand Down Expand Up @@ -108,8 +109,12 @@ pub type EE1<F> = nova::provider::ipa_pc::EvaluationEngine<G1<F>>;
pub type EE2<F> = nova::provider::ipa_pc::EvaluationEngine<G2<F>>;

/// 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<F> = nova::spartan::snark::RelaxedR1CSSNARK<G1<F>, EE1<F>>;
/// 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<F> = nova::spartan::snark::RelaxedR1CSSNARK<G2<F>, EE2<F>>;

/// Type alias for a MultiFrame with S1 field elements.
Expand Down Expand Up @@ -188,7 +193,15 @@ 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 = <SS1<F> as RelaxedR1CSSNARKTrait<G1<F>>>::commitment_key_floor();
let commitment_size_hint2 = <SS2<F> as RelaxedR1CSSNARKTrait<G2<F>>>::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 }
}
Expand Down

0 comments on commit fbabced

Please sign in to comment.