mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-04 20:24:10 +00:00
Add benchmarks for Mongomery point (de)compression and laddering.
This commit is contained in:
parent
2939d26b5c
commit
6be10341e2
1 changed files with 30 additions and 1 deletions
|
|
@ -512,6 +512,35 @@ mod test {
|
|||
let expected: ExtendedPoint = constants::ED25519_BASEPOINT_POINT.double();
|
||||
|
||||
assert_eq!(result.compress(), expected.to_montgomery().compress());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(test, feature = "bench"))]
|
||||
mod bench {
|
||||
use rand::OsRng;
|
||||
use constants::ED25519_BASEPOINT_TABLE;
|
||||
use constants::BASE_COMPRESSED_MONTGOMERY;
|
||||
use test::Bencher;
|
||||
use super::*;
|
||||
|
||||
#[bench]
|
||||
fn montgomery_decompress(b: &mut Bencher) {
|
||||
b.iter(| | BASE_COMPRESSED_MONTGOMERY.decompress());
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn montgomery_compress(b: &mut Bencher) {
|
||||
let p: MontgomeryPoint = BASE_COMPRESSED_MONTGOMERY.decompress();
|
||||
|
||||
b.iter(| | p.compress());
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn montgomery_ladder(b: &mut Bencher) {
|
||||
let mut csprng: OsRng = OsRng::new().unwrap();
|
||||
let s: Scalar = Scalar::random(&mut csprng);
|
||||
let p: MontgomeryPoint = (&Scalar::random(&mut csprng) * &ED25519_BASEPOINT_TABLE).to_montgomery();
|
||||
|
||||
b.iter(| | &s * &p);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue