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

@@ -10,6 +10,8 @@ pub struct Fr(FrRepr);
use rand_core::SeedableRng;
#[cfg(test)]
use rand_xorshift::XorShiftRng;
#[cfg(test)]
use std::ops::Neg;
#[test]
fn test_fr_repr_ordering() {
@@ -767,10 +769,9 @@ fn test_fr_double() {
}
#[test]
fn test_fr_negate() {
fn test_fr_neg() {
{
let mut a = Fr::zero();
a.negate();
let a = Fr::zero().neg();
assert!(a.is_zero());
}
@@ -783,8 +784,7 @@ fn test_fr_negate() {
for _ in 0..1000 {
// Ensure (a - (-a)) = 0.
let mut a = Fr::random(&mut rng);
let mut b = a;
b.negate();
let b = a.neg();
a.add_assign(&b);
assert!(a.is_zero());
@@ -832,8 +832,7 @@ fn test_fr_sqrt() {
for _ in 0..1000 {
// Ensure sqrt(a^2) = a or -a
let a = Fr::random(&mut rng);
let mut nega = a;
nega.negate();
let nega = a.neg();
let mut b = a;
b.square();