Skip to content

feat(arithmetic): add compressed u32 logical left shift - #9

Merged
RobinLinus merged 1 commit into
solving-bitcoin:mainfrom
brenorb:feat/seventh-primitive-scan
Sep 18, 2026
Merged

RobinLinus merged 1 commit into
solving-bitcoin:mainfrom
brenorb:feat/seventh-primitive-scan

Conversation

@brenorb

@brenorb brenorb commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add u32_compressed_lshift(shift) for canonical compressed u32 ScriptNums, supporting shifts 1..=31
  • validate hostile compressed encodings, extract the safe 31-bit magnitude, repeatedly double with signed recentering, and return the modulo-2^32 compressed result
  • record the full-width correctness result and the OP-020 frontier, including the dominated-byte comparison

Measurements

For shift 8:

  • direct compressed fragment: 492 locking bytes, 6 representative witness bytes, 1 witness item, 5-item peak
  • decode-byte-shift-reencode baseline: 490 locking bytes, 6 representative witness bytes, 1 witness item, 7-item peak
  • the direct construction costs 2 locking bytes but saves 2 live stack items

Verification

  • python3 tools/kb.py validate
  • cargo fmt --all -- --check
  • cargo test --locked u32_compressed_lshift --lib
  • cargo test --locked --test primitive_metrics u32_compressed_lshift_metrics_are_current
  • cargo run --locked --release --example u32_compressed_lshift_benchmark
  • git diff --check

The full repository test suite was intentionally not run; verification was scoped to the new primitive and its metrics. Deployment remains unclassified; no Bitcoin Core or relay-policy claim is made.

@RobinLinus
RobinLinus merged commit 74acba4 into solving-bitcoin:main Sep 18, 2026
@brenorb
brenorb deleted the feat/seventh-primitive-scan 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