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

Cycle of curves #184

Merged
merged 17 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from 16 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
19 changes: 17 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 24 additions & 2 deletions groth16/src/circuit.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
use crate::error::Error;
use bn_254::{Fq, Fr, G1Affine};
use grumpkin::params::PARAM_B3 as GRUMPKIN_PARAM_B3;
use zkstd::circuit::CircuitDriver;

use grumpkin::driver::GrumpkinDriver;
use zkstd::circuit::prelude::R1cs;
use zkstd::common::Debug;

/// circuit trait
pub trait Circuit: Default + Debug {
fn synthesize(&self, constraint_system: &mut R1cs<GrumpkinDriver>) -> Result<(), Error>;
fn synthesize(&self, constraint_system: &mut R1cs<Bn254Driver>) -> Result<(), Error>;
}

#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct Bn254Driver;

impl CircuitDriver for Bn254Driver {
const ORDER_STR: &'static str =
"30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001";
const BASE_STR: &'static str =
"30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47";
const NUM_BITS: u16 = 254;
type Affine = G1Affine;

type Base = Fq;

type Scalar = Fr;

fn b3() -> Self::Scalar {
GRUMPKIN_PARAM_B3
}
}
5 changes: 2 additions & 3 deletions groth16/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ pub use zksnark::ZkSnark;

#[cfg(test)]
mod tests {
use crate::circuit::Circuit;
use crate::circuit::{Bn254Driver, Circuit};
use crate::error::Error;
use crate::zksnark::ZkSnark;

use bn_254::Fr as BnScalar;
use grumpkin::driver::GrumpkinDriver;
use zkstd::circuit::prelude::{FieldAssignment, R1cs};
use zkstd::common::OsRng;

Expand All @@ -50,7 +49,7 @@ mod tests {
}

impl Circuit for DummyCircuit {
fn synthesize(&self, composer: &mut R1cs<GrumpkinDriver>) -> Result<(), Error> {
fn synthesize(&self, composer: &mut R1cs<Bn254Driver>) -> Result<(), Error> {
let x = FieldAssignment::instance(composer, self.x);
let o = FieldAssignment::instance(composer, self.o);
let c = FieldAssignment::constant(&BnScalar::from(5));
Expand Down
19 changes: 0 additions & 19 deletions grumpkin/src/driver.rs

This file was deleted.

1 change: 0 additions & 1 deletion grumpkin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#![allow(clippy::suspicious_arithmetic_impl)]

mod curve;
pub mod driver;
pub mod params;

pub use curve::{Affine, Projective};
4 changes: 3 additions & 1 deletion nova/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ bn-254 = { path = "../bn254", default-features = false }
grumpkin = { path = "../grumpkin", default-features = false }
zkgroth16 = { path = "../groth16", default-features = false }
serde = { version = "1.0.102", default-features = false, features = ["derive"] }
num-bigint = { version = "0.4", features = ["serde", "rand"] }
num-traits = "0.2"
blake2b_simd = { version = "1", default-features = false }
rand_core = { version="0.6.4", default-features = false, features = ["getrandom"] }

[dev-dependencies]
rand_core = { version="0.6.4", default-features = false, features = ["getrandom"] }
grumpkin = { path = "../grumpkin", default-features = false }

[features]
Expand Down
Loading
Loading