Skip to content

feat(script): add crypto and signature verification opcodes#67

Merged
sgbett merged 1 commit intomasterfrom
feature/61-crypto-signature-verification
Feb 12, 2026
Merged

feat(script): add crypto and signature verification opcodes#67
sgbett merged 1 commit intomasterfrom
feature/61-crypto-signature-verification

Conversation

@sgbett
Copy link
Owner

@sgbett sgbett commented Feb 12, 2026

Summary

  • Implement Phase 5 of the script interpreter ([Task 5] Crypto operations — hashing + signature verification #61): crypto operations and signature verification
  • Add hash opcodes: OP_RIPEMD160, OP_SHA1, OP_SHA256, OP_HASH160, OP_HASH256
  • Add OP_CODESEPARATOR with subscript tracking for sighash computation
  • Add OP_CHECKSIG / OP_CHECKSIGVERIFY with full BSV validation (FORKID, strict DER, low-S, NULLFAIL)
  • Add OP_CHECKMULTISIG / OP_CHECKMULTISIGVERIFY with classic Bitcoin M-of-N algorithm, NULLDUMMY enforcement
  • Add Digest.sha1 to primitives
  • Add subscript: parameter to Transaction#sighash for CODESEPARATOR support

Test plan

  • Hash operation unit tests (direct and via ASM evaluation)
  • P2PKH end-to-end: build tx, sign, verify through interpreter
  • P2PK end-to-end verification
  • CHECKSIGVERIFY with custom lock script
  • 1-of-2 and 2-of-2 multisig verification
  • Wrong-order signatures trigger NULLFAIL
  • Non-empty dummy element triggers NULLDUMMY
  • Encoding validation: missing FORKID, invalid pubkey
  • CODESEPARATOR basic test
  • Full suite: 906 examples, 0 failures
  • RuboCop clean

Closes #61

🤖 Generated with Claude Code

Implement Phase 5 of the script interpreter: hash operations
(RIPEMD160, SHA1, SHA256, HASH160, HASH256), CODESEPARATOR,
CHECKSIG, CHECKSIGVERIFY, CHECKMULTISIG, and CHECKMULTISIGVERIFY.

Includes FORKID enforcement, strict DER encoding, low-S validation,
NULLFAIL/NULLDUMMY rules, and M-of-N multisig with the classic
Bitcoin off-by-one algorithm. Adds subscript support to
Transaction#sighash for CODESEPARATOR, and Digest.sha1.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Feb 12, 2026

Codecov Report

❌ Patch coverage is 88.09524% with 15 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
lib/bsv/script/interpreter/operations/crypto.rb 90.00% 10 Missing ⚠️
lib/bsv/script/interpreter/interpreter.rb 70.58% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

@sgbett sgbett merged commit a5fe863 into master Feb 12, 2026
7 checks passed
@sgbett sgbett deleted the feature/61-crypto-signature-verification branch February 12, 2026 19:40
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.

[Task 5] Crypto operations — hashing + signature verification

1 participant