Move from Field::negate to Neg operator

This commit is contained in:
Jack Grigg
2019-12-12 22:52:17 +00:00
parent 4a3350bc31
commit 91c32f1c7c
26 changed files with 175 additions and 189 deletions

View File

@@ -2,7 +2,7 @@
use ff::Field;
use pairing::Engine;
use std::ops::{AddAssign, MulAssign, SubAssign};
use std::ops::{AddAssign, MulAssign, Neg, SubAssign};
use bellman::{ConstraintSystem, SynthesisError};
@@ -367,7 +367,7 @@ impl<E: JubjubEngine> EdwardsPoint<E> {
let y3 = AllocatedNum::alloc(cs.namespace(|| "y3"), || {
let mut t0 = *a.get_value().get()?;
t0.double();
t0.negate();
t0 = t0.neg();
t0.add_assign(t.get_value().get()?);
let mut t1 = E::Fr::one();
@@ -642,7 +642,7 @@ impl<E: JubjubEngine> MontgomeryPoint<E> {
t0.sub_assign(self.x.get_value().get()?);
t0.mul_assign(lambda.get_value().get()?);
t0.add_assign(self.y.get_value().get()?);
t0.negate();
t0 = t0.neg();
Ok(t0)
})?;

View File

@@ -5,7 +5,7 @@ use bellman::{
use ff::Field;
use pairing::bls12_381::{Bls12, Fr};
use rand_core::OsRng;
use std::ops::AddAssign;
use std::ops::{AddAssign, Neg};
use zcash_primitives::{
jubjub::{edwards, fs::Fs, FixedGenerators, JubjubBls12, Unknown},
primitives::{Diversifier, Note, PaymentAddress, ProofGenerationKey, ValueCommitment},
@@ -202,8 +202,7 @@ impl SaplingProvingContext {
// Accumulate the value commitment randomness in the context
{
let mut tmp = rcv;
tmp.negate(); // Outputs subtract from the total.
let mut tmp = rcv.neg(); // Outputs subtract from the total.
tmp.add_assign(&self.bsk);
// Update the context