mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-06 20:41:14 +00:00
Merge pull request #325 from rubdos/const_fn_for_scalar_from_bits
Make Scalar::from_bits a const fn.
This commit is contained in:
commit
e342f25c4e
1 changed files with 1 additions and 1 deletions
|
|
@ -243,7 +243,7 @@ impl Scalar {
|
||||||
/// This function is intended for applications like X25519 which
|
/// This function is intended for applications like X25519 which
|
||||||
/// require specific bit-patterns when performing scalar
|
/// require specific bit-patterns when performing scalar
|
||||||
/// multiplication.
|
/// multiplication.
|
||||||
pub fn from_bits(bytes: [u8; 32]) -> Scalar {
|
pub const fn from_bits(bytes: [u8; 32]) -> Scalar {
|
||||||
let mut s = Scalar{bytes};
|
let mut s = Scalar{bytes};
|
||||||
// Ensure that s < 2^255 by masking the high bit
|
// Ensure that s < 2^255 by masking the high bit
|
||||||
s.bytes[31] &= 0b0111_1111;
|
s.bytes[31] &= 0b0111_1111;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue