Skip to content

feat(u4): add little-endian bit adapter - #83

Open
brenorb wants to merge 1 commit into
solving-bitcoin:mainfrom
brenorb:feat/u4-little-endian-bits
Open

brenorb wants to merge 1 commit into
solving-bitcoin:mainfrom
brenorb:feat/u4-little-endian-bits

Conversation

@brenorb

@brenorb brenorb commented Sep 11, 2026

Copy link
Copy Markdown

Summary

  • add a mirrored 61-item staggered lookup table that emits each u4 nibble least-significant-bit first
  • preserve checked range validation, stack scheduling, and the existing 1..=234 batch bound
  • record the 32-nibble boundary: 924-byte script, 64-byte representative witness, 189-item peak, and 735 static non-push opcodes

Research result

The little-endian adapter matches the existing checked big-endian converter in script size, stack peak, and opcode count. It removes the need for a caller-side four-bit reversal when a ScriptNum or scalar consumer needs least-significant-bit-first nibble output. Witness nibbles remain hostile: checked mode enforces numeric range 0..=15, while canonical encoding and protocol binding remain caller obligations. Deployment remains unclassified; local evidence uses the repository tapscript executor with the strict stack limit.

Tests

  • cargo test --locked arithmetic::u4::bits::tests -- --nocapture --skip batch_size_guard_matches_the_strict_stack_peak
  • cargo test --locked arithmetic::u4::bits::tests::batch_size_guard_matches_the_strict_stack_peak -- --exact --nocapture
  • python3 tools/kb.py validate
  • UPDATE_PRIMITIVE_METRICS=1 cargo test --locked --test primitive_metrics (6 passed, 1 ignored)
  • cargo test --locked --test primitive_metrics (6 passed, 1 ignored)
  • full repository test suite intentionally not run

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