mirror of
https://github.com/saymrwulf/risc0-curve25519-dalek-source.git
synced 2026-09-05 20:10:35 +00:00
Change AVX2 backend to use width-8 tables
This commit is contained in:
parent
62d43752df
commit
6b768c2a1a
3 changed files with 3392 additions and 75 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -22,7 +22,7 @@ use subtle::ConditionallyAssignable;
|
|||
use subtle::Choice;
|
||||
|
||||
use edwards;
|
||||
use scalar_mul::window::{LookupTable, NafLookupTable5};
|
||||
use scalar_mul::window::{LookupTable, NafLookupTable5, NafLookupTable8};
|
||||
|
||||
use traits::Identity;
|
||||
|
||||
|
|
@ -307,6 +307,19 @@ impl<'a> From<&'a edwards::EdwardsPoint> for NafLookupTable5<CachedPoint> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a edwards::EdwardsPoint> for NafLookupTable8<CachedPoint> {
|
||||
fn from(point: &'a edwards::EdwardsPoint) -> Self {
|
||||
let A = ExtendedPoint::from(*point);
|
||||
let mut Ai = [CachedPoint::from(A); 64];
|
||||
let A2 = A.double();
|
||||
for i in 0..63 {
|
||||
Ai[i + 1] = (&A2 + &Ai[i]).into();
|
||||
}
|
||||
// Now Ai = [A, 3A, 5A, 7A, 9A, 11A, 13A, 15A, ..., 127A]
|
||||
NafLookupTable8(Ai)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use backend::avx2::constants::BASEPOINT_ODD_LOOKUP_TABLE;
|
|||
/// Compute \\(aA + bB\\) in variable time, where \\(B\\) is the Ed25519 basepoint.
|
||||
pub fn mul(a: &Scalar, A: &EdwardsPoint, b: &Scalar) -> EdwardsPoint {
|
||||
let a_naf = a.non_adjacent_form(5);
|
||||
let b_naf = b.non_adjacent_form(5);
|
||||
let b_naf = b.non_adjacent_form(8);
|
||||
|
||||
// Find starting index
|
||||
let mut i: usize = 255;
|
||||
|
|
|
|||
Loading…
Reference in a new issue