Repository navigation
feat(u32): document fixed rotations - #45
Conversation
|
Review: hold pending the changes below. Fold this into the rotation/stack documentation package. The 24-bit rotation test should invoke the public helper rather than only manually reconstructing an OP_ROLL sequence; otherwise it does not protect the documented API. Historical local validation (September 11, at this unchanged PR head): Rebase on current main, address the specific gaps above, and run the affected correctness and active metric checks. Broad/full-repository runs are not requested. Reviewed commit: |
1b73893 to
61f1867
Compare
|
Updated in place as the rotation/stack documentation package and rebased onto current main. The 24-bit regression now calls the public Checks: |
|
Consolidated #46 here as the shared u32 representation/validation package. Added byte-for-byte The required full metrics run after these Rust metric changes passed: 107 passed, 1 ignored. |
|
Consolidated #47 into this PR. Added executable seven-bit rotation boundary, stack-preservation, and short-input error coverage; active metrics and knowledge/docs now record the 76-byte fragment, 9-byte representative witness, 13-byte maximum witness, and 8-item peak. Required checks passed: cargo fmt --all -- --check, python3 tools/kb.py validate, git diff --cached --check, and cargo test --locked --test primitive_metrics (107 passed, 1 ignored). |
|
Review of The 24-bit test now calls the public helper and active metrics were added, addressing the earlier review. One small doc correction remains: u8_rrot7(i) rotates the selected byte, so its new description as rotating a u32 word is misleading; describe the actual byte helper. Resolve shared catalog/metric additions and rerun fixed-rotation/equality tests and named metrics. Current integration conflicts: Validation scope: source/diff and existing CI review; no new full-repository or field-arithmetic test run was requested. |
… planes Resolve the shared catalog, u32 knowledge page, u32 README, and primitive metrics conflicts by keeping both sides: - knowledge/catalog.json: merge the u32 security and stack-contract text so it covers the PR's raw-byte equality and unchecked fixed rotations as well as main's checked/unchecked byte-plane transpose. All 101 records and every configuration from both sides are present (262 configurations, no duplicates). - knowledge/primitives/u32.md and src/arithmetic/u32/README.md: keep main's byte-plane bullet/sentence and the PR's fixed-rotation bullets. - tests/primitive_metrics.rs: keep the PR's u32_equality and u32_fixed_rotation metric tests and main's u32_byte_planes metric test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The PR had changed the u8_rrot7(i) doc comment to "Right rotation of a u32 word by the fixed seven-bit SHA-256 rotation", but the helper only touches one byte: it moves the item at stack depth i to the top and replaces it with (x & 0x7f) (x >> 7), high bit on top, growing the stack by one item. The recombination into rotated bytes happens in u32_rrot7(). Document the exact stack effect and the unchecked out-of-range behavior, add the same note to the u32 README, and add u8_rrot7_splits_only_the_selected_byte, which checks depths 0..=4 and byte boundaries 0, 1, 0x7f, 0x80, 0xa5, 0xfe, 0xff, that the other limbs keep their order, the final depth, an alt-stack marker, and the 0x100 unchecked case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Addressed in
Validation on the committed head with a clean tree:
All of this evidence is local, and the deployment class is unclassified. No Bitcoin Core or relay-policy validation is claimed. This head was subsequently integrated into |
Merges origin/main (3d1001f, which has since integrated solving-bitcoin#84 signed less-than, solving-bitcoin#45 fixed rotations/equality, solving-bitcoin#40 reverse-byte adapter, and 27 other PRs) into feat/u32-compressed-boundary, addressing Robin Linus's 2026-09-25 review. Conflicts resolved: - knowledge/catalog.json: kept the u32 record's "tests" entries from both sides (u32_compression_metrics_are_current and u32_reverse_byte_adapter_metrics_are_current), and merged the "security"/"stack_contract" prose so both sides' sentences survive. main ⊆ merged and PR ⊆ merged verified by record-id and (record, configuration)-id set comparison: 117 records / 285 configurations after merge, no duplicates, no ids outside the union of both sides. - knowledge/primitives/u32.md: concatenated both sides' bullets (signed compression boundary / unchecked decoder from the PR; reusable routing / byte-plane transpose / fixed-byte rotations / SHA-256 rotation from main). All 43 main bullets and 40 PR bullets verified present in the merged 45. - src/arithmetic/u4/mod.rs: union of both sides' `pub mod` lines, alphabetically sorted (main added several u4 modules the PR predates; no semantic content lost). - tests/primitive_metrics.rs: kept every #[test] fn from both sides (u32_compression_metrics_are_current from the PR; u32_reverse_byte_adapter_metrics_are_current, u32_equality_metrics_are_current, u32_fixed_rotation_metrics_are_current, u32_byte_planes_metrics_are_current from main). 207 fns after merge = union of main's 206 and the PR's 169 (168 shared). src/arithmetic/u32/README.md and src/arithmetic/u32/stack.rs merged without conflict. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
Research framing
Question: what are the exact costs of the fixed-byte rotations used by the u32 rotation dispatcher?
Result:
u32_rrot8()is 3 script bytes,u32_rrot16()is 1 byte, andu32_rrot(24)is 2 bytes. The four-byte witness serializes to 9 bytes; strict peaks are 5, 4, and 5 items respectively.The evidence 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 -- --checkcargo test --locked fixed_byte_rotations_match_referencecargo test --locked --test primitive_metrics u32_fixed_rotation_metrics_are_currentpython3 tools/kb.py validategit diff --checkThe full repository test suite was intentionally not run; field-arithmetic tests remain skipped by default.