Skip to content

Commit

Permalink
Use scalar_mul instead of scalar_mult
Browse files Browse the repository at this point in the history
  • Loading branch information
hdevalence committed Mar 22, 2018
1 parent 70eee52 commit 2e73b2b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions src/backend/avx2/edwards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ mod test {
}

#[test]
fn scalar_mult_vs_edwards_scalar_mult() {
fn scalar_mul_vs_edwards_scalar_mul() {
let B: ExtendedPoint = constants::ED25519_BASEPOINT_POINT.into();
// some random bytes
let s = Scalar::from_bits([233, 1, 233, 147, 113, 78, 244, 120, 40, 45, 103, 51, 224, 199, 189, 218, 96, 140, 211, 112, 39, 194, 73, 216, 173, 33, 102, 93, 76, 200, 84, 12]);
Expand All @@ -867,7 +867,7 @@ mod test {
}

#[test]
fn scalar_mult_vs_basepoint_table_scalar_mult() {
fn scalar_mul_vs_basepoint_table_scalar_mul() {
let B: ExtendedPoint = constants::ED25519_BASEPOINT_POINT.into();
let B_table = EdwardsBasepointTable::create(&B);
// some random bytes
Expand All @@ -881,7 +881,7 @@ mod test {
}

#[test]
fn multiscalar_mul_vs_adding_scalar_mults() {
fn multiscalar_mul_vs_adding_scalar_muls() {
let B: ExtendedPoint = constants::ED25519_BASEPOINT_POINT.into();
let s1 = Scalar::from_bits([233, 1, 233, 147, 113, 78, 244, 120, 40, 45, 103, 51, 224, 199, 189, 218, 96, 140, 211, 112, 39, 194, 73, 216, 173, 33, 102, 93, 76, 200, 84, 12]);
let s2 = Scalar::from_bits([165, 30, 79, 89, 58, 24, 195, 245, 248, 146, 203, 236, 119, 43, 64, 119, 196, 111, 188, 251, 248, 53, 234, 59, 215, 28, 218, 13, 59, 120, 14, 4]);
Expand All @@ -901,7 +901,7 @@ mod test {
use super::*;

#[test]
fn multiscalar_mul_vs_adding_scalar_mults() {
fn multiscalar_mul_vs_adding_scalar_muls() {
let B: ExtendedPoint = constants::ED25519_BASEPOINT_POINT.into();
let s1 = Scalar::from_bits([233, 1, 233, 147, 113, 78, 244, 120, 40, 45, 103, 51, 224, 199, 189, 218, 96, 140, 211, 112, 39, 194, 73, 216, 173, 33, 102, 93, 76, 200, 84, 12]);
let s2 = Scalar::from_bits([165, 30, 79, 89, 58, 24, 195, 245, 248, 146, 203, 236, 119, 43, 64, 119, 196, 111, 188, 251, 248, 53, 234, 59, 215, 28, 218, 13, 59, 120, 14, 4]);
Expand Down Expand Up @@ -971,7 +971,7 @@ mod bench {
}

#[bench]
fn scalar_mult(b: &mut Bencher) {
fn scalar_mul(b: &mut Bencher) {
let B = &constants::ED25519_BASEPOINT_TABLE;
let P = ExtendedPoint::from(B * &Scalar::from_u64(83973422));
let s = Scalar::from_bits([233, 1, 233, 147, 113, 78, 244, 120, 40, 45, 103, 51, 224, 199, 189, 218, 96, 140, 211, 112, 39, 194, 73, 216, 173, 33, 102, 93, 76, 200, 84, 12]);
Expand All @@ -996,7 +996,7 @@ mod bench {
}

#[bench]
fn ten_fold_scalar_mult(b: &mut Bencher) {
fn ten_fold_scalar_mul(b: &mut Bencher) {
let mut csprng: OsRng = OsRng::new().unwrap();
// Create 10 random scalars
let scalars: Vec<_> = (0..10).map(|_| Scalar::random(&mut csprng)).collect();
Expand All @@ -1012,7 +1012,7 @@ mod bench {
use super::{constants, Bencher, OsRng};

#[bench]
fn double_scalar_mult(b: &mut Bencher) {
fn double_scalar_mul(b: &mut Bencher) {
let mut csprng: OsRng = OsRng::new().unwrap();
// Create 2 random scalars
let s1 = Scalar::random(&mut csprng);
Expand All @@ -1023,7 +1023,7 @@ mod bench {
}

#[bench]
fn ten_fold_scalar_mult(b: &mut Bencher) {
fn ten_fold_scalar_mul(b: &mut Bencher) {
let mut csprng: OsRng = OsRng::new().unwrap();
// Create 10 random scalars
let scalars: Vec<_> = (0..10).map(|_| Scalar::random(&mut csprng)).collect();
Expand Down
14 changes: 7 additions & 7 deletions src/edwards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1245,9 +1245,9 @@ mod test {
assert_eq!(aB_1.compress(), aB_2.compress());
}

/// Test scalar_mult versus a known scalar multiple from ed25519.py
/// Test scalar_mul versus a known scalar multiple from ed25519.py
#[test]
fn scalar_mult_vs_ed25519py() {
fn scalar_mul_vs_ed25519py() {
let aB = &constants::ED25519_BASEPOINT_POINT * &A_SCALAR;
assert_eq!(aB.compress(), A_TIMES_BASEPOINT);
}
Expand Down Expand Up @@ -1331,7 +1331,7 @@ mod test {
#[test]
fn monte_carlo_overflow_underflow_debug_assert_test() {
let mut P = constants::ED25519_BASEPOINT_POINT;
// N.B. each scalar_mult does 1407 field mults, 1024 field squarings,
// N.B. each scalar_mul does 1407 field mults, 1024 field squarings,
// so this does ~ 1M of each operation.
for _ in 0..1_000 {
P *= &A_SCALAR;
Expand All @@ -1353,7 +1353,7 @@ mod test {
use super::super::*;
use super::{A_SCALAR, B_SCALAR, A_TIMES_BASEPOINT, DOUBLE_SCALAR_MULT_RESULT};

/// Test double_scalar_mult_vartime vs ed25519.py
/// Test double_scalar_mul_vartime vs ed25519.py
#[test]
#[cfg(feature="precomputed_tables")]
fn double_scalar_mul_basepoint_vs_ed25519py() {
Expand Down Expand Up @@ -1443,7 +1443,7 @@ mod bench {
}

#[bench]
fn scalar_mult(b: &mut Bencher) {
fn scalar_mul(b: &mut Bencher) {
let B = &constants::ED25519_BASEPOINT_POINT;
b.iter(|| B * &A_SCALAR);
}
Expand Down Expand Up @@ -1518,7 +1518,7 @@ mod bench {

#[bench]
#[cfg(feature="precomputed_tables")]
fn ten_fold_scalar_mult(b: &mut Bencher) {
fn ten_fold_scalar_mul(b: &mut Bencher) {
let mut csprng: OsRng = OsRng::new().unwrap();
// Create 10 random scalars
let scalars: Vec<_> = (0..10).map(|_| Scalar::random(&mut csprng)).collect();
Expand All @@ -1542,7 +1542,7 @@ mod bench {

#[bench]
#[cfg(feature="precomputed_tables")]
fn ten_fold_scalar_mult(b: &mut Bencher) {
fn ten_fold_scalar_mul(b: &mut Bencher) {
let mut csprng: OsRng = OsRng::new().unwrap();
// Create 10 random scalars
let scalars: Vec<_> = (0..10).map(|_| Scalar::random(&mut csprng)).collect();
Expand Down
2 changes: 1 addition & 1 deletion src/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ mod test {
}

#[test]
fn scalar_multiply_by_one() {
fn scalar_mul_by_one() {
let test_scalar = &X * &Scalar::one();
for i in 0..32 {
assert!(test_scalar[i] == X[i]);
Expand Down

0 comments on commit 2e73b2b

Please sign in to comment.