Switch to stable cargo formatting options

This commit is contained in:
Pratyush Mishra
2020-04-07 16:11:56 -07:00
parent 456f30a849
commit 33a9da08f8
40 changed files with 402 additions and 408 deletions

View File

@@ -111,14 +111,14 @@ impl<F: PrimeField> FpGadget<F> {
Ordering::Less => {
left = a;
right = b;
},
}
Ordering::Greater => {
left = b;
right = a;
},
}
Ordering::Equal => {
return Err(SynthesisError::Unsatisfiable);
},
}
};
let right_for_check = if should_also_check_equality {
right.add_constant(cs.ns(|| "plus one"), &F::one())?
@@ -252,7 +252,7 @@ mod test {
true,
)
.unwrap();
},
}
Ordering::Greater => {
a_var
.enforce_cmp(
@@ -270,8 +270,8 @@ mod test {
true,
)
.unwrap();
},
_ => {},
}
_ => {}
}
if i == 0 {
@@ -300,7 +300,7 @@ mod test {
true,
)
.unwrap();
},
}
Ordering::Greater => {
a_var
.enforce_cmp(
@@ -318,8 +318,8 @@ mod test {
true,
)
.unwrap();
},
_ => {},
}
_ => {}
}
assert!(!cs.is_satisfied());

View File

@@ -13,7 +13,7 @@ pub mod cmp;
#[derive(Debug)]
pub struct FpGadget<F: PrimeField> {
pub value: Option<F>,
pub value: Option<F>,
pub variable: ConstraintVar<F>,
}
@@ -364,7 +364,7 @@ impl<F: PrimeField> ToBitsGadget<F> for FpGadget<F> {
assert_eq!(tmp.len(), num_bits as usize);
tmp
},
}
None => vec![None; num_bits as usize],
};
@@ -422,7 +422,7 @@ impl<F: PrimeField> ToBytesGadget<F> for FpGadget<F> {
let default = F::default();
let default_len = to_bytes![&default].unwrap().len();
vec![None; default_len]
},
}
};
let bytes = UInt8::alloc_vec(cs.ns(|| "Alloc bytes"), &byte_values)?;
@@ -438,7 +438,7 @@ impl<F: PrimeField> ToBytesGadget<F> for FpGadget<F> {
Boolean::Is(bit) => {
lc += (coeff, bit.get_variable());
coeff.double_in_place();
},
}
Boolean::Constant(_) | Boolean::Not(_) => unreachable!(),
}
}
@@ -577,7 +577,7 @@ impl<F: PrimeField> ThreeBitCondNegLookupGadget<F> for FpGadget<F> {
impl<F: PrimeField> Clone for FpGadget<F> {
fn clone(&self) -> Self {
Self {
value: self.value.clone(),
value: self.value.clone(),
variable: self.variable.clone(),
}
}

View File

@@ -31,8 +31,8 @@ where
P: Fp12Parameters,
<P::Fp6Params as Fp6Parameters>::Fp2Params: Fp2Parameters<Fp = ConstraintF>,
{
pub c0: Fp6Gadget<P, ConstraintF>,
pub c1: Fp6Gadget<P, ConstraintF>,
pub c0: Fp6Gadget<P, ConstraintF>,
pub c1: Fp6Gadget<P, ConstraintF>,
#[derivative(Debug = "ignore")]
_params: PhantomData<P>,
}
@@ -847,7 +847,7 @@ where
Ok(fe) => {
let fe = *fe.borrow();
(Ok(fe.c0), Ok(fe.c1))
},
}
Err(_) => (
Err(SynthesisError::AssignmentMissing),
Err(SynthesisError::AssignmentMissing),
@@ -872,7 +872,7 @@ where
Ok(fe) => {
let fe = *fe.borrow();
(Ok(fe.c0), Ok(fe.c1))
},
}
Err(_) => (
Err(SynthesisError::AssignmentMissing),
Err(SynthesisError::AssignmentMissing),

View File

@@ -11,8 +11,8 @@ use crate::{fields::fp::FpGadget, prelude::*, Vec};
#[derivative(Debug(bound = "P: Fp2Parameters, ConstraintF: PrimeField"))]
#[must_use]
pub struct Fp2Gadget<P: Fp2Parameters<Fp = ConstraintF>, ConstraintF: PrimeField> {
pub c0: FpGadget<ConstraintF>,
pub c1: FpGadget<ConstraintF>,
pub c0: FpGadget<ConstraintF>,
pub c1: FpGadget<ConstraintF>,
#[derivative(Debug = "ignore")]
_params: PhantomData<P>,
}
@@ -526,8 +526,8 @@ impl<P: Fp2Parameters<Fp = ConstraintF>, ConstraintF: PrimeField> Clone
{
fn clone(&self) -> Self {
Self {
c0: self.c0.clone(),
c1: self.c1.clone(),
c0: self.c0.clone(),
c1: self.c1.clone(),
_params: PhantomData,
}
}
@@ -624,7 +624,7 @@ impl<P: Fp2Parameters<Fp = ConstraintF>, ConstraintF: PrimeField> AllocGadget<Fp
Ok(fe) => {
let fe = *fe.borrow();
(Ok(fe.c0), Ok(fe.c1))
},
}
Err(_) => (
Err(SynthesisError::AssignmentMissing),
Err(SynthesisError::AssignmentMissing),
@@ -649,7 +649,7 @@ impl<P: Fp2Parameters<Fp = ConstraintF>, ConstraintF: PrimeField> AllocGadget<Fp
Ok(fe) => {
let fe = *fe.borrow();
(Ok(fe.c0), Ok(fe.c1))
},
}
Err(_) => (
Err(SynthesisError::AssignmentMissing),
Err(SynthesisError::AssignmentMissing),

View File

@@ -14,9 +14,9 @@ use crate::{fields::fp::FpGadget, prelude::*, Vec};
#[must_use]
pub struct Fp3Gadget<P: Fp3Parameters<Fp = ConstraintF>, ConstraintF: PrimeField + SquareRootField>
{
pub c0: FpGadget<ConstraintF>,
pub c1: FpGadget<ConstraintF>,
pub c2: FpGadget<ConstraintF>,
pub c0: FpGadget<ConstraintF>,
pub c1: FpGadget<ConstraintF>,
pub c2: FpGadget<ConstraintF>,
#[derivative(Debug = "ignore")]
_params: PhantomData<P>,
}
@@ -880,7 +880,7 @@ impl<P: Fp3Parameters<Fp = ConstraintF>, ConstraintF: PrimeField + SquareRootFie
Ok(fe) => {
let fe = *fe.borrow();
(Ok(fe.c0), Ok(fe.c1), Ok(fe.c2))
},
}
_ => (
Err(SynthesisError::AssignmentMissing),
Err(SynthesisError::AssignmentMissing),
@@ -907,7 +907,7 @@ impl<P: Fp3Parameters<Fp = ConstraintF>, ConstraintF: PrimeField + SquareRootFie
Ok(fe) => {
let fe = *fe.borrow();
(Ok(fe.c0), Ok(fe.c1), Ok(fe.c2))
},
}
_ => (
Err(SynthesisError::AssignmentMissing),
Err(SynthesisError::AssignmentMissing),

View File

@@ -22,8 +22,8 @@ where
P: Fp4Parameters,
P::Fp2Params: Fp2Parameters<Fp = ConstraintF>,
{
pub c0: Fp2Gadget<P, ConstraintF>,
pub c1: Fp2Gadget<P, ConstraintF>,
pub c0: Fp2Gadget<P, ConstraintF>,
pub c1: Fp2Gadget<P, ConstraintF>,
#[derivative(Debug = "ignore")]
_params: PhantomData<P>,
}
@@ -569,8 +569,8 @@ where
{
fn clone(&self) -> Self {
Self {
c0: self.c0.clone(),
c1: self.c1.clone(),
c0: self.c0.clone(),
c1: self.c1.clone(),
_params: PhantomData,
}
}
@@ -686,7 +686,7 @@ where
Ok(fe) => {
let fe = *fe.borrow();
(Ok(fe.c0), Ok(fe.c1))
},
}
Err(_) => (
Err(SynthesisError::AssignmentMissing),
Err(SynthesisError::AssignmentMissing),
@@ -711,7 +711,7 @@ where
Ok(fe) => {
let fe = *fe.borrow();
(Ok(fe.c0), Ok(fe.c1))
},
}
Err(_) => (
Err(SynthesisError::AssignmentMissing),
Err(SynthesisError::AssignmentMissing),

View File

@@ -25,8 +25,8 @@ where
P: Fp6Parameters,
P::Fp3Params: Fp3Parameters<Fp = ConstraintF>,
{
pub c0: Fp3Gadget<P, ConstraintF>,
pub c1: Fp3Gadget<P, ConstraintF>,
pub c0: Fp3Gadget<P, ConstraintF>,
pub c1: Fp3Gadget<P, ConstraintF>,
#[derivative(Debug = "ignore")]
_params: PhantomData<P>,
}
@@ -557,8 +557,8 @@ where
{
fn clone(&self) -> Self {
Self {
c0: self.c0.clone(),
c1: self.c1.clone(),
c0: self.c0.clone(),
c1: self.c1.clone(),
_params: PhantomData,
}
}
@@ -677,7 +677,7 @@ where
Ok(fe) => {
let fe = *fe.borrow();
(Ok(fe.c0), Ok(fe.c1))
},
}
Err(_) => (
Err(SynthesisError::AssignmentMissing),
Err(SynthesisError::AssignmentMissing),
@@ -702,7 +702,7 @@ where
Ok(fe) => {
let fe = *fe.borrow();
(Ok(fe.c0), Ok(fe.c1))
},
}
Err(_) => (
Err(SynthesisError::AssignmentMissing),
Err(SynthesisError::AssignmentMissing),

View File

@@ -21,9 +21,9 @@ where
P: Fp6Parameters,
P::Fp2Params: Fp2Parameters<Fp = ConstraintF>,
{
pub c0: Fp2Gadget<P, ConstraintF>,
pub c1: Fp2Gadget<P, ConstraintF>,
pub c2: Fp2Gadget<P, ConstraintF>,
pub c0: Fp2Gadget<P, ConstraintF>,
pub c1: Fp2Gadget<P, ConstraintF>,
pub c2: Fp2Gadget<P, ConstraintF>,
#[derivative(Debug = "ignore")]
_params: PhantomData<P>,
}
@@ -977,7 +977,7 @@ where
Ok(fe) => {
let fe = *fe.borrow();
(Ok(fe.c0), Ok(fe.c1), Ok(fe.c2))
},
}
_ => (
Err(SynthesisError::AssignmentMissing),
Err(SynthesisError::AssignmentMissing),
@@ -1004,7 +1004,7 @@ where
Ok(fe) => {
let fe = *fe.borrow();
(Ok(fe.c0), Ok(fe.c1), Ok(fe.c2))
},
}
_ => (
Err(SynthesisError::AssignmentMissing),
Err(SynthesisError::AssignmentMissing),