feat(bip322-multisig): add BIP-322 P2WSH signature verification#175
Merged
TaprootFreak merged 3 commits intodevelopfrom Apr 30, 2026
Merged
feat(bip322-multisig): add BIP-322 P2WSH signature verification#175TaprootFreak merged 3 commits intodevelopfrom
TaprootFreak merged 3 commits intodevelopfrom
Conversation
Add verifyBip322P2wshSignature() and isP2wshAddress() for server-side validation of BIP-322 simple signatures from P2WSH multisig wallets. - New src/verify.ts with DER parsing, witness stack decoding, and OP_CHECKMULTISIG verification using @noble/curves/secp256k1 - 16 tests covering address validation, roundtrip sign/verify, under-threshold rejection, wrong-message rejection, foreign-key rejection - Bump version to 0.2.0-beta.1
4 tasks
davidleomay
approved these changes
Apr 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
The
@dfx.swiss/bip322-multisigpackage currently only provides building and signing primitives (bip322MessageHash,buildToSpendTx,buildToSignPsbt,extractBip322Signature, etc.). It has no verification capability.In DFXswiss/api#3637, we added BIP-322 P2WSH multisig auth support. The verification logic currently lives as a standalone
bip322-p2wsh.util.tsfile in the API repo (~190 lines). Review feedback asks to remove that file and use this package instead.This PR adds the missing verification functions so the API can replace the custom util file with a single package import.
Changes
New module
src/verify.tsexporting:isP2wshAddress(address)— mainnet P2WSH bech32 address detection (witness v0, 32-byte program)verifyBip322P2wshSignature(message, address, signatureBase64)— full BIP-322 simple signature verification for standard P2WSH multisig (OP_M ... OP_N OP_CHECKMULTISIG)Internally uses existing
core.tsprimitives (bip322MessageHash,buildToSpendTx,p2wshScriptPubKey) +bitcoinjs-libTransaction.hashForWitnessV0for sighash computation. ECDSA verification via@noble/curves/secp256k1.New dependency:
@noble/curves@^2.2.0Tests
16 tests in
src/__tests__/verify.test.ts: