diff --git a/noir_stdlib/src/uint128.nr b/noir_stdlib/src/uint128.nr index 4a58b3868be..9f1e7b4b76e 100644 --- a/noir_stdlib/src/uint128.nr +++ b/noir_stdlib/src/uint128.nr @@ -116,6 +116,8 @@ impl U128 { pub fn from_integer(i: T) -> U128 { let f = crate::as_field(i); + // Reject values which would overflow a u128 + f.assert_max_bit_size(128); let lo = f as u64 as Field; let hi = (f-lo) / pow64; U128 { @@ -289,4 +291,4 @@ impl Shr for U128 { } self / U128::from_integer(y) } -} \ No newline at end of file +}