diff --git a/src/cli/lurk_proof.rs b/src/cli/lurk_proof.rs index 3c5c93b1bd..980229aab9 100644 --- a/src/cli/lurk_proof.rs +++ b/src/cli/lurk_proof.rs @@ -1,6 +1,6 @@ use ::nova::{ supernova::NonUniformCircuit, - traits::{circuit_supernova::StepCircuit as SuperStepCircuit, Group}, + traits::{circuit_supernova::StepCircuit as SuperStepCircuit, Engine}, }; use abomonation::Abomonation; use anyhow::{bail, Result}; @@ -14,7 +14,7 @@ use crate::{ field::LurkField, lem::{pointers::ZPtr, store::Store}, proof::{ - nova::{self, CurveCycleEquipped, G1, G2}, + nova::{self, CurveCycleEquipped, E1, E2}, supernova::C2, MultiFrameTrait, }, @@ -157,8 +157,8 @@ pub(crate) enum LurkProof< C: Coprocessor + Serialize + DeserializeOwned, M: MultiFrameTrait<'a, F, C>, > where - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, { Nova { proof: nova::Proof<'a, F, C, M>, @@ -177,8 +177,8 @@ impl< M: MultiFrameTrait<'a, F, C>, > HasFieldModulus for LurkProof<'a, F, C, M> where - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, { fn field_modulus() -> String { F::MODULUS.to_owned() @@ -192,8 +192,8 @@ impl< M: MultiFrameTrait<'a, F, C>, > LurkProof<'a, F, C, M> where - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, { #[inline] fn public_io(&self) -> (&[F], &[F]) { @@ -245,8 +245,8 @@ impl< M: MultiFrameTrait<'a, F, C>, > LurkProof<'a, F, C, M> where - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, { #[inline] pub(crate) fn persist(self, proof_key: &str) -> Result<()> { @@ -259,12 +259,12 @@ impl< C: Coprocessor + Serialize + DeserializeOwned + 'static, M: MultiFrameTrait<'static, F, C> + SuperStepCircuit - + NonUniformCircuit, G2, M, C2> + + NonUniformCircuit, E2, M, C2> + 'static, > LurkProof<'static, F, C, M> where - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, { pub(crate) fn verify_proof(proof_key: &str) -> Result<()> { let lurk_proof = load::(&proof_path(proof_key))?; @@ -309,8 +309,8 @@ pub(crate) struct PackedLurkProof< C: Coprocessor + Serialize + DeserializeOwned, M: MultiFrameTrait<'a, F, C>, > where - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, { proof: LurkProof<'a, F, C, M>, meta: Option>, @@ -324,8 +324,8 @@ impl< M: MultiFrameTrait<'a, F, C>, > HasFieldModulus for PackedLurkProof<'a, F, C, M> where - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, { fn field_modulus() -> String { F::MODULUS.to_owned() @@ -337,12 +337,12 @@ impl< C: Coprocessor + 'static + Serialize + DeserializeOwned, M: MultiFrameTrait<'static, F, C> + SuperStepCircuit - + NonUniformCircuit, G2, M, C2> + + NonUniformCircuit, E2, M, C2> + 'static, > PackedLurkProof<'static, F, C, M> where - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, { pub(crate) fn pack( proof_key: String, diff --git a/src/cli/repl/meta_cmd.rs b/src/cli/repl/meta_cmd.rs index f6dbef1cdc..c07be7bb04 100644 --- a/src/cli/repl/meta_cmd.rs +++ b/src/cli/repl/meta_cmd.rs @@ -1,6 +1,6 @@ use abomonation::Abomonation; use anyhow::{bail, Context, Result}; -use nova::traits::Group; +use nova::traits::Engine; use serde::{de::DeserializeOwned, Serialize}; use std::{collections::HashMap, process}; @@ -10,7 +10,7 @@ use crate::{ field::LurkField, lem::{multiframe::MultiFrame, pointers::Ptr, Tag}, package::{Package, SymbolRef}, - proof::nova::{CurveCycleEquipped, G1, G2}, + proof::nova::{CurveCycleEquipped, E1, E2}, tag::{ContTag, ExprTag}, }; @@ -359,8 +359,8 @@ impl MetaCmd { impl MetaCmd where - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, { const VERIFY: MetaCmd = MetaCmd { name: "verify", diff --git a/src/lem/multiframe.rs b/src/lem/multiframe.rs index abb54253c3..b2e87d23d2 100644 --- a/src/lem/multiframe.rs +++ b/src/lem/multiframe.rs @@ -4,7 +4,7 @@ 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::Group}; +use nova::{supernova::NonUniformCircuit, traits::Engine}; use rayon::prelude::*; use std::sync::Arc; @@ -16,7 +16,7 @@ use crate::{ eval::lang::Lang, field::{LanguageField, LurkField}, proof::{ - nova::{CurveCycleEquipped, G1, G2}, + nova::{CurveCycleEquipped, E1, E2}, supernova::{FoldingConfig, C2}, CEKState, EvaluationStore, FrameLike, MultiFrameTrait, Provable, }, @@ -901,12 +901,12 @@ impl<'a, F: LurkField, C: Coprocessor> nova::traits::circuit_supernova::StepC } } -impl<'a, F, C> NonUniformCircuit, G2, MultiFrame<'a, F, C>, C2> for MultiFrame<'a, F, C> +impl<'a, F, C> NonUniformCircuit, E2, MultiFrame<'a, F, C>, C2> for MultiFrame<'a, F, C> where F: CurveCycleEquipped + LurkField, C: Coprocessor + 'a, - < as Group>::Scalar as PrimeField>::Repr: Abomonation, - < as Group>::Scalar as PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as PrimeField>::Repr: Abomonation, { fn num_circuits(&self) -> usize { assert_eq!(self.pc, 0); diff --git a/src/proof/nova.rs b/src/proof/nova.rs index c6351786cd..2cec7c00ab 100644 --- a/src/proof/nova.rs +++ b/src/proof/nova.rs @@ -5,16 +5,19 @@ use bellpepper_core::{num::AllocatedNum, ConstraintSystem}; use ff::Field; use nova::{ errors::NovaError, - provider::bn256_grumpkin::{bn256, grumpkin}, + provider::{ + bn256_grumpkin::{bn256, Bn256Engine, GrumpkinEngine}, + pasta::{PallasEngine, VestaEngine}, + }, traits::{ circuit::{StepCircuit, TrivialCircuit}, evaluation::EvaluationEngineTrait, snark::RelaxedR1CSSNARKTrait, - Group, + Engine, }, CircuitShape, CompressedSNARK, ProverKey, RecursiveSNARK, VerifierKey, }; -use pasta_curves::{pallas, vesta}; +use pasta_curves::pallas; use rayon::prelude::*; use serde::{Deserialize, Serialize}; use std::{ @@ -46,38 +49,38 @@ pub trait CurveCycleEquipped: LurkField { /// encapsulating these idiosyncracies within Nova. /// a concrete implementation of an [`nova::traits::evaluation::EvaluationEngineTrait`] for G1, - type EE1: EvaluationEngineTrait; + type EE1: EvaluationEngineTrait; /// a concrete implementation of an [`nova::traits::evaluation::EvaluationEngineTrait`] for G2, - type EE2: EvaluationEngineTrait; + type EE2: EvaluationEngineTrait; /// The group type for the first curve in the cycle. - type G1: Group::Scalar, Scalar = Self>; + type E1: Engine::Scalar, Scalar = Self>; /// The group type for the second curve in the cycle. - type G2: Group::Scalar>; + type E2: Engine::Scalar>; } impl CurveCycleEquipped for pallas::Scalar { - type EE1 = nova::provider::ipa_pc::EvaluationEngine; - type EE2 = nova::provider::ipa_pc::EvaluationEngine; + type EE1 = nova::provider::ipa_pc::EvaluationEngine; + type EE2 = nova::provider::ipa_pc::EvaluationEngine; - type G1 = pallas::Point; - type G2 = vesta::Point; + type E1 = PallasEngine; + type E2 = VestaEngine; } // The impl CurveCycleEquipped for vesta::Scalar is academically possible, but voluntarily omitted to avoid confusion. impl CurveCycleEquipped for bn256::Scalar { - type EE1 = nova::provider::ipa_pc::EvaluationEngine; - type EE2 = nova::provider::ipa_pc::EvaluationEngine; + type EE1 = nova::provider::ipa_pc::EvaluationEngine; + type EE2 = nova::provider::ipa_pc::EvaluationEngine; - type G1 = bn256::Point; - type G2 = grumpkin::Point; + type E1 = Bn256Engine; + type E2 = GrumpkinEngine; } // The impl CurveCycleEquipped for grumpkin::Scalar is academically possible, but voluntarily omitted to avoid confusion. /// Convenience alias for the primary group type pegged to a LurkField through a CurveCycleEquipped type. -pub type G1 = ::G1; +pub type E1 = ::E1; /// Convenience alias for the secondary group type pegged to a LurkField through a CurveCycleEquipped type. -pub type G2 = ::G2; +pub type E2 = ::E2; /// Type alias for the Evaluation Engine using G1 group elements. pub type EE1 = ::EE1; @@ -87,24 +90,24 @@ pub type EE2 = ::EE2; /// 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>; +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>; +pub type SS2 = nova::spartan::snark::RelaxedR1CSSNARK, EE2>; /// Type alias for a MultiFrame with S1 field elements. /// This uses the <::G1 as Group>::Scalar type for the G1 scalar field elements /// to reflect it this should not be used outside the Nova context pub type C1LEM<'a, F, C> = crate::lem::multiframe::MultiFrame<'a, F, C>; /// Type alias for a Trivial Test Circuit with G2 scalar field elements. -pub type C2 = TrivialCircuit< as Group>::Scalar>; +pub type C2 = TrivialCircuit< as Engine>::Scalar>; /// Type alias for Nova Circuit Parameters with the curve cycle types defined above. -pub type NovaCircuitShape = CircuitShape>; +pub type NovaCircuitShape = CircuitShape>; /// Type alias for Nova Public Parameters with the curve cycle types defined above. -pub type NovaPublicParams = nova::PublicParams, G2, C1, C2>; +pub type NovaPublicParams = nova::PublicParams, E2, C1, C2>; /// A struct that contains public parameters for the Nova proving system. #[derive(Clone, Serialize, Deserialize)] @@ -113,18 +116,18 @@ pub struct PublicParams> where F: CurveCycleEquipped, // technical bounds that would disappear once associated_type_bounds stabilizes - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, { pp: NovaPublicParams, - pk: ProverKey, G2, SC, C2, SS1, SS2>, - vk: VerifierKey, G2, SC, C2, SS1, SS2>, + pk: ProverKey, E2, SC, C2, SS1, SS2>, + vk: VerifierKey, E2, SC, C2, SS1, SS2>, } impl> Abomonation for PublicParams where - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, { unsafe fn entomb(&self, bytes: &mut W) -> std::io::Result<()> { self.pp.entomb(bytes)?; @@ -153,17 +156,17 @@ where #[serde(bound = "")] pub enum Proof<'a, F: CurveCycleEquipped, C: Coprocessor, M: MultiFrameTrait<'a, F, C>> where - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, { /// A proof for the intermediate steps of a recursive computation Recursive( - Box, G2, M, C2>>, + Box, E2, M, C2>>, PhantomData<&'a C>, ), /// A proof for the final step of a recursive computation Compressed( - Box, G2, M, C2, SS1, SS2>>, + Box, E2, M, C2, SS1, SS2>>, PhantomData<&'a C>, ), } @@ -185,7 +188,7 @@ pub fn circuit_cache_key< ) -> F { let folding_config = Arc::new(FoldingConfig::new_ivc(lang, 2)); let circuit = M::blank(folding_config, 0); - F::from(rc as u64) * nova::circuit_digest::(&circuit) + F::from(rc as u64) * nova::circuit_digest::(&circuit) } /// Generates the public parameters for the Nova proving system. @@ -199,15 +202,15 @@ pub fn public_params< lang: Arc>, ) -> PublicParams where - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, { let (circuit_primary, circuit_secondary) = circuits(num_iters_per_step, lang); - let commitment_size_hint1 = as RelaxedR1CSSNARKTrait>>::ck_floor(); - let commitment_size_hint2 = as RelaxedR1CSSNARKTrait>>::ck_floor(); + let commitment_size_hint1 = as RelaxedR1CSSNARKTrait>>::ck_floor(); + let commitment_size_hint2 = as RelaxedR1CSSNARKTrait>>::ck_floor(); - let pp = nova::PublicParams::new( + let pp = nova::PublicParams::setup( &circuit_primary, &circuit_secondary, &*commitment_size_hint1, @@ -243,8 +246,8 @@ pub struct NovaProver< impl<'a, F: CurveCycleEquipped, C: Coprocessor, M: MultiFrameTrait<'a, F, C>> Prover<'a, F, C, M> for NovaProver<'a, F, C, M> where - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, { type PublicParams = PublicParams; fn new(reduction_count: usize, lang: Lang) -> Self { @@ -266,8 +269,8 @@ where impl<'a, F: CurveCycleEquipped, C: Coprocessor, M: MultiFrameTrait<'a, F, C>> NovaProver<'a, F, C, M> where - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, { /// Proves the computation given the public parameters, frames, and store. pub fn prove( @@ -313,8 +316,8 @@ where impl<'a, F: CurveCycleEquipped, C: Coprocessor, M: MultiFrameTrait<'a, F, C>> Proof<'a, F, C, M> where - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, { /// Proves the computation recursively, generating a recursive SNARK proof. #[tracing::instrument(skip_all, name = "nova::prove_recursively")] @@ -333,13 +336,13 @@ where let z0_secondary = Self::z0_secondary(); assert_eq!(circuits[0].frames().unwrap().len(), num_iters_per_step); - let (_circuit_primary, circuit_secondary): (M, TrivialCircuit< as Group>::Scalar>) = + let (_circuit_primary, circuit_secondary): (M, TrivialCircuit< as Engine>::Scalar>) = crate::proof::nova::circuits(num_iters_per_step, lang); tracing::debug!("circuits.len: {}", circuits.len()); // produce a recursive SNARK - let mut recursive_snark: Option, G2, M, C2>> = None; + let mut recursive_snark: Option, E2, M, C2>> = None; // the shadowing here is voluntary let recursive_snark = if lurk_config(None, None) @@ -399,7 +402,7 @@ where if debug { // For debugging purposes, synthesize the circuit and check that the constraint system is satisfied. use bellpepper_core::test_cs::TestConstraintSystem; - let mut cs = TestConstraintSystem::< as Group>::Scalar>::new(); + let mut cs = TestConstraintSystem::< as Engine>::Scalar>::new(); // This is a CircuitFrame, not an EvalFrame let first_frame = circuit_primary.frames().unwrap().iter().next().unwrap(); @@ -476,7 +479,7 @@ where Ok(zi_primary == zi_primary_verified && zi_secondary == zi_secondary_verified) } - fn z0_secondary() -> Vec<::Scalar> { - vec![ as Group>::Scalar::ZERO] + fn z0_secondary() -> Vec<::Scalar> { + vec![ as Engine>::Scalar::ZERO] } } diff --git a/src/proof/supernova.rs b/src/proof/supernova.rs index ff2aec4fa9..9cb66479cb 100644 --- a/src/proof/supernova.rs +++ b/src/proof/supernova.rs @@ -9,7 +9,7 @@ use nova::{ traits::{ circuit_supernova::{StepCircuit as SuperStepCircuit, TrivialSecondaryCircuit}, snark::default_ck_hint, - Group, + Engine, }, }; use serde::{Deserialize, Serialize}; @@ -23,39 +23,39 @@ use crate::{ field::LurkField, lem::eval::EvalConfig, proof::{ - nova::{CurveCycleEquipped, NovaCircuitShape, G1, G2}, + nova::{CurveCycleEquipped, NovaCircuitShape, E1, E2}, {EvaluationStore, FrameLike, MultiFrameTrait, Prover}, }, }; /// Type alias for a Trivial Test Circuit with G2 scalar field elements. -pub type C2 = TrivialSecondaryCircuit< as Group>::Scalar>; +pub type C2 = TrivialSecondaryCircuit< as Engine>::Scalar>; /// Type alias for SuperNova Aux Parameters with the curve cycle types defined above. -pub type SuperNovaAuxParams = AuxParams, G2>; +pub type SuperNovaAuxParams = AuxParams, E2>; /// Type alias for SuperNova Public Parameters with the curve cycle types defined above. -pub type SuperNovaPublicParams = supernova::PublicParams, G2, C1, C2>; +pub type SuperNovaPublicParams = supernova::PublicParams, E2, C1, C2>; /// A struct that contains public parameters for the SuperNova proving system. pub struct PublicParams> where // technical bounds that would disappear once associated_type_bounds stabilizes - < as Group>::Scalar as PrimeField>::Repr: Abomonation, - < as Group>::Scalar as PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as PrimeField>::Repr: Abomonation, { /// Public params for SuperNova. pub pp: SuperNovaPublicParams, // SuperNova does not yet have a `CompressedSNARK`. - // pk: ProverKey, G2, SC, C2, SS1, SS2>, - // vk: VerifierKey, G2, SC, C2, SS1, SS2>, + // pk: ProverKey, E2, SC, C2, SS1, SS2>, + // vk: VerifierKey, E2, SC, C2, SS1, SS2>, } impl> Index for PublicParams where // technical bounds that would disappear once associated_type_bounds stabilizes - < as Group>::Scalar as PrimeField>::Repr: Abomonation, - < as Group>::Scalar as PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as PrimeField>::Repr: Abomonation, { type Output = NovaCircuitShape; @@ -67,8 +67,8 @@ where impl> PublicParams where // technical bounds that would disappear once associated_type_bounds stabilizes - < as Group>::Scalar as PrimeField>::Repr: Abomonation, - < as Group>::Scalar as PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as PrimeField>::Repr: Abomonation, { /// return the digest pub fn digest(&self) -> F { @@ -81,19 +81,19 @@ pub fn public_params< 'a, F: CurveCycleEquipped, C: Coprocessor + 'a, - M: MultiFrameTrait<'a, F, C> + SuperStepCircuit + NonUniformCircuit, G2, M, C2>, + M: MultiFrameTrait<'a, F, C> + SuperStepCircuit + NonUniformCircuit, E2, M, C2>, >( rc: usize, lang: Arc>, ) -> PublicParams where - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, { let folding_config = Arc::new(FoldingConfig::new_nivc(lang, rc)); let non_uniform_circuit = M::blank(folding_config, 0); // TODO: use `&*SS::commitment_key_floor()`, where `SS: RelaxedR1CSSNARKTrait`` when https://github.com/lurk-lab/arecibo/issues/27 closes - let pp = SuperNovaPublicParams::::new( + let pp = SuperNovaPublicParams::::setup( &non_uniform_circuit, &*default_ck_hint(), &*default_ck_hint(), @@ -105,13 +105,13 @@ where #[derive(Serialize, Deserialize)] pub enum Proof<'a, F: CurveCycleEquipped, C: Coprocessor, M: MultiFrameTrait<'a, F, C>> where - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, { /// A proof for the intermediate steps of a recursive computation - Recursive(Box, G2>>), + Recursive(Box, E2>>), /// A proof for the final step of a recursive computation - // Compressed(Box, G2, C1<'a, F, C>, C2, SS1, SS2>>), + // Compressed(Box, E2, C1<'a, F, C>, C2, SS1, SS2>>), Compressed(PhantomData<&'a (C, M)>), } @@ -119,11 +119,11 @@ impl< 'a, F: CurveCycleEquipped, C: Coprocessor, - M: MultiFrameTrait<'a, F, C> + SuperStepCircuit + NonUniformCircuit, G2, M, C2>, + M: MultiFrameTrait<'a, F, C> + SuperStepCircuit + NonUniformCircuit, E2, M, C2>, > Proof<'a, F, C, M> where - < as Group>::Scalar as PrimeField>::Repr: Abomonation, - < as Group>::Scalar as PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as PrimeField>::Repr: Abomonation, { /// Proves the computation recursively, generating a recursive SNARK proof. #[tracing::instrument(skip_all, name = "supernova::prove_recursively")] @@ -136,7 +136,7 @@ where // Is this assertion strictly necessary? assert!(!nivc_steps.is_empty()); - let mut recursive_snark_option: Option, G2>> = None; + let mut recursive_snark_option: Option, E2>> = None; let z0_primary = z0; let z0_secondary = Self::z0_secondary(); @@ -200,8 +200,8 @@ where Ok(zi_primary == zi_primary_verified && *zi_secondary == zi_secondary_verified) } - fn z0_secondary() -> Vec<::Scalar> { - vec![ as Group>::Scalar::ZERO] + fn z0_secondary() -> Vec<::Scalar> { + vec![ as Engine>::Scalar::ZERO] } } @@ -227,8 +227,8 @@ impl< M: MultiFrameTrait<'a, F, C> + SuperStepCircuit, > Prover<'a, F, C, M> for SuperNovaProver<'a, F, C, M> where - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, { type PublicParams = PublicParams; fn new(reduction_count: usize, lang: Lang) -> Self { @@ -251,11 +251,11 @@ impl< 'a, F: CurveCycleEquipped, C: Coprocessor, - M: MultiFrameTrait<'a, F, C> + SuperStepCircuit + NonUniformCircuit, G2, M, C2>, + M: MultiFrameTrait<'a, F, C> + SuperStepCircuit + NonUniformCircuit, E2, M, C2>, > SuperNovaProver<'a, F, C, M> where - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, { /// Proves the computation given the public parameters, frames, and store. pub fn prove( @@ -358,21 +358,21 @@ pub fn circuit_cache_key< 'a, F: CurveCycleEquipped, C: Coprocessor + 'a, - M: MultiFrameTrait<'a, F, C> + SuperStepCircuit + NonUniformCircuit, G2, M, C2>, + M: MultiFrameTrait<'a, F, C> + SuperStepCircuit + NonUniformCircuit, E2, M, C2>, >( rc: usize, lang: Arc>, circuit_index: usize, ) -> F where - < as Group>::Scalar as PrimeField>::Repr: Abomonation, - < as Group>::Scalar as PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as PrimeField>::Repr: Abomonation, { let folding_config = Arc::new(FoldingConfig::new_nivc(lang, 2)); let circuit = M::blank(folding_config, 0); let num_circuits = circuit.num_circuits(); let circuit = circuit.primary_circuit(circuit_index); - F::from(rc as u64) * supernova::circuit_digest::(&circuit, num_circuits) + F::from(rc as u64) * supernova::circuit_digest::(&circuit, num_circuits) } /// Collects all the cache keys of supernova instance. We need all of them to compute @@ -381,14 +381,14 @@ pub fn circuit_cache_keys< 'a, F: CurveCycleEquipped, C: Coprocessor + 'a, - M: MultiFrameTrait<'a, F, C> + SuperStepCircuit + NonUniformCircuit, G2, M, C2>, + M: MultiFrameTrait<'a, F, C> + SuperStepCircuit + NonUniformCircuit, E2, M, C2>, >( rc: usize, lang: &Arc>, -) -> CircuitDigests> +) -> CircuitDigests> where - < as Group>::Scalar as PrimeField>::Repr: Abomonation, - < as Group>::Scalar as PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as PrimeField>::Repr: Abomonation, { let num_circuits = lang.coprocessor_count() + 1; let digests = (0..num_circuits) diff --git a/src/proof/tests/mod.rs b/src/proof/tests/mod.rs index c6238999ef..9e8360c2e7 100644 --- a/src/proof/tests/mod.rs +++ b/src/proof/tests/mod.rs @@ -3,7 +3,7 @@ mod nova_tests_lem; use abomonation::Abomonation; use bellpepper::util_cs::{metric_cs::MetricCS, witness_cs::WitnessCS, Comparable}; use bellpepper_core::{test_cs::TestConstraintSystem, ConstraintSystem, Delta}; -use nova::traits::Group; +use nova::traits::Engine; use std::sync::Arc; use crate::{ @@ -11,7 +11,7 @@ use crate::{ eval::lang::Lang, lem::eval::EvalConfig, proof::{ - nova::{public_params, CurveCycleEquipped, NovaProver, G1, G2}, + nova::{public_params, CurveCycleEquipped, NovaProver, E1, E2}, supernova::FoldingConfig, CEKState, EvaluationStore, MultiFrameTrait, Prover, }, @@ -47,8 +47,8 @@ fn test_aux<'a, F: CurveCycleEquipped, C: Coprocessor, M: MultiFrameTrait<'a, ) // technical bounds that would disappear once associated_type_bounds stabilizes where - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, { for chunk_size in REDUCTION_COUNTS_TO_TEST { nova_test_full_aux::( @@ -82,8 +82,8 @@ fn nova_test_full_aux<'a, F: CurveCycleEquipped, C: Coprocessor, M: MultiFram ) // technical bounds that would disappear once associated_type_bounds stabilizes where - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, { let expr = s.read(expr).unwrap(); @@ -126,8 +126,8 @@ fn nova_test_full_aux2<'a, F: CurveCycleEquipped, C: Coprocessor, M: MultiFra ) // technical bounds that would disappear once associated_type_bounds stabilizes where - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, { let limit = limit.unwrap_or(10000); diff --git a/src/public_parameters/disk_cache.rs b/src/public_parameters/disk_cache.rs index c612fa00a2..312793a797 100644 --- a/src/public_parameters/disk_cache.rs +++ b/src/public_parameters/disk_cache.rs @@ -4,11 +4,11 @@ use std::marker::PhantomData; use abomonation::{encode, Abomonation}; use camino::{Utf8Path, Utf8PathBuf}; -use nova::traits::Group; +use nova::traits::Engine; use crate::config::lurk_config; use crate::coprocessor::Coprocessor; -use crate::proof::nova::{CurveCycleEquipped, PublicParams, G1, G2}; +use crate::proof::nova::{CurveCycleEquipped, PublicParams, E1, E2}; use crate::proof::MultiFrameTrait; use crate::public_parameters::error::Error; @@ -34,8 +34,8 @@ impl<'a, F: CurveCycleEquipped, C: Coprocessor + 'a, M: MultiFrameTrait<'a, F DiskCache<'a, F, C, M> where // technical bounds that would disappear once associated_type_bounds stabilizes - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, { pub(crate) fn new(disk_cache_path: &Utf8Path) -> Result { create_dir_all(disk_cache_path)?; diff --git a/src/public_parameters/instance.rs b/src/public_parameters/instance.rs index 354261940c..2c5dfa8d55 100644 --- a/src/public_parameters/instance.rs +++ b/src/public_parameters/instance.rs @@ -45,7 +45,7 @@ use std::{ use ::nova::{ constants::NUM_HASH_BITS, supernova::NonUniformCircuit, - traits::{circuit_supernova::StepCircuit as SuperStepCircuit, Group}, + traits::{circuit_supernova::StepCircuit as SuperStepCircuit, Engine}, }; use abomonation::Abomonation; use camino::Utf8Path; @@ -57,7 +57,7 @@ use crate::{ eval::lang::Lang, proof::MultiFrameTrait, proof::{ - nova::{self, CurveCycleEquipped, G1, G2}, + nova::{self, CurveCycleEquipped, E1, E2}, supernova::{self, C2}, }, }; @@ -134,11 +134,11 @@ impl< 'a, F: CurveCycleEquipped, C: Coprocessor, - M: MultiFrameTrait<'a, F, C> + SuperStepCircuit + NonUniformCircuit, G2, M, C2>, + M: MultiFrameTrait<'a, F, C> + SuperStepCircuit + NonUniformCircuit, E2, M, C2>, > Instance<'a, F, C, M> where - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, { pub fn new(rc: usize, lang: Arc>, abomonated: bool, kind: Kind) -> Self { let cache_key = match kind { @@ -196,8 +196,8 @@ where impl<'a, F: CurveCycleEquipped, C: Coprocessor, M: MultiFrameTrait<'a, F, C>> Instance<'a, F, C, M> where - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, { /// The key (or cache_key) of this [Instance] used to retrieve it from the file cache pub fn lang(&self) -> Arc> { diff --git a/src/public_parameters/mem_cache.rs b/src/public_parameters/mem_cache.rs index 9920a3c920..3941392a0e 100644 --- a/src/public_parameters/mem_cache.rs +++ b/src/public_parameters/mem_cache.rs @@ -4,7 +4,7 @@ use std::{ }; use abomonation::{decode, Abomonation}; -use nova::traits::Group; +use nova::traits::Engine; use once_cell::sync::Lazy; use tap::TapFallible; use tracing::{info, warn}; @@ -12,7 +12,7 @@ use tracing::{info, warn}; use crate::proof::MultiFrameTrait; use crate::{ coprocessor::Coprocessor, - proof::nova::{PublicParams, G1, G2}, + proof::nova::{PublicParams, E1, E2}, }; use crate::{proof::nova::CurveCycleEquipped, public_parameters::error::Error}; @@ -51,8 +51,8 @@ impl PublicParamMemCache { default: Fn, ) -> Result>, Error> where - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, { // subdirectory search let disk_cache = DiskCache::new(public_params_dir()).unwrap(); @@ -111,8 +111,8 @@ impl PublicParamMemCache { default: Fn, ) -> Result>, Error> where - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, { // re-grab the lock let mut mem_cache = self.mem_cache.lock().unwrap(); diff --git a/src/public_parameters/mod.rs b/src/public_parameters/mod.rs index d17113cb17..fafe35d869 100644 --- a/src/public_parameters/mod.rs +++ b/src/public_parameters/mod.rs @@ -1,10 +1,10 @@ -use ::nova::traits::Group; +use ::nova::traits::Engine; use abomonation::{decode, Abomonation}; use std::sync::Arc; use crate::coprocessor::Coprocessor; use crate::proof::nova::{self, NovaCircuitShape, PublicParams}; -use crate::proof::nova::{CurveCycleEquipped, G1, G2}; +use crate::proof::nova::{CurveCycleEquipped, E1, E2}; use crate::proof::MultiFrameTrait; pub mod disk_cache; @@ -27,8 +27,8 @@ pub fn public_params< instance: &Instance<'static, F, C, M>, ) -> Result>, Error> where - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, { let f = |instance: &Instance<'static, F, C, M>| { Arc::new(nova::public_params(instance.rc, instance.lang())) @@ -50,8 +50,8 @@ where C: Coprocessor + 'a, M: MultiFrameTrait<'a, F, C>, Fn: FnOnce(&PublicParams) -> T, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, { let default = |instance: &Instance<'a, F, C, M>| nova::public_params(instance.rc, instance.lang()); @@ -88,8 +88,8 @@ pub fn supernova_circuit_params< instance: &Instance<'a, F, C, M>, ) -> Result, Error> where - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, { let disk_cache = DiskCache::::new(public_params_dir()).unwrap(); @@ -114,8 +114,8 @@ pub fn supernova_aux_params< instance: &Instance<'a, F, C, M>, ) -> Result, Error> where - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, { let disk_cache = DiskCache::::new(public_params_dir()).unwrap(); @@ -140,13 +140,13 @@ pub fn supernova_public_params< 'a, F: CurveCycleEquipped, C: Coprocessor + 'a, - M: MultiFrameTrait<'a, F, C> + SuperStepCircuit + NonUniformCircuit, G2, M, C2>, + M: MultiFrameTrait<'a, F, C> + SuperStepCircuit + NonUniformCircuit, E2, M, C2>, >( instance_primary: &Instance<'a, F, C, M>, ) -> Result, Error> where - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, - < as Group>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, + < as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation, { let default = |instance: &Instance<'a, F, C, M>| { supernova::public_params::<'a, F, C, M>(instance.rc, instance.lang())