Skip to content

Compute the common-prefix length of opaque item vectors - #312

Merged
RobinLinus merged 1 commit into
solving-bitcoin:mainfrom
brenorb:codex/opaque-common-prefix
Nov 9, 2026
Merged

RobinLinus merged 1 commit into
solving-bitcoin:mainfrom
brenorb:codex/opaque-common-prefix

Conversation

@brenorb

@brenorb brenorb commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Result

Adds support::common_prefix::opaque_common_prefix_len(n) for two fixed-width lists of opaque stack items. The reverse scan starts with the full width and overwrites the candidate at each mismatch, so the final candidate is the first mismatch or the full width. It compares exact raw bytes and uses zero hints.

Pairs Schedule Script bytes Serialized data witness bytes Ordinary items Hint items Combined peak Executed non-push ops
32 Reverse mismatch 292 193 64 0 66 165
32 Forward state 334 193 64 0 67 225
128 Reverse mismatch 1,256 771 256 0 258 657
128 Forward state 1,458 771 256 0 259 897

Both complete leaves verify the same canonical length and end with true. All payloads coexist at entry. Witness bytes exclude script, control block, annex and transaction. Evidence is locally reproduced, with unclassified execution under the stack-limited local tapscript profile.

The contract suite covers exhaustive small raw vectors, later matches after the first mismatch, oversized and misshapen witnesses, and both caller stacks. At 499 pairs the reverse path reaches 1,000 combined items and the matched forward path rejects.

Verification

  • Focused opaque-vector, malformed-input and metric tests
  • python3 tools/kb.py validate and cargo fmt --all -- --check
  • cargo test --locked -- --skip fields::

@brenorb
brenorb marked this pull request as ready for review November 6, 2026 08:59
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 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-11-06T09:06:48.538541Z bcaff94 Draft marked ready
ℹ️ 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.

@RobinLinus
RobinLinus merged commit 93b2245 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