Skip to content

Commit

Permalink
apply changes from upstream to forked crate
Browse files Browse the repository at this point in the history
  • Loading branch information
jmwample committed Jul 26, 2024
1 parent 7fc2968 commit 4ea0f59
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
10 changes: 10 additions & 0 deletions curve25519-elligator2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,13 @@ digest = ["dep:digest", "elligator2"]

[target.'cfg(all(not(curve25519_dalek_backend = "fiat"), not(curve25519_dalek_backend = "serial"), target_arch = "x86_64"))'.dependencies]
curve25519-dalek-derive = { version = "0.1.1" }

[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = [
'cfg(allow_unused_unsafe)',
'cfg(curve25519_dalek_backend, values("fiat", "serial", "simd"))',
'cfg(curve25519_dalek_diagnostics, values("build"))',
'cfg(curve25519_dalek_bits, values("32", "64"))',
'cfg(nightly)',
]
7 changes: 5 additions & 2 deletions curve25519-elligator2/src/backend/serial/u32/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use core::fmt::Debug;
use core::ops::{Index, IndexMut};
use subtle::{Choice, ConditionallySelectable};

#[cfg(feature = "zeroize")]
use zeroize::Zeroize;
Expand Down Expand Up @@ -196,10 +197,12 @@ impl Scalar29 {
}

// conditionally add l if the difference is negative
let underflow_mask = ((borrow >> 31) ^ 1).wrapping_sub(1);
let mut carry: u32 = 0;
for i in 0..9 {
carry = (carry >> 29) + difference[i] + (constants::L[i] & underflow_mask);
let underflow = Choice::from((borrow >> 31) as u8);

let addend = u32::conditional_select(&0, &constants::L[i], underflow);
carry = (carry >> 29) + difference[i] + addend;
difference[i] = carry & mask;
}

Expand Down
7 changes: 5 additions & 2 deletions curve25519-elligator2/src/backend/serial/u64/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use core::fmt::Debug;
use core::ops::{Index, IndexMut};
use subtle::{Choice, ConditionallySelectable};

#[cfg(feature = "zeroize")]
use zeroize::Zeroize;
Expand Down Expand Up @@ -185,10 +186,12 @@ impl Scalar52 {
}

// conditionally add l if the difference is negative
let underflow_mask = ((borrow >> 63) ^ 1).wrapping_sub(1);
let mut carry: u64 = 0;
for i in 0..5 {
carry = (carry >> 52) + difference[i] + (constants::L[i] & underflow_mask);
let underflow = Choice::from((borrow >> 63) as u8);

let addend = u64::conditional_select(&0, &constants::L[i], underflow);
carry = (carry >> 52) + difference[i] + addend;
difference[i] = carry & mask;
}

Expand Down
2 changes: 1 addition & 1 deletion curve25519-elligator2/src/backend/vector/ifma/edwards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ impl<'a> From<&'a edwards::EdwardsPoint> for NafLookupTable8<CachedPoint> {
}
}

#[cfg(target_feature = "avx512ifma,avx512vl")]
#[cfg(all(target_feature = "avx512ifma", target_feature = "avx512vl"))]
#[cfg(test)]
mod test {
use super::*;
Expand Down
2 changes: 1 addition & 1 deletion curve25519-elligator2/src/backend/vector/ifma/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ impl<'a, 'b> Mul<&'b F51x4Reduced> for &'a F51x4Reduced {
}
}

#[cfg(target_feature = "avx512ifma,avx512vl")]
#[cfg(all(target_feature = "avx512ifma", target_feature = "avx512vl"))]
#[cfg(test)]
mod test {
use super::*;
Expand Down

0 comments on commit 4ea0f59

Please sign in to comment.