mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-07 20:50:39 +00:00
Try to connect the AVX2 backend to the ExtendedPoint frontend
This commit is contained in:
parent
77766b3422
commit
97fe2f0bf4
3 changed files with 40 additions and 29 deletions
1
build.rs
1
build.rs
|
|
@ -1,4 +1,5 @@
|
||||||
#![cfg_attr(feature = "nightly", feature(i128_type))]
|
#![cfg_attr(feature = "nightly", feature(i128_type))]
|
||||||
|
#![cfg_attr(feature = "nightly", feature(cfg_target_feature))]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
|
||||||
|
|
@ -432,6 +432,14 @@ impl<'a, 'b> Mul<&'b Scalar> for &'a ExtendedPoint {
|
||||||
/// For scalar multiplication of a basepoint,
|
/// For scalar multiplication of a basepoint,
|
||||||
/// `EdwardsBasepointTable` is approximately 4x faster.
|
/// `EdwardsBasepointTable` is approximately 4x faster.
|
||||||
fn mul(self, scalar: &'b Scalar) -> ExtendedPoint {
|
fn mul(self, scalar: &'b Scalar) -> ExtendedPoint {
|
||||||
|
// If we built with AVX2, use the AVX2 backend.
|
||||||
|
#[cfg(all(target_feature = "avx2", feature = "avx2_backend"))] {
|
||||||
|
use backend::avx2::edwards as edwards_avx2;
|
||||||
|
let P_avx2 = edwards_avx2::ExtendedPoint::from(*self);
|
||||||
|
return ExtendedPoint::from(&P_avx2 * scalar);
|
||||||
|
}
|
||||||
|
// Otherwise, proceed as normal:
|
||||||
|
#[cfg(not(all(target_feature = "avx2", feature = "avx2_backend")))] {
|
||||||
// Construct a lookup table of [P,2P,3P,4P,5P,6P,7P,8P]
|
// Construct a lookup table of [P,2P,3P,4P,5P,6P,7P,8P]
|
||||||
let P = self.to_projective_niels();
|
let P = self.to_projective_niels();
|
||||||
let mut lookup_table: [ProjectiveNielsPoint; 8] = [P; 8];
|
let mut lookup_table: [ProjectiveNielsPoint; 8] = [P; 8];
|
||||||
|
|
@ -466,6 +474,7 @@ impl<'a, 'b> Mul<&'b Scalar> for &'a ExtendedPoint {
|
||||||
Q
|
Q
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a, 'b> Mul<&'b ExtendedPoint> for &'a Scalar {
|
impl<'a, 'b> Mul<&'b ExtendedPoint> for &'a Scalar {
|
||||||
type Output = ExtendedPoint;
|
type Output = ExtendedPoint;
|
||||||
|
|
|
||||||
|
|
@ -11,11 +11,12 @@
|
||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
#![cfg_attr(feature = "alloc", feature(alloc))]
|
#![cfg_attr(feature = "alloc", feature(alloc))]
|
||||||
#![cfg_attr(feature = "nightly", feature(i128_type))]
|
#![cfg_attr(feature = "nightly", feature(i128_type))]
|
||||||
|
#![cfg_attr(feature = "nightly", feature(cfg_target_feature))]
|
||||||
#![cfg_attr(feature = "bench", feature(test))]
|
#![cfg_attr(feature = "bench", feature(test))]
|
||||||
#![cfg_attr(all(feature = "nightly", feature = "std"), feature(zero_one))]
|
#![cfg_attr(all(feature = "nightly", feature = "std"), feature(zero_one))]
|
||||||
|
|
||||||
#![allow(unused_features)]
|
#![allow(unused_features)]
|
||||||
//#![deny(missing_docs)] // refuse to compile if documentation is missing
|
#![deny(missing_docs)] // refuse to compile if documentation is missing
|
||||||
|
|
||||||
//! # curve25519-dalek
|
//! # curve25519-dalek
|
||||||
//!
|
//!
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue