Skip to content

Mask five-byte CSV operands before narrowing - #24

Open
adrienlacombe wants to merge 1 commit into
BitVM:masterfrom
adrienlacombe:codex/csv-five-byte
Open

adrienlacombe wants to merge 1 commit into
BitVM:masterfrom
adrienlacombe:codex/csv-five-byte

Conversation

@adrienlacombe

@adrienlacombe adrienlacombe commented Sep 20, 2026

Copy link
Copy Markdown

OP_CHECKSEQUENCEVERIFY accepts up to five-byte nonnegative ScriptNums. An operand such as 2^32 has no relevant BIP68 bits and should compare like zero, but the interpreter attempted to convert the entire i64 to u32 with expect, causing a panic. Mask the operand to the type flag and low 16 bits before narrowing, matching Bitcoin Core's CheckSequence comparison.

Eight regression groups exercise this rule in legacy, SegWit v0 and Tapscript contexts, as well as height/time mismatches, transaction version, input/operand disable bits, negative, overlong and nonminimal encodings. A targeted test reproduced the panic before this patch; cargo test --locked --workspace --all-features passes all 20 tests after it. Upstream does not track Cargo.lock; the local run used an ignored lockfile generated offline.

The rule follows BIP112 and Bitcoin Core v30.3. This patch is based directly on upstream master and is independent of other pending interpreter PRs.

The funded follow-up in solving-bitcoin/bitcoin-scripts#241 confirms all 19 complete Core transactions and 19 local consensus/policy comparisons, with byte-identical reports from two fresh nodes. The lab uses a combined interpreter pin that retains the other pending repairs; this standalone patch remains based directly on upstream master.

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.

1 participant