Change from `cache` to `to_niels`.
This commit is contained in:
parent
f467cd32f2
commit
bed8a7d369
|
@ -6,36 +6,54 @@ extern crate test;
|
||||||
use jubjub::*;
|
use jubjub::*;
|
||||||
use test::Bencher;
|
use test::Bencher;
|
||||||
|
|
||||||
|
// Non-Niels
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
fn bench_point_doubling(bencher: &mut Bencher) {
|
fn bench_point_doubling(bencher: &mut Bencher) {
|
||||||
let a = ExtendedPoint::identity();
|
let a = ExtendedPoint::identity();
|
||||||
bencher.iter(move || a.double());
|
bencher.iter(move || a.double());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[bench]
|
||||||
|
fn bench_point_addition(bencher: &mut Bencher) {
|
||||||
|
let a = ExtendedPoint::identity();
|
||||||
|
let b = -ExtendedPoint::identity();
|
||||||
|
bencher.iter(move || a + b);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[bench]
|
||||||
|
fn bench_point_subtraction(bencher: &mut Bencher) {
|
||||||
|
let a = ExtendedPoint::identity();
|
||||||
|
let b = -ExtendedPoint::identity();
|
||||||
|
bencher.iter(move || a + b);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Niels
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
fn bench_cached_point_addition(bencher: &mut Bencher) {
|
fn bench_cached_point_addition(bencher: &mut Bencher) {
|
||||||
let a = ExtendedPoint::identity();
|
let a = ExtendedPoint::identity();
|
||||||
let b = ExtendedPoint::identity().cache();
|
let b = ExtendedPoint::identity().to_niels();
|
||||||
bencher.iter(move || &a + &b);
|
bencher.iter(move || &a + &b);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
fn bench_cached_affine_point_subtraction(bencher: &mut Bencher) {
|
fn bench_cached_affine_point_subtraction(bencher: &mut Bencher) {
|
||||||
let a = ExtendedPoint::identity();
|
let a = ExtendedPoint::identity();
|
||||||
let b = AffinePoint::identity().cache();
|
let b = AffinePoint::identity().to_niels();
|
||||||
bencher.iter(move || &a + &b);
|
bencher.iter(move || &a + &b);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
fn bench_cached_point_subtraction(bencher: &mut Bencher) {
|
fn bench_cached_point_subtraction(bencher: &mut Bencher) {
|
||||||
let a = ExtendedPoint::identity();
|
let a = ExtendedPoint::identity();
|
||||||
let b = ExtendedPoint::identity().cache();
|
let b = ExtendedPoint::identity().to_niels();
|
||||||
bencher.iter(move || &a + &b);
|
bencher.iter(move || &a + &b);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
fn bench_cached_affine_point_addition(bencher: &mut Bencher) {
|
fn bench_cached_affine_point_addition(bencher: &mut Bencher) {
|
||||||
let a = ExtendedPoint::identity();
|
let a = ExtendedPoint::identity();
|
||||||
let b = AffinePoint::identity().cache();
|
let b = AffinePoint::identity().to_niels();
|
||||||
bencher.iter(move || &a + &b);
|
bencher.iter(move || &a + &b);
|
||||||
}
|
}
|
||||||
|
|
|
@ -244,7 +244,7 @@ impl AffinePoint {
|
||||||
self.v
|
self.v
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cache(&self) -> AffineNielsPoint {
|
pub fn to_niels(&self) -> AffineNielsPoint {
|
||||||
AffineNielsPoint {
|
AffineNielsPoint {
|
||||||
v_plus_u: &self.v + &self.u,
|
v_plus_u: &self.v + &self.u,
|
||||||
v_minus_u: &self.v - &self.u,
|
v_minus_u: &self.v - &self.u,
|
||||||
|
@ -275,7 +275,7 @@ impl ExtendedPoint {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cache(&self) -> ExtendedNielsPoint {
|
pub fn to_niels(&self) -> ExtendedNielsPoint {
|
||||||
ExtendedNielsPoint {
|
ExtendedNielsPoint {
|
||||||
v_plus_u: &self.v + &self.u,
|
v_plus_u: &self.v + &self.u,
|
||||||
v_minus_u: &self.v - &self.u,
|
v_minus_u: &self.v - &self.u,
|
||||||
|
@ -481,7 +481,7 @@ impl<'a, 'b> Add<&'b ExtendedPoint> for &'a ExtendedPoint {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn add(self, other: &'b ExtendedPoint) -> ExtendedPoint {
|
fn add(self, other: &'b ExtendedPoint) -> ExtendedPoint {
|
||||||
self + other.cache()
|
self + other.to_niels()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -490,7 +490,7 @@ impl<'a, 'b> Sub<&'b ExtendedPoint> for &'a ExtendedPoint {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn sub(self, other: &'b ExtendedPoint) -> ExtendedPoint {
|
fn sub(self, other: &'b ExtendedPoint) -> ExtendedPoint {
|
||||||
self - other.cache()
|
self - other.to_niels()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue