Skip to content

feat(u4): add hint-checked symbol histogram - #286

Merged
RobinLinus merged 3 commits into
solving-bitcoin:mainfrom
brenorb:claude/seeded-primitive-21
Nov 9, 2026
Merged

RobinLinus merged 3 commits into
solving-bitcoin:mainfrom
brenorb:claude/seeded-primitive-21

Conversation

@brenorb

@brenorb brenorb commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds arithmetic::u4::histogram::u4_nibbles_histogram_hinted(n) (1..=962, peak n+38): witness x[0..n-1] c[0..15] (c[15] on top) returns the 16 symbol counts and consumes the vector. Every nibble is range-checked to 0..=15 and every claimed count to 0..=n; the claimed counts and the vector's own symbols are packed into the same base-(n+1) lane words and must be equal, so all 16 counts are exact. The existing fixed-symbol count primitive is untouched.
  • Records the primitive page (with the soundness argument), catalog entry, comparison, NR-108 (sixteen counting passes dominated for a full histogram) and OP-064 (consumers and table reuse).

Evidence

  • 64 nibbles: 3,158 script bytes, peak 102, 157 witness bytes over 80 items (16 hint items); sixteen u4_nibbles_count passes alone are at least 18,448 bytes (lower-bound estimate that excludes the vector copies, not a built comparator): 83% less. At 16 nibbles 956 vs 4,256; at 128, 5,988 vs 37,424. Sizes pinned by a test.
  • Tests: honest histograms returned in order for 56 seeded vectors (full and three-symbol alphabets); agreement with u4_nibbles_count; every symbol's count forged by +-1..3; weight moved between symbols and between every adjacent pair of lanes; 1,500 random count vectors accepted exactly when equal to the true histogram; out-of-range counts and nibbles at every position; generation bounds; exact stack frontier.
  • Evidence locally-reproduced; execution unclassified. No Bitcoin Core validation or deployability claim. Independent of the open composition-check PR; same lane technique, separately implemented.
  • Note: NR/OP numbering follows PRs 266-285 (NR-088..107, OP-044..063); PR 265 uses NR-087/OP-043.

Test plan

  • CARGO_PROFILE_DEV_OPT_LEVEL=1 CARGO_PROFILE_TEST_OPT_LEVEL=1 cargo test --locked --no-fail-fast -- --skip fields:: (all suites pass)
  • python3 tools/kb.py validate

🤖 Generated with Claude Code

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>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T11:27:14.917564Z 38d4abe PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 38d4abee34

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/arithmetic/u4/histogram.rs Resolved
Comment thread knowledge/catalog.json Resolved
Comment thread knowledge/catalog.json Resolved

Copy link
Copy Markdown
Contributor

Review of 38d4abee34a8: leaving this PR open pending the following changes.

The returned histogram preserves the original count items; numeric range checks/Horner equality do not make their bytes canonical when require_minimal=false. Please document and test this numeric-only contract (including nonminimal zero/count aliases), or canonicalize the outputs if byte-unique counts are intended. Also report the exact serialized hint cost for the measured fixture: sixteen count-4 items add 32 bytes to the existing witness, or 33 bytes as a separately serialized hint vector; hint_bytes: null leaves the mandatory hint boundary unmeasured.

The current CI is green; these are contract, boundary, or evidence gaps that those checks do not cover.

brenorb commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, @RobinLinus! The histogram contract now makes clear that counts are checked numerically and returned with their original bytes; a permissive-profile regression covers padded counts and both zero aliases. The fixture now pins 32 incremental hint bytes and the 33-byte standalone vector. Focused tests and metrics pass on the merged base; CI is running and the full non-field suite is queued.

@RobinLinus
RobinLinus merged commit 577ceb1 into solving-bitcoin:main Nov 9, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants