Repository navigation
feat(u4): add canonical LSB projection - #113
Conversation
|
Review: changes required before merge. The canonical wrapper retains a maximum batch size of 982, but its stronger validator adds one stack item to the peak. Strict local executions succeed at 981 and fail at 982 for otherwise valid inputs. Give the canonical variant its own maximum (981 without unrelated state), update composition/peak documentation, and add exact-boundary tests. Evidence: Reviewed commit: |
6ce7b1f to
74a77ab
Compare
|
Addressed the review recommendation in rebased commit
Validation:
|
|
Review of The canonical maximum is now separately bounded at 981, with an executed strict frontier, addressing the earlier overflow. Integrate this with newly merged #236, preserving its range-only boundary tests and terminology. Rerun the focused LSB tests and both range-only/canonical metric checks. Current integration conflicts: Validation scope: source/diff and existing CI review; no new full-repository or field-arithmetic test run was requested. |
…solving-bitcoin#236 and Core fixture solving-bitcoin#225 Resolve conflicts in knowledge/catalog.json, knowledge/primitives/u4-lsb.md, src/arithmetic/u4/README.md, src/arithmetic/u4/lsb.rs and src/arithmetic/u4/mod.rs (the last one is new relative to e9d5a66 because main now also carries solving-bitcoin#244). - lsb.rs: keep solving-bitcoin#236's range-checked wording, imports and its three tests (projects_all_nibble_least_significant_bits_in_order, rejects_out_of_range_nibbles_at_each_position, respects_stack_frontier_and_preserves_state); keep this PR's separate u4_nibbles_to_lsb_canonical API, its 981-input bound and its four tests. Document the canonical API's contract distinctly. - mod.rs: take main's sorted module list (superset of the PR's). - catalog: keep main's range-only summary/security wording and solving-bitcoin#225's Core complete-leaf configuration; add the PR's canonical-checked-batch32 configuration, list the canonical tests and metric, and state that only the canonical API enforces canonical ScriptNum encoding. - knowledge page / README: keep solving-bitcoin#236 and solving-bitcoin#225 text verbatim; add the canonical adapter as a separate API with its 1..=981 frontier and the note that the Core fixture does not validate it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ality check canonical_projection_rejects_malformed_nibbles ran under the default local helper, which enforces minimal ScriptNum decoding (require_minimal), so the aliases [0x01, 0x00] and [0x80] were rejected with MinimalData by OP_WITHIN before verify_canonical_nibble ran. With the canonicality check removed from u4_nibbles_to_lsb_canonical the test still passed. Run the rejection cases under the local TapscriptProfile::Consensus profile, which decodes non-minimal numbers: add a valid control, a range-only control showing u4_nibbles_to_lsb accepts both aliases there, and exact-error assertions (EqualVerify for aliases, Verify for 256) for the canonical API at every position. The original minimal-helper rejection check is retained. With the canonicality check dropped, the test now fails with "canonical API mishandled [1, 0] at 0" (left: None, right: Some(EqualVerify)). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Addressed in
Validation on the clean committed HEAD, with
Evidence for the canonical variant is |
Summary
u4_nibbles_to_lsb_canonical()with minimal ScriptNum validation for every nibbleVerification
cargo test --locked arithmetic::u4::lsb::tests:: --libcargo test --locked --test primitive_metrics u4_lsb_canonical_metrics_are_current -- --exactpython3 tools/kb.py validatecargo fmt --all -- --checkgit diff --check