Skip to content

Bigint silent truncation#135

Open
Ryang-21 wants to merge 4 commits intomasterfrom
bigint-silent-truncation
Open

Bigint silent truncation#135
Ryang-21 wants to merge 4 commits intomasterfrom
bigint-silent-truncation

Conversation

@Ryang-21
Copy link
Contributor

@Ryang-21 Ryang-21 commented Mar 2, 2026

What

This fixes silent truncation that occurred when encoding LargeInt by checking that the bytes to be encoded are of the appropriate size. This is necessary as the BigInt.asUintN and BigInt.asintN methods truncate the higher bits when they exceed the provided size param given to the function.

Validation

Tests were added to check functionality at the max and min bounds of the sized integer. Values that are beyond the bounds were tested to throw.

@Ryang-21 Ryang-21 requested review from Shaptic and Copilot and removed request for Copilot March 2, 2026 20:02
@Ryang-21 Ryang-21 linked an issue Mar 2, 2026 that may be closed by this pull request
@Ryang-21 Ryang-21 requested a review from quietbits March 2, 2026 20:02
Copy link

@quietbits quietbits left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not super familiar with this repo, but the update looks OK to me.

Comment on lines +338 to +339
[-1n, 64, 32, [0xffffffffn, 0xffffffffn]],
[0xfffffffffffffffen, 64, 32, [0xfffffffen, 0xffffffffn]],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sliceBigInt was changed to encode the bigint slices as uint. Is this a breaking change

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is, actually: see #100 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LargeInt silently truncates oversized integer inputs

3 participants