mirror of
https://github.com/arnaucube/ark-r1cs-std.git
synced 2026-01-11 08:21:30 +01:00
Simplify a few "if" structures
This commit is contained in:
committed by
Pratyush Mishra
parent
53a51eb4dc
commit
b42d5f8d36
@@ -201,7 +201,7 @@ impl AllocatedBit {
|
|||||||
|
|
||||||
impl PartialEq for AllocatedBit {
|
impl PartialEq for AllocatedBit {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -312,7 +312,7 @@ impl<ConstraintF: Field> ToBytesGadget<ConstraintF> for UInt32 {
|
|||||||
|
|
||||||
impl PartialEq for UInt32 {
|
impl PartialEq for UInt32 {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ impl UInt8 {
|
|||||||
|
|
||||||
impl PartialEq for UInt8 {
|
impl PartialEq for UInt8 {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -275,7 +275,7 @@ impl<F: PrimeField> FieldGadget<F, F> for FpGadget<F> {
|
|||||||
|
|
||||||
impl<F: PrimeField> PartialEq for FpGadget<F> {
|
impl<F: PrimeField> PartialEq for FpGadget<F> {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,15 +58,13 @@ mod montgomery_affine_impl {
|
|||||||
) -> Result<(P::BaseField, P::BaseField), SynthesisError> {
|
) -> Result<(P::BaseField, P::BaseField), SynthesisError> {
|
||||||
let montgomery_point: GroupAffine<P> = if p.y == P::BaseField::one() {
|
let montgomery_point: GroupAffine<P> = if p.y == P::BaseField::one() {
|
||||||
GroupAffine::zero()
|
GroupAffine::zero()
|
||||||
|
} else if p.x == P::BaseField::zero() {
|
||||||
|
GroupAffine::new(P::BaseField::zero(), P::BaseField::zero())
|
||||||
} else {
|
} else {
|
||||||
if p.x == P::BaseField::zero() {
|
let u = (P::BaseField::one() + &p.y)
|
||||||
GroupAffine::new(P::BaseField::zero(), P::BaseField::zero())
|
* &(P::BaseField::one() - &p.y).inverse().unwrap();
|
||||||
} else {
|
let v = u * &p.x.inverse().unwrap();
|
||||||
let u = (P::BaseField::one() + &p.y)
|
GroupAffine::new(u, v)
|
||||||
* &(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))
|
Ok((montgomery_point.x, montgomery_point.y))
|
||||||
|
|||||||
Reference in New Issue
Block a user