-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #179 from KogarashiNetwork/feature/nova-gadget
init NIFS circuit and gadget
- Loading branch information
Showing
52 changed files
with
856 additions
and
452 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ members = [ | |
"groth16", | ||
"grumpkin", | ||
"nova", | ||
"r1cs", | ||
"zkstd", | ||
] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use crate::params::PARAM_B3; | ||
use bn_254::{Fq, Fr, G1Affine}; | ||
use zkstd::circuit::CircuitDriver; | ||
|
||
#[derive(Clone, Debug, Default, PartialEq, Eq)] | ||
pub struct GrumpkinDriver; | ||
|
||
impl CircuitDriver for GrumpkinDriver { | ||
const NUM_BITS: u16 = 254; | ||
type Affine = G1Affine; | ||
|
||
type Base = Fq; | ||
|
||
type Scalar = Fr; | ||
|
||
fn b3() -> Self::Scalar { | ||
PARAM_B3 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
mod nifs; | ||
mod transcript; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use core::marker::PhantomData; | ||
|
||
use zkstd::circuit::prelude::{CircuitDriver, R1cs}; | ||
|
||
pub(crate) struct NifsCircuit<C: CircuitDriver> { | ||
p: PhantomData<C>, | ||
} | ||
|
||
impl<C: CircuitDriver> NifsCircuit<C> { | ||
pub(crate) fn verify(cs: &mut R1cs<C>) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
mod mimc; | ||
mod relaxed_r1cs; | ||
|
||
pub(crate) use mimc::MimcAssignment; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use crate::hash::Mimc; | ||
|
||
use zkstd::circuit::prelude::{CircuitDriver, FieldAssignment, R1cs}; | ||
|
||
pub(crate) struct MimcAssignment<const ROUND: usize, C: CircuitDriver> { | ||
constants: [C::Scalar; ROUND], | ||
} | ||
|
||
impl<const ROUND: usize, C: CircuitDriver> Default for MimcAssignment<ROUND, C> { | ||
fn default() -> Self { | ||
Self { | ||
constants: Mimc::<ROUND, C::Scalar>::default().constants, | ||
} | ||
} | ||
} | ||
|
||
impl<const ROUND: usize, C: CircuitDriver> MimcAssignment<ROUND, C> { | ||
pub(crate) fn hash( | ||
&self, | ||
cs: &mut R1cs<C>, | ||
mut xl: FieldAssignment<C>, | ||
mut xr: FieldAssignment<C>, | ||
) -> FieldAssignment<C> { | ||
for c in self.constants.iter().map(|c| FieldAssignment::constant(c)) { | ||
let cxl = &xl + &c; | ||
let mut ccxl = FieldAssignment::square(cs, &cxl); | ||
ccxl = &FieldAssignment::mul(cs, &ccxl, &cxl) + &xr; | ||
xr = xl; | ||
xl = ccxl; | ||
} | ||
xl | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use crate::relaxed_r1cs::RelaxedR1csInstance; | ||
|
||
use zkstd::circuit::prelude::{CircuitDriver, FieldAssignment, PointAssignment, R1cs}; | ||
|
||
pub(crate) struct RelaxedR1csAssignment<C: CircuitDriver> { | ||
pub(crate) commit_w: PointAssignment<C>, | ||
pub(crate) commit_e: PointAssignment<C>, | ||
pub(crate) u: FieldAssignment<C>, | ||
pub(crate) x: Vec<FieldAssignment<C>>, | ||
} | ||
|
||
impl<C: CircuitDriver> RelaxedR1csAssignment<C> { | ||
pub(crate) fn witness(cs: &mut R1cs<C>, relaxed_r1cs: RelaxedR1csInstance<C>) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.