diff --git a/util/bigint/src/uint.rs b/util/bigint/src/uint.rs index 801c5f5bd..69aaa5809 100644 --- a/util/bigint/src/uint.rs +++ b/util/bigint/src/uint.rs @@ -407,7 +407,7 @@ macro_rules! uint_overflowing_mul_reg { let (b_u, b_l) = split(you[i]); for j in 0..$n_words { - if me[j] == 0 { + if me[j] == 0 && carry2 == 0 { continue; } @@ -1640,6 +1640,14 @@ mod tests { assert_eq!(U256::from(1u64) * U256::from(10u64), U256::from(10u64)); } + #[test] + pub fn uint256_mul2() { + let a = U512::from_str("10000000000000000fffffffffffffffe").unwrap(); + let b = U512::from_str("ffffffffffffffffffffffffffffffff").unwrap(); + + assert_eq!(a * b, U512::from_str("10000000000000000fffffffffffffffcffffffffffffffff0000000000000002").unwrap()); + } + #[test] pub fn uint256_overflowing_mul() { assert_eq!(