mirror of
https://github.com/arnaucube/ark-r1cs-std.git
synced 2026-01-12 00:41:32 +01:00
Runs cargo fmt
This commit is contained in:
committed by
Pratyush Mishra
parent
98416f6b2e
commit
fb87c421e7
@@ -1,12 +1,12 @@
|
||||
use std::{fmt::Debug, marker::PhantomData};
|
||||
|
||||
use crate::crh::{
|
||||
FixedLengthCRHGadget,
|
||||
injective_map::{InjectiveMap, PedersenCRHCompressor, TECompressor},
|
||||
pedersen::{
|
||||
PedersenWindow,
|
||||
constraints::{PedersenCRHGadget, PedersenCRHGadgetParameters},
|
||||
}
|
||||
PedersenWindow,
|
||||
},
|
||||
FixedLengthCRHGadget,
|
||||
};
|
||||
|
||||
use algebra::{
|
||||
@@ -24,7 +24,13 @@ use r1cs_std::{
|
||||
prelude::*,
|
||||
};
|
||||
|
||||
pub trait InjectiveMapGadget<G: Group, I: InjectiveMap<G>, ConstraintF: Field, GG: GroupGadget<G, ConstraintF>> {
|
||||
pub trait InjectiveMapGadget<
|
||||
G: Group,
|
||||
I: InjectiveMap<G>,
|
||||
ConstraintF: Field,
|
||||
GG: GroupGadget<G, ConstraintF>,
|
||||
>
|
||||
{
|
||||
type OutputGadget: EqGadget<ConstraintF>
|
||||
+ ToBytesGadget<ConstraintF>
|
||||
+ CondSelectGadget<ConstraintF>
|
||||
@@ -41,8 +47,13 @@ pub trait InjectiveMapGadget<G: Group, I: InjectiveMap<G>, ConstraintF: Field, G
|
||||
|
||||
pub struct TECompressorGadget;
|
||||
|
||||
impl<ConstraintF, P> InjectiveMapGadget<TEAffine<P>, TECompressor, ConstraintF, TwistedEdwardsGadget<P, ConstraintF, FpGadget<ConstraintF>>>
|
||||
for TECompressorGadget
|
||||
impl<ConstraintF, P>
|
||||
InjectiveMapGadget<
|
||||
TEAffine<P>,
|
||||
TECompressor,
|
||||
ConstraintF,
|
||||
TwistedEdwardsGadget<P, ConstraintF, FpGadget<ConstraintF>>,
|
||||
> for TECompressorGadget
|
||||
where
|
||||
ConstraintF: PrimeField + SquareRootField,
|
||||
P: TEModelParameters + ModelParameters<BaseField = ConstraintF>,
|
||||
@@ -58,8 +69,12 @@ where
|
||||
}
|
||||
|
||||
impl<ConstraintF, P>
|
||||
InjectiveMapGadget<TEProjective<P>, TECompressor, ConstraintF, TwistedEdwardsGadget<P, ConstraintF, FpGadget<ConstraintF>>>
|
||||
for TECompressorGadget
|
||||
InjectiveMapGadget<
|
||||
TEProjective<P>,
|
||||
TECompressor,
|
||||
ConstraintF,
|
||||
TwistedEdwardsGadget<P, ConstraintF, FpGadget<ConstraintF>>,
|
||||
> for TECompressorGadget
|
||||
where
|
||||
ConstraintF: PrimeField + SquareRootField,
|
||||
P: TEModelParameters + ModelParameters<BaseField = ConstraintF>,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use crate::CryptoError;
|
||||
use crate::{CryptoError, Error};
|
||||
use algebra::bytes::ToBytes;
|
||||
use crate::Error;
|
||||
use rand::Rng;
|
||||
use std::{fmt::Debug, hash::Hash, marker::PhantomData};
|
||||
|
||||
@@ -17,7 +16,6 @@ use algebra::{
|
||||
groups::Group,
|
||||
};
|
||||
|
||||
|
||||
#[cfg(feature = "r1cs")]
|
||||
pub mod constraints;
|
||||
|
||||
|
||||
@@ -7,13 +7,11 @@ pub mod pedersen;
|
||||
|
||||
use crate::Error;
|
||||
|
||||
|
||||
#[cfg(feature = "r1cs")]
|
||||
pub mod constraints;
|
||||
#[cfg(feature = "r1cs")]
|
||||
pub use constraints::*;
|
||||
|
||||
|
||||
pub trait FixedLengthCRH {
|
||||
const INPUT_SIZE_BITS: usize;
|
||||
type Output: ToBytes + Clone + Eq + Hash + Default;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
use crate::crh::{
|
||||
FixedLengthCRHGadget,
|
||||
pedersen::{PedersenCRH, PedersenParameters, PedersenWindow},
|
||||
FixedLengthCRHGadget,
|
||||
};
|
||||
use algebra::{Field, Group};
|
||||
use r1cs_core::{ConstraintSystem, SynthesisError};
|
||||
@@ -27,14 +26,15 @@ pub struct PedersenCRHGadgetParameters<
|
||||
|
||||
pub struct PedersenCRHGadget<G: Group, ConstraintF: Field, GG: GroupGadget<G, ConstraintF>> {
|
||||
#[doc(hideen)]
|
||||
_group: PhantomData<*const G>,
|
||||
_group: PhantomData<*const G>,
|
||||
#[doc(hideen)]
|
||||
_group_gadget: PhantomData<*const GG>,
|
||||
#[doc(hideen)]
|
||||
_engine: PhantomData<ConstraintF>,
|
||||
_engine: PhantomData<ConstraintF>,
|
||||
}
|
||||
|
||||
impl<ConstraintF, G, GG, W> FixedLengthCRHGadget<PedersenCRH<G, W>, ConstraintF> for PedersenCRHGadget<G, ConstraintF, GG>
|
||||
impl<ConstraintF, G, GG, W> FixedLengthCRHGadget<PedersenCRH<G, W>, ConstraintF>
|
||||
for PedersenCRHGadget<G, ConstraintF, GG>
|
||||
where
|
||||
ConstraintF: Field,
|
||||
G: Group,
|
||||
@@ -74,9 +74,13 @@ where
|
||||
}
|
||||
|
||||
impl<G: Group, W: PedersenWindow, ConstraintF: Field, GG: GroupGadget<G, ConstraintF>>
|
||||
AllocGadget<PedersenParameters<G>, ConstraintF> for PedersenCRHGadgetParameters<G, W, ConstraintF, GG>
|
||||
AllocGadget<PedersenParameters<G>, ConstraintF>
|
||||
for PedersenCRHGadgetParameters<G, W, ConstraintF, GG>
|
||||
{
|
||||
fn alloc<F, T, CS: ConstraintSystem<ConstraintF>>(_cs: CS, value_gen: F) -> Result<Self, SynthesisError>
|
||||
fn alloc<F, T, CS: ConstraintSystem<ConstraintF>>(
|
||||
_cs: CS,
|
||||
value_gen: F,
|
||||
) -> Result<Self, SynthesisError>
|
||||
where
|
||||
F: FnOnce() -> Result<T, SynthesisError>,
|
||||
T: Borrow<PedersenParameters<G>>,
|
||||
@@ -114,16 +118,14 @@ mod test {
|
||||
use rand::{thread_rng, Rng};
|
||||
|
||||
use crate::crh::{
|
||||
pedersen::{PedersenCRH, PedersenWindow},
|
||||
pedersen::constraints::PedersenCRHGadget,
|
||||
FixedLengthCRH,
|
||||
FixedLengthCRHGadget
|
||||
pedersen::{constraints::PedersenCRHGadget, PedersenCRH, PedersenWindow},
|
||||
FixedLengthCRH, FixedLengthCRHGadget,
|
||||
};
|
||||
use algebra::curves::{jubjub::JubJubProjective as JubJub, ProjectiveCurve};
|
||||
use r1cs_core::ConstraintSystem;
|
||||
use r1cs_std::{
|
||||
groups::curves::twisted_edwards::jubjub::JubJubGadget,
|
||||
test_constraint_system::TestConstraintSystem, prelude::*,
|
||||
groups::curves::twisted_edwards::jubjub::JubJubGadget, prelude::*,
|
||||
test_constraint_system::TestConstraintSystem,
|
||||
};
|
||||
|
||||
type TestCRH = PedersenCRH<JubJub, Window>;
|
||||
|
||||
@@ -7,9 +7,7 @@ use std::{
|
||||
};
|
||||
|
||||
use crate::crh::FixedLengthCRH;
|
||||
use algebra::{Field, ToConstraintField};
|
||||
use algebra::groups::Group;
|
||||
|
||||
use algebra::{groups::Group, Field, ToConstraintField};
|
||||
|
||||
#[cfg(feature = "r1cs")]
|
||||
pub mod constraints;
|
||||
@@ -141,8 +139,9 @@ impl<G: Group> Debug for PedersenParameters<G> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl<ConstraintF: Field, G: Group + ToConstraintField<ConstraintF>> ToConstraintField<ConstraintF> for PedersenParameters<G> {
|
||||
impl<ConstraintF: Field, G: Group + ToConstraintField<ConstraintF>> ToConstraintField<ConstraintF>
|
||||
for PedersenParameters<G>
|
||||
{
|
||||
#[inline]
|
||||
fn to_field_elements(&self) -> Result<Vec<ConstraintF>, Error> {
|
||||
Ok(Vec::new())
|
||||
|
||||
Reference in New Issue
Block a user