mirror of
https://github.com/Qortal/pirate-librustzcash.git
synced 2025-07-30 20:11:23 +00:00
Move from Curve*::negate to Neg operator
This commit is contained in:
@@ -134,6 +134,19 @@ macro_rules! curve_impl {
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::ops::Neg for $affine {
|
||||
type Output = Self;
|
||||
|
||||
#[inline]
|
||||
fn neg(self) -> Self {
|
||||
let mut ret = self;
|
||||
if !ret.is_zero() {
|
||||
ret.y = ret.y.neg();
|
||||
}
|
||||
ret
|
||||
}
|
||||
}
|
||||
|
||||
impl CurveAffine for $affine {
|
||||
type Engine = Bls12;
|
||||
type Scalar = $scalarfield;
|
||||
@@ -163,12 +176,6 @@ macro_rules! curve_impl {
|
||||
self.mul_bits(bits)
|
||||
}
|
||||
|
||||
fn negate(&mut self) {
|
||||
if !self.is_zero() {
|
||||
self.y = self.y.neg();
|
||||
}
|
||||
}
|
||||
|
||||
fn into_projective(&self) -> $projective {
|
||||
(*self).into()
|
||||
}
|
||||
@@ -188,6 +195,19 @@ macro_rules! curve_impl {
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::ops::Neg for $projective {
|
||||
type Output = Self;
|
||||
|
||||
#[inline]
|
||||
fn neg(self) -> Self {
|
||||
let mut ret = self;
|
||||
if !ret.is_zero() {
|
||||
ret.y = ret.y.neg();
|
||||
}
|
||||
ret
|
||||
}
|
||||
}
|
||||
|
||||
impl<'r> ::std::ops::Add<&'r $projective> for $projective {
|
||||
type Output = Self;
|
||||
|
||||
@@ -324,9 +344,7 @@ macro_rules! curve_impl {
|
||||
|
||||
impl<'r> ::std::ops::SubAssign<&'r $projective> for $projective {
|
||||
fn sub_assign(&mut self, other: &Self) {
|
||||
let mut tmp = *other;
|
||||
tmp.negate();
|
||||
self.add_assign(&tmp);
|
||||
self.add_assign(&other.neg());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -566,12 +584,6 @@ macro_rules! curve_impl {
|
||||
}
|
||||
}
|
||||
|
||||
fn negate(&mut self) {
|
||||
if !self.is_zero() {
|
||||
self.y = self.y.neg();
|
||||
}
|
||||
}
|
||||
|
||||
fn mul_assign<S: Into<<Self::Scalar as PrimeField>::Repr>>(&mut self, other: S) {
|
||||
let mut res = Self::zero();
|
||||
|
||||
|
Reference in New Issue
Block a user