bip322-js is a TypeScript/JavaScript library providing utility functions for the BIP-322 signature scheme, enabling generic message signing and verification across various Bitcoin address types. It supports P2PKH, P2SH-P2WPKH, P2WPKH, and single-key-spend P2TR addresses on mainnet, testnet, and regtest. The current stable version is 3.0.0, released in April 2025. A key differentiator is its 'Loose BIP-137 Verification' by default, which allows backward compatibility with legacy BIP-137 signatures, even if they have non-standard header flags, by assuming ownership of the private key for all derivable addresses. It also provides functionalities to generate raw `toSpend` and `toSign` BIP-322 transactions.
npm install bip322-jsVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to sign a message using a private key for a P2WPKH address and then verify the generated signature, including an example of toggling strict BIP-137 verification.
Ensure your code expects a `string` (Base64-encoded) return type from `Signer.sign` for all address types. If you need a Buffer, decode the Base64 string.
Remove the `network` argument from `Signer.sign` calls. The library will infer the network (mainnet, testnet, regtest) from the address string.
Update imports and calls to `Key.compressPublicKey` and `Key.uncompressPublicKey` respectively.
Do not rely on byte-for-byte comparison of Taproot BIP-322 signatures. Instead, use `Verifier.verifySignature()` to validate signatures, which correctly handles non-deterministic outputs.
To enforce strict BIP-137 verification, pass `true` as the fourth argument to `Verifier.verifySignature(address, message, signature, true)`.
Be aware of this behavior when interacting with systems that enforce strict adherence to BIP-137 and BIP-322 specifications regarding taproot addresses. For strict verification, consider using the `useStrictVerification` flag where applicable or ensuring a clear understanding of the expected signature scheme.
Remove the `network` argument. The function now infers the network directly from the provided Bitcoin address. E.g., `Signer.sign(privateKey, address, message)`.
These functions have been moved to the `Key` class. Use `Key.compressPublicKey` or `Key.uncompressPublicKey` instead.
Update your code to expect a `string` (Base64-encoded) return from `Signer.sign` for all address types. If a Buffer is needed, decode the Base64 string, e.g., `Buffer.from(signature, 'base64')`.
This is expected behavior and does not indicate an invalid signature. Instead of byte-for-byte comparison, always use `Verifier.verifySignature()` to validate the signature.
No dependency data recorded yet.