Skip to content

feat(u4): add checked byte splitter - #34

Merged
RobinLinus merged 1 commit into
solving-bitcoin:mainfrom
brenorb:feat/u4-split-byte
Sep 16, 2026
Merged

RobinLinus merged 1 commit into
solving-bitcoin:mainfrom
brenorb:feat/u4-split-byte

Conversation

@brenorb

@brenorb brenorb commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add u8_to_u4_pair(check_inputs) to split one byte-valued ScriptNum into high and low nibbles
  • use a four-threshold schedule with no lookup-table memory and preserve unrelated altstack state
  • checked mode validates 0..=255; unchecked mode has an explicit caller invariant
  • add exhaustive byte coverage, malformed-input rejection, state-preservation, and unchecked-hostile tests

Evidence

  • evidence: locally-reproduced
  • execution class: unclassified; local tapscript helper only, with no Bitcoin Core differential validation
  • representative checked fragment: 62 locking-script bytes, 4-byte serialized witness with 1 data item, 4-item strict combined peak, zero hints
  • executed-opcode count is not recorded for this configuration

Validation

  • cargo fmt -- --check
  • python3 tools/kb.py validate
  • cargo test --locked arithmetic::u4
  • cargo test --locked --test primitive_metrics u8_to_u4_pair_metrics_are_current

The full repository test suite was intentionally not run; the focused u4 module and metric test cover this contribution.

@RobinLinus
RobinLinus merged commit 1963104 into solving-bitcoin:main Sep 16, 2026
@brenorb
brenorb deleted the feat/u4-split-byte branch October 28, 2026 02:57
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