-
Notifications
You must be signed in to change notification settings - Fork 3
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 #50 from Yoii-Inc/feat/r1cs_for_pedersen_commitment
Feat/r1cs for pedersen commitment
- Loading branch information
Showing
52 changed files
with
7,494 additions
and
769 deletions.
There are no files selected for viewing
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,25 @@ | ||
use ark_ff::UniformRand; | ||
use ark_std::rand::Rng; | ||
use ark_std::{fmt::Debug, hash::Hash}; | ||
|
||
use ark_ff::bytes::ToBytes; | ||
|
||
pub mod constraints; | ||
pub mod pedersen; | ||
|
||
use ark_crypto_primitives::Error; | ||
|
||
pub trait CommitmentScheme { | ||
type Input; | ||
type Output: ToBytes + Clone + Default + Eq + Hash + Debug; | ||
type Parameters: Clone; | ||
type Randomness: Clone + ToBytes + Default + Eq + UniformRand + Debug; | ||
|
||
fn setup<R: Rng>(r: &mut R) -> Result<Self::Parameters, Error>; | ||
|
||
fn commit( | ||
parameters: &Self::Parameters, | ||
input: &Self::Input, | ||
r: &Self::Randomness, | ||
) -> Result<Self::Output, Error>; | ||
} |
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,23 @@ | ||
use crate::commitment::CommitmentScheme; | ||
use ark_ff::PrimeField; | ||
use ark_r1cs_std::{alloc::AllocVar, R1CSVar, ToBytesGadget}; | ||
use ark_relations::r1cs::SynthesisError; | ||
use core::fmt::Debug; | ||
|
||
pub trait CommitmentGadget<C: CommitmentScheme, ConstraintF: PrimeField> { | ||
type OutputVar: ToBytesGadget<ConstraintF> | ||
+ AllocVar<C::Output, ConstraintF> | ||
+ R1CSVar<ConstraintF> | ||
+ Clone | ||
+ Sized | ||
+ Debug; | ||
type ParametersVar: AllocVar<C::Parameters, ConstraintF> + Clone; | ||
type RandomnessVar: AllocVar<C::Randomness, ConstraintF> + Clone; | ||
type InputVar: AllocVar<C::Input, ConstraintF> + Clone; | ||
|
||
fn commit( | ||
parameters: &Self::ParametersVar, | ||
input: &Self::InputVar, | ||
r: &Self::RandomnessVar, | ||
) -> Result<Self::OutputVar, SynthesisError>; | ||
} |
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,5 @@ | ||
pub mod pedersen; | ||
pub use pedersen::*; | ||
pub mod constraints; | ||
pub use constraints::*; | ||
pub mod local_pedersen; |
Oops, something went wrong.