Skip to content

feat(u32): document byte reorder boundary - #44

Merged
RobinLinus merged 1 commit into
solving-bitcoin:mainfrom
brenorb:feat/u32-byte-reorder-boundary
Sep 18, 2026
Merged

RobinLinus merged 1 commit into
solving-bitcoin:mainfrom
brenorb:feat/u32-byte-reorder-boundary

Conversation

@brenorb

@brenorb brenorb commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add direct tests for all four byte_reorder(offset) permutations and invalid-offset rejection
  • document and catalog each compile-time specialization
  • record generated script, serialized witness, and strict stack metrics

Research framing

Question: what is the exact permutation and cost of the byte reorder used by non-byte-aligned u32 rotations?

Result: offsets 0, 1, 2, and 3 compile to 3, 2, 4, and 3 script bytes respectively. Each consumes four byte items with a 9-byte serialized witness and a 4-item strict peak.

The result is locally reproduced and unclassified for deployment. Inputs are raw byte-valued stack items; callers remain responsible for range and canonical ScriptNum checks.

Validation

  • cargo fmt --all -- --check
  • cargo test --locked byte_reorder_covers_all_offsets
  • cargo test --locked byte_reorder_rejects_invalid_offsets
  • cargo test --locked --test primitive_metrics u32_byte_reorder_metrics_are_current
  • python3 tools/kb.py validate
  • git diff --check

The full repository test suite was intentionally not run; field-arithmetic tests remain skipped by default.

@RobinLinus
RobinLinus merged commit 7945974 into solving-bitcoin:main Sep 18, 2026
@brenorb
brenorb deleted the feat/u32-byte-reorder-boundary 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