Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Refactor nova.rs for new Public Parameters tuned to a SNARK #626

Merged
merged 1 commit into from
Aug 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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<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
commit fbabced1887520d2a524dc17cdf85edd4fd6014d
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