Skip to content

Commit

Permalink
refactor: Refactor to adpt to Arecibo changes in PR 133 (#917)
Browse files Browse the repository at this point in the history
* refactor: Refactor to adpt to Arecibo changes argumentcomputer/arecibo#133

- Adapted the codebase to replace the `Group` types and traits with `Engine`, and replaced `G1` and `G2` with `E1` and `E2`.
- Updated the trait `EvaluationEngineTrait<G>` and `RelaxedR1CSSNARKTrait` along with type aliases to reflect these changes.
- Modified the `CurveCycleEquipped` implementation for `bn256::Scalar` and `pallas::Scalar`.
- Made necessary adjustments to the aid functions and type aliases related to `NovaProver` for compatibility with the new group types.
- Made changes in the SuperNova proving system to accommodate new `Engine` types.

* chore: re-align the arecibo branch to dev
  • Loading branch information
huitseeker authored Nov 23, 2023
1 parent e5abcc5 commit 47c9608
Show file tree
Hide file tree
Showing 10 changed files with 159 additions and 156 deletions.
40 changes: 20 additions & 20 deletions src/cli/lurk_proof.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand All @@ -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,
},
Expand Down Expand Up @@ -157,8 +157,8 @@ pub(crate) enum LurkProof<
C: Coprocessor<F> + Serialize + DeserializeOwned,
M: MultiFrameTrait<'a, F, C>,
> where
<<G1<F> as Group>::Scalar as ff::PrimeField>::Repr: Abomonation,
<<G2<F> as Group>::Scalar as ff::PrimeField>::Repr: Abomonation,
<<E1<F> as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation,
<<E2<F> as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation,
{
Nova {
proof: nova::Proof<'a, F, C, M>,
Expand All @@ -177,8 +177,8 @@ impl<
M: MultiFrameTrait<'a, F, C>,
> HasFieldModulus for LurkProof<'a, F, C, M>
where
<<G1<F> as Group>::Scalar as ff::PrimeField>::Repr: Abomonation,
<<G2<F> as Group>::Scalar as ff::PrimeField>::Repr: Abomonation,
<<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 @@ -192,8 +192,8 @@ impl<
M: MultiFrameTrait<'a, F, C>,
> LurkProof<'a, F, C, M>
where
<<G1<F> as Group>::Scalar as ff::PrimeField>::Repr: Abomonation,
<<G2<F> as Group>::Scalar as ff::PrimeField>::Repr: Abomonation,
<<E1<F> as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation,
<<E2<F> as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation,
{
#[inline]
fn public_io(&self) -> (&[F], &[F]) {
Expand Down Expand Up @@ -245,8 +245,8 @@ impl<
M: MultiFrameTrait<'a, F, C>,
> LurkProof<'a, F, C, M>
where
<<G1<F> as Group>::Scalar as ff::PrimeField>::Repr: Abomonation,
<<G2<F> as Group>::Scalar as ff::PrimeField>::Repr: Abomonation,
<<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<()> {
Expand All @@ -259,12 +259,12 @@ impl<
C: Coprocessor<F> + Serialize + DeserializeOwned + 'static,
M: MultiFrameTrait<'static, F, C>
+ SuperStepCircuit<F>
+ NonUniformCircuit<G1<F>, G2<F>, M, C2<F>>
+ NonUniformCircuit<E1<F>, E2<F>, M, C2<F>>
+ 'static,
> LurkProof<'static, F, C, M>
where
<<G1<F> as Group>::Scalar as ff::PrimeField>::Repr: Abomonation,
<<G2<F> as Group>::Scalar as ff::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 verify_proof(proof_key: &str) -> Result<()> {
let lurk_proof = load::<Self>(&proof_path(proof_key))?;
Expand Down Expand Up @@ -309,8 +309,8 @@ pub(crate) struct PackedLurkProof<
C: Coprocessor<F> + Serialize + DeserializeOwned,
M: MultiFrameTrait<'a, F, C>,
> where
<<G1<F> as Group>::Scalar as ff::PrimeField>::Repr: Abomonation,
<<G2<F> as Group>::Scalar as ff::PrimeField>::Repr: Abomonation,
<<E1<F> as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation,
<<E2<F> as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation,
{
proof: LurkProof<'a, F, C, M>,
meta: Option<LurkProofMeta<F>>,
Expand All @@ -324,8 +324,8 @@ impl<
M: MultiFrameTrait<'a, F, C>,
> HasFieldModulus for PackedLurkProof<'a, F, C, M>
where
<<G1<F> as Group>::Scalar as ff::PrimeField>::Repr: Abomonation,
<<G2<F> as Group>::Scalar as ff::PrimeField>::Repr: Abomonation,
<<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 @@ -337,12 +337,12 @@ impl<
C: Coprocessor<F> + 'static + Serialize + DeserializeOwned,
M: MultiFrameTrait<'static, F, C>
+ SuperStepCircuit<F>
+ NonUniformCircuit<G1<F>, G2<F>, M, C2<F>>
+ NonUniformCircuit<E1<F>, E2<F>, M, C2<F>>
+ 'static,
> PackedLurkProof<'static, F, C, M>
where
<<G1<F> as Group>::Scalar as ff::PrimeField>::Repr: Abomonation,
<<G2<F> as Group>::Scalar as ff::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 pack(
proof_key: String,
Expand Down
8 changes: 4 additions & 4 deletions src/cli/repl/meta_cmd.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand All @@ -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},
};

Expand Down Expand Up @@ -359,8 +359,8 @@ impl MetaCmd<F> {

impl<F: CurveCycleEquipped + Serialize + DeserializeOwned> MetaCmd<F>
where
<<G1<F> as Group>::Scalar as ff::PrimeField>::Repr: Abomonation,
<<G2<F> as Group>::Scalar as ff::PrimeField>::Repr: Abomonation,
<<E1<F> as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation,
<<E2<F> as Engine>::Scalar as ff::PrimeField>::Repr: Abomonation,
{
const VERIFY: MetaCmd<F> = MetaCmd {
name: "verify",
Expand Down
10 changes: 5 additions & 5 deletions src/lem/multiframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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,
},
Expand Down Expand Up @@ -901,12 +901,12 @@ impl<'a, F: LurkField, C: Coprocessor<F>> nova::traits::circuit_supernova::StepC
}
}

impl<'a, F, C> NonUniformCircuit<G1<F>, G2<F>, MultiFrame<'a, F, C>, C2<F>> for MultiFrame<'a, F, C>
impl<'a, F, C> NonUniformCircuit<E1<F>, E2<F>, MultiFrame<'a, F, C>, C2<F>> for MultiFrame<'a, F, C>
where
F: CurveCycleEquipped + LurkField,
C: Coprocessor<F> + 'a,
<<G1<F> as Group>::Scalar as PrimeField>::Repr: Abomonation,
<<G2<F> as Group>::Scalar as PrimeField>::Repr: Abomonation,
<<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

0 comments on commit 47c9608

Please sign in to comment.