mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-06 20:41:14 +00:00
errata and basepoint_odd_lookup_table test for better understanding
This commit is contained in:
parent
f6015c66c2
commit
8da05f7e90
4 changed files with 24 additions and 4 deletions
|
|
@ -327,7 +327,7 @@ There are several directions for future improvement:
|
||||||
[sandy2x]: https://eprint.iacr.org/2015/943.pdf
|
[sandy2x]: https://eprint.iacr.org/2015/943.pdf
|
||||||
[avx2trac]: https://trac.torproject.org/projects/tor/ticket/8897#comment:28
|
[avx2trac]: https://trac.torproject.org/projects/tor/ticket/8897#comment:28
|
||||||
[hwcd08]: https://www.iacr.org/archive/asiacrypt2008/53500329/53500329.pdf
|
[hwcd08]: https://www.iacr.org/archive/asiacrypt2008/53500329/53500329.pdf
|
||||||
[curve_models]: https://doc-internal.dalek.rs/curve25519_dalek/curve_models/index.html
|
[curve_models]: https://doc-internal.dalek.rs/curve25519_dalek/backend/serial/curve_models/index.html
|
||||||
[bbjlp08]: https://eprint.iacr.org/2008/013
|
[bbjlp08]: https://eprint.iacr.org/2008/013
|
||||||
[cmo98]: https://link.springer.com/content/pdf/10.1007%2F3-540-49649-1_6.pdf
|
[cmo98]: https://link.springer.com/content/pdf/10.1007%2F3-540-49649-1_6.pdf
|
||||||
[intel]: https://software.intel.com/sites/default/files/managed/9e/bc/64-ia-32-architectures-optimization-manual.pdf
|
[intel]: https://software.intel.com/sites/default/files/managed/9e/bc/64-ia-32-architectures-optimization-manual.pdf
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ use traits::Identity;
|
||||||
|
|
||||||
use super::constants;
|
use super::constants;
|
||||||
use super::field::{FieldElement2625x4, Lanes, Shuffle};
|
use super::field::{FieldElement2625x4, Lanes, Shuffle};
|
||||||
|
use backend::vector::avx2::constants::{BASEPOINT_ODD_LOOKUP_TABLE};
|
||||||
|
|
||||||
/// A point on Curve25519, using parallel Edwards formulas for curve
|
/// A point on Curve25519, using parallel Edwards formulas for curve
|
||||||
/// operations.
|
/// operations.
|
||||||
|
|
@ -188,7 +189,7 @@ impl From<ExtendedPoint> for CachedPoint {
|
||||||
let mut x = P.0;
|
let mut x = P.0;
|
||||||
|
|
||||||
x = x.blend(x.diff_sum(), Lanes::AB);
|
x = x.blend(x.diff_sum(), Lanes::AB);
|
||||||
// x = (X1 - Y1, X2 + Y2, Z2, T2) = (S2 S3 Z2 T2)
|
// x = (Y2 - X2, Y2 + X2, Z2, T2) = (S2 S3 Z2 T2)
|
||||||
|
|
||||||
x = x * (121666, 121666, 2 * 121666, 2 * 121665);
|
x = x * (121666, 121666, 2 * 121666, 2 * 121665);
|
||||||
// x = (121666*S2 121666*S3 2*121666*Z2 2*121665*T2)
|
// x = (121666*S2 121666*S3 2*121666*Z2 2*121665*T2)
|
||||||
|
|
@ -521,4 +522,23 @@ mod test {
|
||||||
let P = &constants::ED25519_BASEPOINT_TABLE * &Scalar::from(8475983829u64);
|
let P = &constants::ED25519_BASEPOINT_TABLE * &Scalar::from(8475983829u64);
|
||||||
doubling_test_helper(P);
|
doubling_test_helper(P);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn basepoint_odd_lookup_table_verify() {
|
||||||
|
use constants;
|
||||||
|
|
||||||
|
let basepoint_odd_table = NafLookupTable8::<CachedPoint>::from(&constants::ED25519_BASEPOINT_POINT);
|
||||||
|
println!("basepoint_odd_lookup_table = {:?}", basepoint_odd_table);
|
||||||
|
|
||||||
|
let table_B = &BASEPOINT_ODD_LOOKUP_TABLE;
|
||||||
|
for (b_vec, base_vec) in table_B.0.iter().zip(basepoint_odd_table.0.iter()) {
|
||||||
|
let b_splits = b_vec.0.split();
|
||||||
|
let base_splits = base_vec.0.split();
|
||||||
|
|
||||||
|
assert_eq!(base_splits[0], b_splits[0]);
|
||||||
|
assert_eq!(base_splits[1], b_splits[1]);
|
||||||
|
assert_eq!(base_splits[2], b_splits[2]);
|
||||||
|
assert_eq!(base_splits[3], b_splits[3]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
// missing).
|
// missing).
|
||||||
#![cfg_attr(
|
#![cfg_attr(
|
||||||
all(feature = "nightly", feature = "stage2_build"),
|
all(feature = "nightly", feature = "stage2_build"),
|
||||||
doc(include = "../docs/avx2-notes.md")
|
doc(include = "../../../../docs/avx2-notes.md")
|
||||||
)]
|
)]
|
||||||
|
|
||||||
pub(crate) mod field;
|
pub(crate) mod field;
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
// missing).
|
// missing).
|
||||||
#![cfg_attr(
|
#![cfg_attr(
|
||||||
all(feature = "nightly", feature = "stage2_build"),
|
all(feature = "nightly", feature = "stage2_build"),
|
||||||
doc(include = "../docs/parallel-formulas.md")
|
doc(include = "../../../docs/parallel-formulas.md")
|
||||||
)]
|
)]
|
||||||
|
|
||||||
#[cfg(not(any(target_feature = "avx2", target_feature = "avx512ifma", rustdoc)))]
|
#[cfg(not(any(target_feature = "avx2", target_feature = "avx512ifma", rustdoc)))]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue