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

[wip] Reorganize public param module #1087

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .clippy.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type-complexity-threshold = 999
type-complexity-threshold = 1200
too-many-arguments-threshold = 20
disallowed-methods = [
# we use strict naming for pasta fields
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ clap = "4.3.17"
ff = "0.13"
metrics = "0.22.0"
neptune = { git = "https://github.com/lurk-lab/neptune", branch = "dev", features = ["abomonation"] }
nova = { git = "https://github.com/lurk-lab/arecibo", branch = "dev", package = "arecibo" }
nova = { git = "https://github.com/lurk-lab/arecibo", branch = "split-ck", package = "arecibo", features = ["abomonate"] }
once_cell = "1.18.0"
pairing = { version = "0.23" }
pasta_curves = { git = "https://github.com/lurk-lab/pasta_curves", branch = "dev" }
Expand Down
5 changes: 2 additions & 3 deletions benches/fibonacci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ fn fibonacci_prove<M: measurement::Measurement>(
true,
Kind::NovaPublicParams,
);
let store = Store::default();
let pp = public_params(&instance).unwrap();

// Track the number of `Lurk frames / sec`
Expand All @@ -103,8 +104,6 @@ fn fibonacci_prove<M: measurement::Measurement>(
BenchmarkId::new(name, params),
&prove_params,
|b, prove_params| {
let store = Store::default();

let ptr = fib_expr::<pasta_curves::Fq>(&store);
let prover = NovaProver::new(prove_params.reduction_count, lang_rc.clone());

Expand All @@ -119,7 +118,7 @@ fn fibonacci_prove<M: measurement::Measurement>(
let _ = black_box(result);
},
BatchSize::LargeInput,
)
);
},
);
}
Expand Down
2 changes: 1 addition & 1 deletion benches/sha256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ fn sha256_ivc_prove<M: measurement::Measurement>(
let lurk_step = make_eval_step_from_config(&EvalConfig::new_ivc(&lang));

// use cached public params
let instance: Instance<'_, Fr, Sha256Coproc<Fr>> = Instance::new(
let instance: Instance<Fr, Sha256Coproc<Fr>> = Instance::new(
reduction_count,
lang_rc.clone(),
true,
Expand Down
2 changes: 1 addition & 1 deletion examples/sha256_ivc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ fn main() {

let pp_start = Instant::now();
let instance = Instance::new(REDUCTION_COUNT, lang_rc, true, Kind::NovaPublicParams);
// see the documentation on `with_public_params`
// see the documentation on `public_params`
let pp = public_params(&instance).unwrap();
let pp_end = pp_start.elapsed();
println!("Public parameters took {:?}", pp_end);
Expand Down
27 changes: 12 additions & 15 deletions src/cli/lurk_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,7 @@ pub(crate) enum LurkProof<
'a,
F: CurveCycleEquipped,
C: Coprocessor<F> + Serialize + DeserializeOwned,
> where
<<E1<F> as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation,
<<E2<F> as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation,
{
> {
Nova {
proof: nova::Proof<F, C1LEM<'a, F, C>>,
public_inputs: Vec<F>,
Expand All @@ -141,9 +138,6 @@ pub(crate) enum LurkProof<

impl<'a, F: CurveCycleEquipped, C: Coprocessor<F> + 'a + Serialize + DeserializeOwned>
HasFieldModulus for LurkProof<'a, F, C>
where
<<E1<F> as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation,
<<E2<F> as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation,
{
fn field_modulus() -> String {
F::MODULUS.to_owned()
Expand All @@ -152,16 +146,24 @@ where

impl<'a, F: CurveCycleEquipped + Serialize, C: Coprocessor<F> + Serialize + DeserializeOwned>
LurkProof<'a, F, C>
where
<<E1<F> as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation,
<<E2<F> as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation,
{
#[inline]
pub(crate) fn persist(self, proof_key: &str) -> Result<()> {
dump(self, &proof_path(proof_key))
}
}

impl<
F: CurveCycleEquipped + DeserializeOwned,
C: Coprocessor<F> + Serialize + DeserializeOwned + 'static,
> LurkProof<'static, F, C>
{
#[inline]
pub(crate) fn is_cached(proof_key: &str) -> bool {
load::<Self>(&proof_path(proof_key)).is_ok()
}
}

impl<
F: CurveCycleEquipped + DeserializeOwned,
C: Coprocessor<F> + Serialize + DeserializeOwned + 'static,
Expand All @@ -180,11 +182,6 @@ where
Ok(())
}

#[inline]
pub(crate) fn is_cached(proof_key: &str) -> bool {
load::<Self>(&proof_path(proof_key)).is_ok()
}

fn verify(&self) -> Result<bool> {
match self {
Self::Nova {
Expand Down
5 changes: 2 additions & 3 deletions src/cli/repl/meta_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use ::nova::traits::Engine;
use abomonation::Abomonation;
use anyhow::{anyhow, bail, Context, Result};
use camino::{Utf8Path, Utf8PathBuf};
use ff::PrimeField;
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use std::{collections::HashMap, process};

Expand Down Expand Up @@ -49,8 +48,8 @@ impl<
C: Coprocessor<F> + Serialize + DeserializeOwned + 'static,
> MetaCmd<F, C>
where
<F as PrimeField>::Repr: Abomonation,
<<<F as CurveCycleEquipped>::E2 as Engine>::Scalar as PrimeField>::Repr: Abomonation,
<<E1<F> as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation,
<<E2<F> as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation,
{
const LOAD: MetaCmd<F, C> = MetaCmd {
name: "load",
Expand Down
8 changes: 3 additions & 5 deletions src/cli/repl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ mod meta_cmd;
use abomonation::Abomonation;
use anyhow::{anyhow, bail, Context, Result};
use camino::{Utf8Path, Utf8PathBuf};
use ff::PrimeField;
use nova::traits::Engine;
use rustyline::{
error::ReadlineError,
Expand Down Expand Up @@ -40,7 +39,7 @@ use crate::{
},
parser,
proof::{
nova::{CurveCycleEquipped, NovaProver},
nova::{CurveCycleEquipped, NovaProver, E1, E2},
RecursiveSNARKTrait,
},
public_parameters::{
Expand Down Expand Up @@ -167,8 +166,8 @@ impl<
C: Coprocessor<F> + Serialize + DeserializeOwned + 'static,
> Repl<F, C>
where
<F as PrimeField>::Repr: Abomonation,
<<<F as CurveCycleEquipped>::E2 as Engine>::Scalar as PrimeField>::Repr: Abomonation,
<<E1<F> as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation,
<<E2<F> as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation,
{
pub(crate) fn new(
store: Store<F>,
Expand Down Expand Up @@ -337,7 +336,6 @@ where
let instance =
Instance::new(self.rc, self.lang.clone(), true, Kind::NovaPublicParams);
let pp = public_params(&instance)?;

let prover = NovaProver::<_, C>::new(self.rc, self.lang.clone());

info!("Proving");
Expand Down
6 changes: 1 addition & 5 deletions src/lem/multiframe.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use abomonation::Abomonation;
use anyhow::Result;
use bellpepper::util_cs::witness_cs::WitnessCS;
use bellpepper_core::{num::AllocatedNum, Circuit, ConstraintSystem, SynthesisError};
use elsa::sync::FrozenMap;
use ff::PrimeField;
use nova::{supernova::NonUniformCircuit, traits::Engine};
use nova::supernova::NonUniformCircuit;
use once_cell::sync::OnceCell;
use rayon::prelude::*;
use std::sync::Arc;
Expand Down Expand Up @@ -904,8 +902,6 @@ impl<'a, F, C> NonUniformCircuit<E1<F>, E2<F>, MultiFrame<'a, F, C>, C2<F>> for
where
F: CurveCycleEquipped + LurkField,
C: Coprocessor<F> + 'a,
<<E1<F> as Engine>::Scalar as PrimeField>::Repr: Abomonation,
<<E2<F> as Engine>::Scalar as PrimeField>::Repr: Abomonation,
{
fn num_circuits(&self) -> usize {
assert_eq!(self.pc, 0);
Expand Down
Loading
Loading