Skip to content

feat(arithmetic): add compressed u32 logical right shift - #8

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

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

Conversation

@brenorb

@brenorb brenorb commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add u32_compressed_rshift(shift) for canonical compressed u32 ScriptNums, supporting shifts 1..=31
  • validate hostile compressed encodings, normalize the sign-carried high bit and 31-bit magnitude, divide by a compile-time power of two, and restore logical shift semantics
  • document the OP-014 progress, measurements, comparison baseline, and remaining Core-validation gap

Measurements

For shift 8:

  • direct compressed fragment: 500 locking bytes, 6 representative witness bytes, 1 witness item, 5-item peak
  • decode-byte-shift-reencode baseline: 499 locking bytes, 6 representative witness bytes, 1 witness item, 7-item peak
  • the direct construction is a stack-shape tradeoff, not a general locking-byte win

Verification

  • python3 tools/kb.py validate
  • cargo fmt --all -- --check
  • cargo test --locked u32_compressed_rshift --lib
  • cargo test --locked --test primitive_metrics u32_compressed_rshift_metrics_are_current
  • cargo run --locked --release --example u32_compressed_rshift_benchmark
  • git diff --check

The full repository test suite was intentionally not run; verification was scoped to the new primitive and its metrics. OP-014 remains open for complete transaction and pinned Bitcoin Core differential validation.

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