Rename X25519 basepoint to X25519_BASEPOINT_MONTGOMERY

This commit is contained in:
Henry de Valence 2018-01-29 14:36:45 -08:00
parent ae46ecd445
commit 1d480a8a71
2 changed files with 10 additions and 10 deletions

View file

@ -51,7 +51,7 @@ pub const ED25519_BASEPOINT_COMPRESSED: CompressedEdwardsY =
0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66]);
/// The X25519 basepoint, in compressed Montgomery form.
pub const BASE_COMPRESSED_MONTGOMERY: CompressedMontgomeryU =
pub const X25519_BASEPOINT_COMPRESSED: CompressedMontgomeryU =
CompressedMontgomeryU([0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

View file

@ -395,7 +395,7 @@ impl<'a, 'b> Mul<&'b MontgomeryPoint> for &'a Scalar {
#[cfg(test)]
mod test {
use constants::BASE_COMPRESSED_MONTGOMERY;
use constants::X25519_BASEPOINT_COMPRESSED;
use traits::Identity;
use super::*;
@ -405,13 +405,13 @@ mod test {
#[test]
fn basepoint_to_montgomery() {
assert_eq!(constants::ED25519_BASEPOINT_POINT.to_montgomery().compress(),
BASE_COMPRESSED_MONTGOMERY);
X25519_BASEPOINT_COMPRESSED);
}
/// Test Montgomery conversion against the X25519 basepoint.
#[test]
fn basepoint_from_montgomery() {
assert_eq!(BASE_COMPRESSED_MONTGOMERY,
assert_eq!(X25519_BASEPOINT_COMPRESSED,
constants::ED25519_BASEPOINT_COMPRESSED.decompress().unwrap().to_montgomery().compress());
}
@ -438,8 +438,8 @@ mod test {
#[test]
fn projective_to_affine_roundtrips() {
assert_eq!(BASE_COMPRESSED_MONTGOMERY.decompress().compress(),
BASE_COMPRESSED_MONTGOMERY);
assert_eq!(X25519_BASEPOINT_COMPRESSED.decompress().compress(),
X25519_BASEPOINT_COMPRESSED);
}
@ -483,7 +483,7 @@ mod test {
#[test]
fn ladder_basepoint_times_two_matches_double() {
let two: Scalar = Scalar::from_u64(2u64);
let result: MontgomeryPoint = &BASE_COMPRESSED_MONTGOMERY.decompress() * &two;
let result: MontgomeryPoint = &X25519_BASEPOINT_COMPRESSED.decompress() * &two;
let expected: EdwardsPoint = constants::ED25519_BASEPOINT_POINT.double();
assert_eq!(result.compress(), expected.to_montgomery().compress());
@ -495,7 +495,7 @@ mod test {
mod bench {
use rand::OsRng;
use constants::ED25519_BASEPOINT_TABLE;
use constants::BASE_COMPRESSED_MONTGOMERY;
use constants::X25519_BASEPOINT_COMPRESSED;
use test::Bencher;
use super::*;
@ -512,12 +512,12 @@ mod bench {
#[bench]
fn montgomery_decompress(b: &mut Bencher) {
b.iter(| | BASE_COMPRESSED_MONTGOMERY.decompress());
b.iter(| | X25519_BASEPOINT_COMPRESSED.decompress());
}
#[bench]
fn montgomery_compress(b: &mut Bencher) {
let p: MontgomeryPoint = BASE_COMPRESSED_MONTGOMERY.decompress();
let p: MontgomeryPoint = X25519_BASEPOINT_COMPRESSED.decompress();
b.iter(| | p.compress());
}