mirror of
https://github.com/saymrwulf/risc0-curve25519-dalek-source.git
synced 2026-09-04 20:03:40 +00:00
Use scalar_mul instead of scalar_mult
This commit is contained in:
parent
70eee5208a
commit
2e73b2bc20
3 changed files with 16 additions and 16 deletions
|
|
@ -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]);
|
||||
|
|
@ -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
|
||||
|
|
@ -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]);
|
||||
|
|
@ -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]);
|
||||
|
|
@ -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]);
|
||||
|
|
@ -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();
|
||||
|
|
@ -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);
|
||||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
@ -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() {
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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();
|
||||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
|
|
|
|||
Loading…
Reference in a new issue