Skip to content

Fix Script signature verification, boolean handling, and parsing - #6

Merged
OWK50GA merged 2 commits into
masterfrom
codex-cloud
Oct 20, 2026
Merged

OWK50GA merged 2 commits into
masterfrom
codex-cloud

Conversation

@OWK50GA

@OWK50GA OWK50GA commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fix three correctness issues in the Chapter 6 Script implementation:

  • Pop the public key before the signature in OP_CHECKSIG, matching the standard stack layout.
  • Use a shared Script boolean conversion for final evaluation and OP_VERIFY. Empty data, all-zero bytes, and negative zero evaluate as false; other values evaluate as true without numeric decoding.
  • Validate CompactSize prefixes, declared script lengths, and direct/PUSHDATA1/PUSHDATA2 pushes before reading. Truncated or out-of-bounds input returns InvalidData instead of panicking, and pushes cannot consume bytes beyond the declared script body.

Add regression tests for signature stack order, invalid and empty signatures, boolean encodings, malformed input, pushdata boundaries, and multi-byte length prefixes.

Apply rustfmt and remove a redundant borrow in TxOut::repr to satisfy CI's strict Clippy checks.

Validation

  • cargo fmt --all -- --check
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo build
  • cargo test (full suite, including Chapter 6 regressions)
  • git diff --check

@OWK50GA
OWK50GA merged commit b367362 into master Oct 20, 2026
10 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.

1 participant