-
Notifications
You must be signed in to change notification settings - Fork 32
Description
Describe the bug
LargeInt implementation silently truncates oversized integer inputs instead of validating that the input fits the target bit-width. When a caller constructs an XDR integer backed by LargeInt (e.g., i64, u64, i128, u128, i256, u256) with a value that exceeds the allowed width (for example, a 300-bit bigint for an i256), LargeInt discards the high bits and keeps only the low bits. No error is thrown and the resulting XDR is valid—but it represents a different value than the one provided.
What version are you on?
v3.1.2
To Reproduce
Steps to reproduce the behavior:
- Create a
Hyperwhich is sized at 64 bits and give it a number larger than i64/u64 - Call
.toString()ortoBigInt()on the instance created and observe that the returned value will be theinput - i64/u64 max
Expected behavior
LargeInt should be responsible for enforcing correctness: when constructing/encoding a fixed-width XDR integer, it should validate the input’s magnitude/bit-width and throw (or otherwise fail loudly) if the value does not fit. Silent truncation should not occur by default for fixed-width integer types.
Additional context
Add any other context about the problem here.