Skip to content

Measure paired signed ScriptNum extrema - #338

Merged
RobinLinus merged 1 commit into
solving-bitcoin:mainfrom
brenorb:codex/paired-signed-extrema
Nov 9, 2026
Merged

RobinLinus merged 1 commit into
solving-bitcoin:mainfrom
brenorb:codex/paired-signed-extrema

Conversation

@brenorb

@brenorb brenorb commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Research question

Does ordering each pair once reduce the cost of computing both extrema of a hostile canonical signed ScriptNum vector after input checks and branch routing are included?

The new fragment consumes 1 through 997 at-most-four-byte canonical values, returns the exact minimum and maximum, and preserves both caller stacks within the combined limit. It uses zero hints. The streaming comparator shares first-pair initialization and checks the same outputs.

Width Schedule Complete leaf bytes Data witness bytes Combined peak Executed non-push ops Value comparisons
128 Paired 1,927 641 131 1,596 190
128 Streaming 1,927 641 131 1,659 253
997 Paired 14,962 4,988 1,000 12,957 1,494
997 Streaming 14,962 4,988 1,000 12,957 1,991

All ordinary data items coexist at entry. Serialized data witness includes the count and lengths and excludes leaf, control block, annex, and transaction. The local tapscript runs enforce the stack limit and disable experimental OP_CAT. Evidence is locally-reproduced. Execution is unclassified.

Each later pair saves one total operation when its swap is skipped. The 997-value fixture takes every swap, giving the same total operations despite fewer value comparisons. A sum-based reconstruction also fails on the valid pair [2147483646, 2147483647] because the next arithmetic opcode consumes a five-byte temporary.

Related PRs #314 and #279 return an earliest nibble minimum index and a single nibble order statistic respectively. Both exact head merge simulations were clean.

Verification

  • cargo test --locked --lib arithmetic::extrema::tests
  • cargo test --locked --test primitive_metrics signed_extrema_metrics_are_current
  • python3 tools/kb.py validate
  • cargo fmt --all -- --check
  • The required full non-field suite passed on this exact published commit.

@brenorb
brenorb marked this pull request as ready for review November 6, 2026 13:31
@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-06T13:36:14.433474Z eb36869 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 6b35341 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