Skip to content

feat(u4): add nibble pair byte packing - #33

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

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

Conversation

@brenorb

@brenorb brenorb commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add u4_pair_to_u8(check_inputs) to pack high | low nibbles into one byte-valued ScriptNum
  • checked mode validates both hostile inputs in 0..=15; unchecked mode is explicit about its caller invariant
  • add exhaustive 256-value coverage, malformed-input rejection, state preservation, and unchecked behavior tests
  • document the u4-to-byte composition boundary and measured cost

Evidence

  • evidence: locally-reproduced
  • execution class: unclassified; local tapscript helper only, with no Bitcoin Core differential validation
  • representative checked fragment: 20 locking-script bytes, 4-byte serialized witness with 2 data items, 5-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 u4_pair_to_u8_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 45cc997 into solving-bitcoin:main Sep 16, 2026
@brenorb
brenorb deleted the feat/u4-pack-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