mirror of
https://github.com/saymrwulf/betrusted-curve25519-dalek-source.git
synced 2026-09-05 20:30:54 +00:00
Test basepoint multiple generation
This commit is contained in:
parent
187d4d3c09
commit
46bf69b80e
1 changed files with 24 additions and 0 deletions
|
|
@ -108,6 +108,10 @@ pub const bi: [PreComputedPoint; 8] = [
|
|||
},
|
||||
];
|
||||
|
||||
/// Table containing precomputed multiples of the basepoint `B = (x,4/5)`.
|
||||
///
|
||||
/// The table is defined so `constants::base[i][j-1] = j*(16^2i)*B`,
|
||||
/// for `0 ≤ i < 32`, `1 ≤ j < 9`.
|
||||
pub const base: [[PreComputedPoint; 8]; 32] = [
|
||||
[
|
||||
PreComputedPoint{
|
||||
|
|
@ -1457,6 +1461,7 @@ pub const base: [[PreComputedPoint; 8]; 32] = [
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
use field::FieldElement;
|
||||
use curve::PreComputedPoint;
|
||||
use constants;
|
||||
|
||||
#[test]
|
||||
|
|
@ -1477,4 +1482,23 @@ mod test {
|
|||
assert_eq!(d, constants::d);
|
||||
assert_eq!(d2, constants::d2);
|
||||
}
|
||||
|
||||
/// Test the values in the lookup table of precomputed multiples
|
||||
/// of the basepoint.
|
||||
#[test]
|
||||
fn test_precomputed_basepoint_multiples() {
|
||||
let bp = constants::BASE_CMPRSSD.decompress().unwrap();
|
||||
let mut P = bp;
|
||||
for i in 0..32 {
|
||||
// P = (16^2)^i * B
|
||||
let mut jP = P.to_precomputed();
|
||||
for j in 1..9 {
|
||||
// constants::base[i][j-1] is supposed to be
|
||||
// j * (16^2)^i * B
|
||||
assert_eq!(constants::base[i][j-1], jP);
|
||||
jP = (&P + &jP).to_extended().to_precomputed();
|
||||
}
|
||||
P = P.mult_by_pow_2(8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue