Repository navigation
feat(u4): add checked modulo-16 multiplication - #152
Conversation
|
Review: changes required before merge. The product-table index calculation consumes operands and table entries instead of computing 16*a+b. The sequence OP_DUP OP_ADD OP_ADD OP_ADD OP_ADD lacks the further duplications needed for four doublings. A complete table-setup / 2 3 / multiply / compare-to-6 / table-cleanup wrapper fails. Correct the index construction and exhaust all 256 operand pairs while checking table preservation and cleanup. Evidence: Reviewed commit: |
1a9c4c9 to
35a9e89
Compare
|
Updated in commit The product-table index now computes Refreshed metrics/docs: 21 fragment bytes, 17 static non-push opcodes, 261-item peak including the 256-item table. Documentation now describes numeric range checking and the required result-before-table-cleanup ordering. Validation passed:
|
|
Review of The index construction now performs four explicit doublings before adding the second operand, addressing the previous 16*a+b error. Preserve all 256 input-pair cases and full table-lifecycle checks. Rebase and rerun the multiplication library/metric checks and KB validation. Current integration conflicts: Validation scope: source/diff and existing CI review; no new full-repository or field-arithmetic test run was requested. |
# Conflicts: # knowledge/catalog.json # knowledge/comparisons/arithmetic.md # knowledge/primitives/index.md # src/arithmetic/u4/README.md # src/arithmetic/u4/mod.rs # tests/primitive_metrics.rs
|
Addressed in
Validation on the integrated tree: 6 focused multiplication tests passed, the named |
This adds checked multiplication modulo 16 for two numeric u4 operands using a reusable 256-entry product table. Both operands are range-checked before forming the table index; the query consumes the operands and preserves the table beneath its result. Callers move or consume the result before table cleanup.
The representative query has 21 policy-produced script bytes, a 5-byte canonical serialized data-witness fixture (two operands, zero hints), a 261-item combined-stack peak, and 17 static non-push opcodes. Numeric range checks do not prove canonical byte encoding. Evidence remains locally-reproduced and deployment unclassified; no Bitcoin Core or relay-policy validation is claimed.
Integration preserves current main's catalog records, APIs, documentation, and active metric tests. Focused coverage includes all 256 operand pairs, malformed runtime inputs, surrounding state, and table preservation and cleanup.
Validation on the integrated tree: 6 focused multiplication tests passed, the named
u4_mul_mod16_metrics_are_currenttest passed, KB validation passed (102 records / 257 configurations), and formatting and whitespace checks passed. The historical reproduction used interpreter702544c9; current tests usea09e87af, with compiler124b561ein both. These are local tapscript results with the stack limit enforced, not Bitcoin Core or relay-policy validation. The existing 21-byte query / 5-byte two-item data witness / 261-item metric peak / 17 static-opcode measurements are unchanged; zero hints. The separate all-table lifecycle test peaks at 516 combined items and uses script-constant operands.