Repository navigation
feat(u32): add embedded constant subtraction - #144
Conversation
|
Review: changes required before merge. The checked byte boundary misses three original input limbs. With four witness items encoding numeric 1, replacing any bottom-based position 0, 1, or 2 by the nonminimal encoding [0x01, 0x00] still succeeds under the local Tapscript Consensus profile after consuming the four outputs and appending OP_TRUE. Position 3 is rejected. Validate each original byte before arithmetic normalizes it; move or stage the validated limb before repeating the check. Add malformed-encoding regressions at every position under a profile that permits nonminimal numeric encodings globally. Evidence: Reviewed commit: |
1dcf119 to
d377c74
Compare
|
Updated in commit
Checks passed: focused subtraction tests, all 34 non-ignored |
|
Review of The validator now rotates through all four limbs. Preserve per-position canonicality checks and subtraction wrap/borrow vectors while rebasing; rerun the focused subtraction and named metric checks plus KB validation. Current integration conflicts: Validation scope: source/diff and existing CI review; no new full-repository or field-arithmetic test run was requested. |
Resolve conflicts with current main while keeping every record, module, index entry, and metric from both sides: - knowledge/catalog.json: main's 101 records unchanged plus arithmetic/u32-sub-constant (102 records, 257 configurations). - knowledge/comparisons/arithmetic.md: keep main's new rows and the leading-zero-byte paragraph alongside the constant-subtraction row and paragraph. - knowledge/primitives/index.md: keep main's new u4/u32 entries and the constant-subtraction entry. - src/arithmetic/u32/mod.rs: keep main's xnor and new modules plus sub_constant. - tests/primitive_metrics.rs: keep winternitz20_mixed_sum_metrics and u32_sub_constant_metrics in the aggregate chain. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Run the raw-input regression on a complete leaf (outputs consumed, then OP_TRUE) under the local Tapscript Consensus profile. At every one of the four positions check -1/256 (Verify), negative zero and nonminimal one (EqualVerify), and five-byte overflow (ScriptIntNumericOverflow), with a succeeding canonical control and canonical 0/127/128/255 limbs at every position. - Add a test-only no-rotation mutant: its control succeeds, it accepts the nonminimal alias at positions 0-2, and it rejects position 3. - Supply the word as runtime witness items through the shared strict harness and add explicit 0 - c wrap, single-boundary borrow (listed first), multi-boundary borrow, top-limb borrow, and 0xffffffff vectors plus 100 seeded random cases. - Check stack preservation for borrowing and non-borrowing cases. - Correct stale docs: comparison paragraph 141 -> 149 bytes, README peak 10 -> 9 items (now metric-marked), and the operand order of the reused u32_sub_drop(1, 0). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Addressed in
Metrics are unchanged and were not refreshed. The policy-produced fragment is 149 bytes, with a 9-byte representative / 13-byte maximum witness, 4 data items, 0 hint items, a 9-item combined main-plus-alt-stack peak and 83 static non-push opcodes. The generic two-word baseline is 77 bytes, a 21-byte witness over 8 items, and a 9-item peak. Validation on the committed HEAD with a clean tree:
Runs used compiler This head was subsequently integrated into |
Summary
u32_sub_constant(value)for checked four-byte u32 subtraction with a public embedded subtrahendEvidence
Verification
cargo fmt --all -- --checkcargo test --locked arithmetic::u32::sub_constant::tests --lib(3 passed)python3 tools/kb.py validatepython3 -m json.tool knowledge/catalog.jsongit diff --check