Function ring::limb::fold_5_bit_windows
source · pub fn fold_5_bit_windows<R, I: FnOnce(u64) -> R, F: Fn(R, u64) -> R>(
limbs: &[u64],
init: I,
fold: F,
) -> R
Expand description
Processes limbs
as a sequence of 5-bit windows, folding the windows from
most significant to least significant and returning the accumulated result.
The first window will be mapped by init
to produce the initial value for
the accumulator. Then f
will be called to fold the accumulator and the
next window until all windows are processed. When the input’s bit length
isn’t divisible by 5, the window passed to init
will be partial; all
windows passed to fold
will be full.
This is designed to avoid leaking the contents of limbs
through side
channels as long as init
and fold
are side-channel free.
Panics if limbs
is empty.