🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@dfx.swiss/bip322-multisig

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dfx.swiss/bip322-multisig

Build and sign BIP-322 simple signatures for Bitcoin P2WSH multisig wallets via PSBT

latest
Source
npmnpm
Version
0.2.0
Version published
Maintainers
2
Created
Source

@dfx.swiss/bip322-multisig

Build and verify BIP-322 simple signatures for Bitcoin P2WSH multisig wallets via PSBT. Provides both a JavaScript / TypeScript library (Node + browser) and CLI binaries.

Installation

npm install @dfx.swiss/bip322-multisig

Requires Node.js ≥ 18 (uses native fetch in the CLI).

CLI

After global install, two commands are available:

npm install -g @dfx.swiss/bip322-multisig

bip322-sign \
  --descriptor 'wsh(sortedmulti(2,[fp1/48h/0h/0h/2h]xpub.../<0;1>/*,...))' \
  --address bc1q...

# Sign the resulting PSBT in Sparrow with the threshold number of cosigners,
# save it as signed.psbt, then:

bip322-finalize --psbt signed.psbt --address bc1q...

Both commands accept --api <baseUrl> (default https://api.dfx.swiss) and bip322-finalize accepts --no-submit to print the signature without contacting the API.

Library

import {
  parseDescriptor,
  findAddress,
  buildBip322Psbt,
  extractBip322Signature,
} from '@dfx.swiss/bip322-multisig';

// Build a BIP-322 to_sign PSBT for a given P2WSH multisig address
const built = buildBip322Psbt({
  message: 'challenge string from server',
  descriptor: 'wsh(sortedmulti(2,[fp1/48h/0h/0h/2h]xpub.../<0;1>/*,...))',
  address: 'bc1q...',
});
// → built.psbtBase64, built.toSpendTxid, built.derived

// After the PSBT has been signed (e.g. by Sparrow + hardware wallets):
const signatureBase64 = extractBip322Signature(signedPsbtBase64);

Scope

SupportedNot supported
wsh(sortedmulti(t, …)) descriptors with key origin infoNon-multisig descriptors
Both h and ' hardened path notationsMiniscript / Taproot policies
Whitespace and newlines in descriptor inputTestnet / signet (tpub)
BIP-389 multipath <0;1>/* (receive + change branches)Multipath with > 2 branches
Standard OP_M … OP_N OP_CHECKMULTISIG witness scriptsNon-standard witness scripts

How it works

BIP-322 defines a generic message-signing scheme by constructing two virtual transactions: to_spend commits the message to the address, and to_sign spends to_spend. The simple-format signature is just the witness stack of to_sign's input, base64-encoded.

This package builds to_sign as a regular PSBT with all the BIP32 derivation paths, witness UTXO, witness script, and sighash type that hardware wallets need to sign. Sparrow (or any other coordinator) handles the multisig orchestration via its standard PSBT-signing flow; this package extracts the resulting witness as a BIP-322 simple signature.

License

MIT

FAQs

Package last updated on 01 Jul 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts