diff --git a/r1cs-std/src/bits/boolean.rs b/r1cs-std/src/bits/boolean.rs index 33697ea..f70ba1c 100644 --- a/r1cs-std/src/bits/boolean.rs +++ b/r1cs-std/src/bits/boolean.rs @@ -201,7 +201,7 @@ impl AllocatedBit { impl PartialEq for AllocatedBit { fn eq(&self, other: &Self) -> bool { - !self.value.is_none() && !other.value.is_none() && self.value == other.value + self.value.is_some() && other.value.is_some() && self.value == other.value } } diff --git a/r1cs-std/src/bits/uint32.rs b/r1cs-std/src/bits/uint32.rs index a1fb5c2..9fa4f56 100644 --- a/r1cs-std/src/bits/uint32.rs +++ b/r1cs-std/src/bits/uint32.rs @@ -312,7 +312,7 @@ impl ToBytesGadget for UInt32 { impl PartialEq for UInt32 { fn eq(&self, other: &Self) -> bool { - !self.value.is_none() && !other.value.is_none() && self.value == other.value + self.value.is_some() && other.value.is_some() && self.value == other.value } } diff --git a/r1cs-std/src/bits/uint8.rs b/r1cs-std/src/bits/uint8.rs index 77568f6..5ca819a 100644 --- a/r1cs-std/src/bits/uint8.rs +++ b/r1cs-std/src/bits/uint8.rs @@ -183,7 +183,7 @@ impl UInt8 { impl PartialEq for UInt8 { fn eq(&self, other: &Self) -> bool { - !self.value.is_none() && !other.value.is_none() && self.value == other.value + self.value.is_some() && other.value.is_some() && self.value == other.value } } diff --git a/r1cs-std/src/fields/fp.rs b/r1cs-std/src/fields/fp.rs index 3bbe6ec..169b70d 100644 --- a/r1cs-std/src/fields/fp.rs +++ b/r1cs-std/src/fields/fp.rs @@ -275,7 +275,7 @@ impl FieldGadget for FpGadget { impl PartialEq for FpGadget { fn eq(&self, other: &Self) -> bool { - !self.value.is_none() && !other.value.is_none() && self.value == other.value + self.value.is_some() && other.value.is_some() && self.value == other.value } } diff --git a/r1cs-std/src/groups/curves/twisted_edwards/mod.rs b/r1cs-std/src/groups/curves/twisted_edwards/mod.rs index 02731d3..0d05e9f 100644 --- a/r1cs-std/src/groups/curves/twisted_edwards/mod.rs +++ b/r1cs-std/src/groups/curves/twisted_edwards/mod.rs @@ -58,15 +58,13 @@ mod montgomery_affine_impl { ) -> Result<(P::BaseField, P::BaseField), SynthesisError> { let montgomery_point: GroupAffine

= if p.y == P::BaseField::one() { GroupAffine::zero() + } else if p.x == P::BaseField::zero() { + GroupAffine::new(P::BaseField::zero(), P::BaseField::zero()) } else { - if p.x == P::BaseField::zero() { - GroupAffine::new(P::BaseField::zero(), P::BaseField::zero()) - } else { - let u = (P::BaseField::one() + &p.y) - * &(P::BaseField::one() - &p.y).inverse().unwrap(); - let v = u * &p.x.inverse().unwrap(); - GroupAffine::new(u, v) - } + let u = (P::BaseField::one() + &p.y) + * &(P::BaseField::one() - &p.y).inverse().unwrap(); + let v = u * &p.x.inverse().unwrap(); + GroupAffine::new(u, v) }; Ok((montgomery_point.x, montgomery_point.y))