Skip to content

Decode checked negabinary digits - #335

Merged
RobinLinus merged 1 commit into
solving-bitcoin:mainfrom
brenorb:codex/checked-negabinary-decoder
Nov 9, 2026
Merged

RobinLinus merged 1 commit into
solving-bitcoin:mainfrom
brenorb:codex/checked-negabinary-decoder

Conversation

@brenorb

@brenorb brenorb commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Decode fixed-width canonical base −2 bits into one checked signed ScriptNum. The fold evaluates d-x-x. Its first subtraction always fits, so only the final 32-bit result needs a raw size check. The matched baseline doubles first and checks or corrects the final step explicitly.

At x=1073741824 and d=1, the exact result is -2147483647. Unguarded doubling produces a five-byte positive intermediate, which fails when used as a subtraction operand. Both checked schedules accept the valid result and reject d=0 at the same accumulator. The signed radix-32 window decoder has a different sign-and-magnitude extraction contract.

Both leaves verify and consume every exact result and leave true. All bit witnesses coexist at entry. Data witness includes the item count and lengths, excluding leaf, control block, annex and transaction. Executed non-push counts include processed branch delimiters.

Width Calls Schedule Leaf bytes Data witness bytes Ordinary items Hint items Peak Executed
8 1 Two subtractions 103 14 8 0 11 84
8 1 Checked multiply first 103 14 8 0 11 84
31 1 Two subtractions 405 48 31 0 34 337
31 1 Checked multiply first 405 48 31 0 34 337
32 1 Two subtractions 422 35 32 0 35 351
32 1 Checked multiply first 444 35 32 0 35 352
32 16 Two subtractions 6,705 595 512 0 515 5,616
32 16 Checked multiply first 7,057 595 512 0 515 5,680

The tests compare all 65,536 sixteen-bit vectors with a host positional sum, reject hostile bit aliases and out-of-range final values, and preserve five caller items at the 1,000-item combined frontier for 31 width-32 calls.

Evidence is locally reproduced and execution is unclassified. Focused tests, metric snapshots, knowledge validation, formatting, and diff checks passed. 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 12:58
@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:03:18.526440Z 15a04c7 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 c0f8d3f 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