mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-04 20:24:10 +00:00
Eliminate vector constants from edwards module
This commit is contained in:
parent
cc8728b2a6
commit
25d9f3f6ca
3 changed files with 21 additions and 20 deletions
|
|
@ -16,6 +16,24 @@ use backend::avx2::edwards::{CachedPoint, ExtendedPoint};
|
|||
use backend::avx2::field::FieldElement32x4;
|
||||
use scalar_mul::window::NafLookupTable8;
|
||||
|
||||
/// The identity element as an `ExtendedPoint`.
|
||||
pub(crate) static EXTENDEDPOINT_IDENTITY: ExtendedPoint = ExtendedPoint(FieldElement32x4([
|
||||
u32x8::new(0, 1, 0, 0, 1, 0, 0, 0),
|
||||
u32x8::splat(0),
|
||||
u32x8::splat(0),
|
||||
u32x8::splat(0),
|
||||
u32x8::splat(0),
|
||||
]));
|
||||
|
||||
/// The identity element as a `CachedPoint`.
|
||||
pub(crate) static CACHEDPOINT_IDENTITY: CachedPoint = CachedPoint(FieldElement32x4([
|
||||
u32x8::new(121647, 121666, 0, 0, 243332, 67108845, 0, 33554431),
|
||||
u32x8::new(67108864, 0, 33554431, 0, 0, 67108863, 0, 33554431),
|
||||
u32x8::new(67108863, 0, 33554431, 0, 0, 67108863, 0, 33554431),
|
||||
u32x8::new(67108863, 0, 33554431, 0, 0, 67108863, 0, 33554431),
|
||||
u32x8::new(67108863, 0, 33554431, 0, 0, 67108863, 0, 33554431),
|
||||
]));
|
||||
|
||||
/// The low limbs of (2p, 2p, 2p, 2p), so that
|
||||
/// ```no_run
|
||||
/// (2p, 2p, 2p, 2p) = [P_TIMES_2_LO, P_TIMES_2_HI, P_TIMES_2_HI, P_TIMES_2_HI, P_TIMES_2_HI]
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@
|
|||
use core::convert::From;
|
||||
use core::ops::{Add, Neg, Sub};
|
||||
|
||||
use core::simd::{u32x8, IntoBits};
|
||||
|
||||
use subtle::Choice;
|
||||
use subtle::ConditionallyAssignable;
|
||||
|
||||
|
|
@ -27,8 +25,7 @@ use scalar_mul::window::{LookupTable, NafLookupTable5, NafLookupTable8};
|
|||
use traits::Identity;
|
||||
|
||||
use backend::avx2::field::{FieldElement32x4, Lanes, Shuffle};
|
||||
|
||||
use backend::avx2;
|
||||
use backend::avx2::constants;
|
||||
|
||||
/// A point on Curve25519, represented in an AVX2-friendly format.
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
|
|
@ -66,13 +63,7 @@ impl Default for ExtendedPoint {
|
|||
|
||||
impl Identity for ExtendedPoint {
|
||||
fn identity() -> ExtendedPoint {
|
||||
ExtendedPoint(FieldElement32x4([
|
||||
u32x8::new(0, 1, 0, 0, 1, 0, 0, 0),
|
||||
u32x8::splat(0),
|
||||
u32x8::splat(0),
|
||||
u32x8::splat(0),
|
||||
u32x8::splat(0),
|
||||
]))
|
||||
constants::EXTENDEDPOINT_IDENTITY
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -172,13 +163,7 @@ impl Default for CachedPoint {
|
|||
|
||||
impl Identity for CachedPoint {
|
||||
fn identity() -> CachedPoint {
|
||||
CachedPoint(FieldElement32x4([
|
||||
u32x8::new(121647, 121666, 0, 0, 243332, 67108845, 0, 33554431),
|
||||
u32x8::new(67108864, 0, 33554431, 0, 0, 67108863, 0, 33554431),
|
||||
u32x8::new(67108863, 0, 33554431, 0, 0, 67108863, 0, 33554431),
|
||||
u32x8::new(67108863, 0, 33554431, 0, 0, 67108863, 0, 33554431),
|
||||
u32x8::new(67108863, 0, 33554431, 0, 0, 67108863, 0, 33554431),
|
||||
]))
|
||||
constants::CACHEDPOINT_IDENTITY
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -526,8 +526,6 @@ impl FieldElement32x4 {
|
|||
///
|
||||
/// Limbs must be bounded by bit-excess \\( b < 2.0 \\).
|
||||
pub fn square_and_negate_D(&self) -> FieldElement32x4 {
|
||||
let neg_mask = D_LANES64;
|
||||
|
||||
#[inline(always)]
|
||||
fn m(x: u32x8, y: u32x8) -> u64x4 {
|
||||
use core::arch::x86_64::_mm256_mul_epu32;
|
||||
|
|
|
|||
Loading…
Reference in a new issue