Skip to content

Range-check shift/rotate amounts in the bytestring wrappers#7854

Open
Unisay wants to merge 1 commit into
masterfrom
yura/issue-2342-shift-rotate
Open

Range-check shift/rotate amounts in the bytestring wrappers#7854
Unisay wants to merge 1 commit into
masterfrom
yura/issue-2342-shift-rotate

Conversation

@Unisay

@Unisay Unisay commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

The shiftByteString and rotateByteString wrappers in PlutusTx.Builtins.Internal pass the shift/rotation amount to PlutusCore.Bitwise as a full Integer with no range check. This matches the currently live builtin semantics (variants B/C take the amount as IntegerCostedLiterally), but variants D and E — which the van Rossem hard fork activates at PV11 — take the amount as a checked Int, failing on values outside [-2^63, 2^63-1]. Once PV11 is live, off-chain evaluation would silently succeed (all-zero shift result, modular rotation) where the deployed script fails phase-2 validation. Both wrappers now fail on out-of-Int-range amounts, mirroring D/E.

Follow-up to #7851, which fixed the analogous narrowing bugs in the other wrappers. Time-sensitive: the divergence goes live with the van Rossem HF.

Closes IntersectMBO/plutus-private#2342

shiftByteString and rotateByteString passed the amount to the Bitwise
code as an unchecked Integer, matching the pre-vanRossem builtin
semantics (variants B/C accept any amount). Builtin semantics variants D
and E, which the van Rossem HF activates, take the amount as a checked
Int, so off-chain evaluation would succeed where the deployed script
fails once PV11 is live. Both wrappers now fail on amounts outside the
machine-Int range, mirroring D/E.

Issue: IntersectMBO/plutus-private#2342
@Unisay Unisay self-assigned this Jul 17, 2026
@Unisay
Unisay marked this pull request as draft July 17, 2026 11:07
@Unisay
Unisay requested a review from kwxm July 17, 2026 11:17
@Unisay
Unisay marked this pull request as ready for review July 17, 2026 11:17
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.

2 participants