Skip to content

Commit bbfcfdc

Browse files
authored
Fix shift left overflow in test_msm_ux when bit_width is 64 (#115)
`1 << 64` overflows since shifting a u64 by 64 positions exceeds its bit width. Skip the modulo when bit_width == 64 since any u64 value is already in range.
1 parent 17ecf01 commit bbfcfdc

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/provider/msm.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,14 @@ mod tests {
482482
println!("bit_width: {bit_width}");
483483
assert!(bit_width <= 64); // Ensure we don't overflow F::from
484484
let coeffs: Vec<u64> = (0..n)
485-
.map(|_| rand::random::<u64>() % (1 << bit_width))
485+
.map(|_| {
486+
let r = rand::random::<u64>();
487+
if bit_width == 64 {
488+
r
489+
} else {
490+
r % (1 << bit_width)
491+
}
492+
})
486493
.collect::<Vec<_>>();
487494
let coeffs_scalar: Vec<F> = coeffs.iter().map(|b| F::from(*b)).collect::<Vec<_>>();
488495
let general = msm(&coeffs_scalar, &bases, true);

0 commit comments

Comments
 (0)