Repository navigation
Integrate 70 reviewed Script PRs and reconcile shared validation - #341
Merged
Merged
Conversation
Decide multiset equality of two checked u4 vectors with zero hints using radix-(2n+1) signed histogram lanes in four-byte ScriptNum accumulators. At 16+16 nibbles: 1,158 script bytes, 63 witness bytes, 53-item peak, versus an 8,512-byte lower bound for 32 per-symbol counts (estimate). Evidence locally-reproduced; execution unclassified. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Zero-hint count of pairs i<j with a[i]>a[j] in a range-checked u4 vector using n(n-1)/2 in-place comparisons. 822 script bytes, 32 witness bytes, 19-item peak at 16 nibbles; quadratic growth, and dominated by the linear nondecreasing predicate for zero-inversion questions (NR-089). Evidence locally-reproduced; execution unclassified. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Zero-hint conversion of hostile ASCII hex characters to u4 nibbles with a table-free fold and a resident 55-entry table scheduler, for lower, upper or either case. At 64 lowercase characters: 1,470 bytes (fold, 67-item peak) versus 1,299 bytes (table, 122-item peak); the fold wins below about 28 lowercase, 48 uppercase and 10 either-case characters. Evidence locally-reproduced; execution unclassified. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Zero-hint balanced-bracket decision over four brackets per nibble using (net change, prefix deficit) summary tables. At 128 brackets: 895 script bytes, 65 witness bytes over 32 items, 69-item peak, versus 2,059 / 193 / 128 items / 133 for a one-item-per-bracket comparator. Evidence locally-reproduced; execution unclassified. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Zero-hint L1, Lee and Hamming distances between two range-checked u4 vectors. Table-free L1/Lee cost 334/414 script bytes at 16 nibbles; fused 256-entry Hamming costs 874 bytes versus 962 for XOR-then-popcount composition (6.3-10.7% smaller over 1-64 nibbles). Evidence locally-reproduced; execution unclassified. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Expand a non-negative ScriptNum into big-endian u4 nibbles (1-8 nibbles) with a hint-free compare-and-subtract ladder or hint-checked Horner verification. At 4 nibbles: 230 script + 5 witness bytes (no hints) versus 59 + 13 (four hints); the hint-free form is dominated on bytes (NR-093). Evidence locally-reproduced; execution unclassified. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Hint-free Boyer-Moore vote plus verification count over a range-checked u4 vector, deciding the strict-majority nibble or none, and a one-hint claim check. At 16 nibbles: 486 script bytes (peak 20) versus a 4,256-byte lower bound for sixteen per-symbol counts; claim check 213 bytes. Evidence locally-reproduced; execution unclassified. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Table-free modulo-15 residue of a canonical u4 vector (running and ladder schedules), a delayed-reduction modulo-17 schedule, and u32 residues modulo 255 and 65,535. Keeping the sum exact and reducing once saves 31% (mod 15) and 33% (mod 17) at 64 nibbles, 38% at 997, with the same peak. Evidence locally-reproduced; execution unclassified. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Numeric decimal Luhn fold with conditional doubling and a delayed-reduction ladder. At 32 digits: 411 script bytes, 35-item peak, versus 766 bytes and a 136-item peak for the Damm fold; Luhn misses the 09/90 adjacent transposition (60 of 3,000 in a model comparison) that Damm detects. Evidence locally-reproduced; execution unclassified. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Exact running sum with a final conditional-subtraction ladder replaces the 31-entry resident table of u4_nibbles_to_sum_mod16. 429 versus 592 script bytes and a 35 versus 66 peak at 32 nibbles; smaller at every length from one nibble to the 965 limit. Evidence locally-reproduced; execution unclassified. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Expand a non-negative ScriptNum into numeric decimal digits with a hint-free ladder or hint-checked Horner verification (1-10 digits), and measure complete leaves feeding the existing Damm fold. At nine digits: 582 versus 144 script bytes; leaf totals 914 (hint-free) versus 494 (hint-checked) script-plus-witness bytes. Evidence locally-reproduced; execution unclassified. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Hint-free decision that a range-checked u4 vector has exactly a public multiset of nibbles, via packed base-(n+1) count lanes (a one-sided form of the packed-histogram technique), with a pairwise-distinct comparator for permutations. 649 script bytes (peak 37) for a 16-nibble permutation versus 823 (peak 19) pairwise and a 4,256-byte lower bound for per-symbol counts. Evidence locally-reproduced; execution unclassified. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Radix-2^w multi-digit Lamport HASH160 commitments that leave the opened digits on the stack and reject (rather than clamp) out-of-range values, with a measured digit-width design space. Two bits per digit minimizes script plus witness at 8/16/32/160 bits; at 160 bits the total is 9,580 bytes versus 2,334 for the smallest tested Winternitz construction. Evidence locally-reproduced; execution unclassified. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Linear-time verification that a witness-claimed nibble is the k-th smallest (for example the lower median) of a range-checked u4 vector, plus a quadratic hint-free pairwise selector. At 16 nibbles: 312 script bytes (one hint) versus 3,512; the selector is itself dominated by the sorting network reported in the open sorting PR. Evidence locally-reproduced; execution unclassified. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Range-checked u4 nibbles replaced by the ASCII codes of their lower- or upper-case hexadecimal digits, with a branching arithmetic form and a resident 16-entry table form. At 64 nibbles: 1,150 versus 680 script bytes (table 41% smaller); the table wins from about five nibbles. Evidence locally-reproduced; execution unclassified. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Verify a witness selection against public weights and a public target with OP_IF additions. In tapscript MINIMALIF makes the selectors canonical for free: 224 script bytes for 32 weights (7 per weight) versus 544 with explicit range and reserialization checks. Evidence locally-reproduced; execution unclassified. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Pack each u4 vector into seven-nibble words with a Horner sum and compare the words with native ScriptNum arithmetic, folding from the last word so the first differing word decides. 2,171 versus 3,532 script bytes at 64 nibbles (two Taproot sibling nodes) and 4,486 versus 7,500 at 128 against the per-nibble state machine, at a peak four items higher. Evidence locally-reproduced; execution unclassified. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Verify prover-supplied presence flags with n flag lookups plus 16 witnessed-index checks instead of 16*n equality scans. At 64 nibbles: 1,029 versus 6,733 script bytes (85% smaller), 1,217 versus 6,858 including witness, with 32 hint items and a 100-item peak. Evidence locally-reproduced; execution unclassified. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Expand a compressed u32 ScriptNum into four bytes by checking four witness bytes against their recompression instead of running the 31-step bit ladder. 135 versus 431 script bytes (69% smaller; 153 versus 437 including witness) for four hint items. Evidence locally-reproduced; execution unclassified. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Verify a claimed XOR of a u4 vector with exact packed bit-count lanes and four hinted half-counts, without the 256-entry XOR table: lane b of the sum equals y_b + 2*h_b, so y_b is the parity of the count. 367 versus 740 script bytes at 16 nibbles (peak 43 versus 273) for five hint items; an exhaustive hint search on four vectors accepts only the honest pair. Evidence locally-reproduced; execution unclassified. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Verify 16 prover-supplied symbol counts of a range-checked u4 vector by comparing packed base-(n+1) lane words, instead of sixteen fixed-symbol counting passes. 3,158 script bytes at 64 nibbles versus at least 18,448 for sixteen passes (lower-bound estimate), for 16 hint items; 1,500 random count forgeries rejected in tests. Evidence locally-reproduced; execution unclassified. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
# Conflicts: # knowledge/catalog.json
# Conflicts: # knowledge/catalog.json # src/arithmetic/u4/README.md
added 29 commits
November 9, 2026 09:22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This integrates 70 reviewed PRs against current
main, resolving overlapping catalog, documentation, module-registration, metric-test and CI additions while retaining the original PR heads as merge ancestors.Included: #266–#286, #290–#292 and #294–#339. PR #293 remains open with a reproduced truncated-PUSHDATA-header finding; it is deliberately excluded.
The integration preserves every incoming primitive metric test and new source file, consolidates 33 identical execution-counter helpers, retains all added Bitcoin Core comparisons, and updates seven older metric fixtures to check outputs and measure size/opcodes/peak from the same compiled fragment. Small documentation corrections distinguish evidence from execution class, describe the SIGHASH_SINGLE boundary accurately, and link the 10-choose-5 experiment from the protocol overview.
Validation: knowledge schema and links pass (203 records, 782 configurations); all 82 Python tests pass; Rust formatting and whitespace checks pass. The full locked non-field Rust suite passed locally: 1,679 tests passed across 25 suites, with 25 existing ignored tests, including all 229 active primitive metric checks. All combined GitHub jobs passed: formatting/knowledge/Python, locked non-field Rust, and pinned Bitcoin Core comparisons (run 612). No field-arithmetic tests are requested or run.
Merge using a merge commit, not squash/rebase, so the reviewed original PRs are recorded as merged.