mirror of
https://github.com/saymrwulf/betrusted-curve25519-dalek-source.git
synced 2026-09-09 21:10:43 +00:00
fix: incorrectly prevented to_radix_2w_size_hint on u32e
This function should be able to be enabled by feature selection.
This commit is contained in:
parent
4fdd15c3af
commit
0a0a972dfa
1 changed files with 14 additions and 18 deletions
|
|
@ -1026,27 +1026,23 @@ impl Scalar {
|
||||||
output
|
output
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg_if::cfg_if!{
|
#[cfg(any(feature = "alloc", all(test, feature = "precomputed-tables")))]
|
||||||
if #[cfg(curve25519_dalek_backend = "u32e_backend")]{}
|
/// Returns a size hint indicating how many entries of the return
|
||||||
else if #[cfg(any(feature = "alloc", all(test, feature = "precomputed-tables")))] {
|
/// value of `to_radix_2w` are nonzero.
|
||||||
/// Returns a size hint indicating how many entries of the return
|
pub(crate) fn to_radix_2w_size_hint(w: usize) -> usize {
|
||||||
/// value of `to_radix_2w` are nonzero.
|
debug_assert!(w >= 4);
|
||||||
pub(crate) fn to_radix_2w_size_hint(w: usize) -> usize {
|
debug_assert!(w <= 8);
|
||||||
debug_assert!(w >= 4);
|
|
||||||
debug_assert!(w <= 8);
|
|
||||||
|
|
||||||
let digits_count = match w {
|
let digits_count = match w {
|
||||||
4..=7 => (256 + w - 1) / w,
|
4..=7 => (256 + w - 1) / w,
|
||||||
// See comment in to_radix_2w on handling the terminal carry.
|
// See comment in to_radix_2w on handling the terminal carry.
|
||||||
8 => (256 + w - 1) / w + 1_usize,
|
8 => (256 + w - 1) / w + 1_usize,
|
||||||
_ => panic!("invalid radix parameter"),
|
_ => panic!("invalid radix parameter"),
|
||||||
};
|
};
|
||||||
|
|
||||||
debug_assert!(digits_count <= 64);
|
debug_assert!(digits_count <= 64);
|
||||||
digits_count
|
digits_count
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// Creates a representation of a Scalar in radix \\( 2^w \\) with \\(w = 4, 5, 6, 7, 8\\) for
|
/// Creates a representation of a Scalar in radix \\( 2^w \\) with \\(w = 4, 5, 6, 7, 8\\) for
|
||||||
/// use with the Pippenger algorithm. Higher radixes are not supported to save cache space.
|
/// use with the Pippenger algorithm. Higher radixes are not supported to save cache space.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue