Runs cargo fmt

This commit is contained in:
Kobi Gurkan
2019-10-21 14:18:35 +03:00
committed by Pratyush Mishra
parent 98416f6b2e
commit fb87c421e7
26 changed files with 284 additions and 240 deletions

View File

@@ -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>,

View File

@@ -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;

View File

@@ -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;

View File

@@ -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>;

View File

@@ -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())