pub(crate) trait ConstantTimeDiv: Unsigned {
const CT_DIV_SHIFT: usize;
const CT_DIV_MULTIPLIER: u64;
// Provided method
fn ct_div(x: u32) -> u32 { ... }
}Expand description
Constant-time division by a compile-time constant divisor.
This trait provides a constant-time alternative to the hardware division
instruction, which has variable timing based on operand values.
Uses Barrett reduction to compute x / M where M is a compile-time constant.
Required Associated Constants§
Sourceconst CT_DIV_SHIFT: usize
const CT_DIV_SHIFT: usize
Bit shift for Barrett reduction, chosen to provide sufficient precision
Sourceconst CT_DIV_MULTIPLIER: u64
const CT_DIV_MULTIPLIER: u64
Precomputed multiplier: ceil(2^SHIFT / M)
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.