Skip to content

feat(sha256): add u4 midstate continuation - #82

Closed
brenorb wants to merge 1 commit into
solving-bitcoin:mainfrom
brenorb:feat/sha256-u4-midstate-boundary
Closed

brenorb wants to merge 1 commit into
solving-bitcoin:mainfrom
brenorb:feat/sha256-u4-midstate-boundary

Conversation

@brenorb

@brenorb brenorb commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a u4 SHA-256 continuation for a caller-supplied midstate after a fixed 64-byte prefix
  • add independent midstate/digest correctness coverage, strict stack coverage, and excess-witness rejection
  • record the 332,830-byte fragment, 48-byte witness, 969-item peak, and 195,219 static non-push opcodes

The fragment does not authenticate the supplied state against the prefix; callers must bind that relationship. The measured script exceeds ordinary script-size and policy limits, so deployment remains unclassified.

Tests

  • python3 tools/kb.py validate
  • cargo test --locked hashes::sha256::sha2_u4::tests::test_sha256_80bytes_from_midstate -- --nocapture
  • cargo test --locked --test primitive_metrics (6 passed, 1 ignored)
  • full repository test suite intentionally not run

Copy link
Copy Markdown
Contributor

Review: hold pending the changes below.

Combine this with #67 into a consistent SHA256 midstate contract, and align continuation semantics with #71/#73. Share padding/byte-order vectors and add active focused metrics.

Historical local validation (September 11, at this unchanged PR head): python3 tools/kb.py validate passed; 8 selected library tests passed. These are targeted local checks, not a full-suite or complete-spend validation. Results using a stack-limit-disabled execution helper remain research-unlimited.

Rebase on current main, address the specific gaps above, and run the affected correctness and active metric checks. Broad/full-repository runs are not requested.

Reviewed commit: ffd88b18ed86766eb172744b7001ae48723c1e5d.

@brenorb

brenorb commented Sep 18, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #67.\n\nThe implementation and evidence are preserved in #67's consolidated SHA-256 midstate contract for both u32 and u4 backends. That update uses one real 64-byte-prefix midstate fixture, the same 16-byte suffix vectors, the 640-bit final length, active focused metric coverage, and the corrected witness/stack documentation.

@brenorb brenorb closed this Sep 18, 2026
@brenorb
brenorb deleted the feat/sha256-u4-midstate-boundary branch October 28, 2026 02:57
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