{"_id":"bip322-js","_rev":"11-50c243b1ba550010e8f642646f5e1dc2","name":"bip322-js","dist-tags":{"latest":"4.0.0"},"versions":{"1.0.2":{"name":"bip322-js","version":"1.0.2","keywords":["bip322","bitcoinjs","javascript","typescript","no-WASM"],"author":{"name":"Ken Sze","email":"acken2@outlook.com"},"license":"MIT","_id":"bip322-js@1.0.2","maintainers":[{"name":"acken2","email":"acken2@outlook.com"}],"homepage":"https://github.com/ACken2/bip322-js#readme","bugs":{"url":"https://github.com/ACken2/bip322-js/issues"},"dist":{"shasum":"6f4e959532de62dd9587e113bdab84450a4b3b1c","tarball":"https://registry.npmjs.org/bip322-js/-/bip322-js-1.0.2.tgz","fileCount":36,"integrity":"sha512-q1kTkJ+4ljkq23hVWTheCgfl5nB8CuWf6Ouc2ocHsvgeGDuXd4nwSVQeGqtdqXldN2yngcKbLl7/sKX0kTJ+Ow==","signatures":[{"sig":"MEYCIQCwi/buABAvdezwEaGLiJ53qW5Afkqftl/y8SwIjacGWgIhALJ9Ck4Cio6m2Jqdma3Yge5zp25K7lEHRAQBo0UHFws+","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":87117},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"be14702eb0c14361b2bed1c54ce08ad86317d053","scripts":{"doc":"typedoc src/index.ts","test":"ts-mocha 'test/**/*.test.ts'","build":"tsc","prepack":"npm run build","test:coverage":"nyc --reporter=text --reporter=text-summary --reporter=lcov npm test"},"_npmUser":{"name":"acken2","email":"acken2@outlook.com"},"repository":{"url":"git+https://github.com/ACken2/bip322-js.git","type":"git"},"_npmVersion":"9.6.7","description":"A Javascript library that provides utility functions related to the BIP-322 signature scheme","directories":{},"_nodeVersion":"18.16.0","dependencies":{"ecpair":"^2.1.0","fast-sha256":"^1.3.0","bitcoinjs-lib":"^6.1.1","bitcoinjs-message":"^2.2.0","@bitcoinerlab/secp256k1":"^1.0.2"},"_hasShrinkwrap":false,"devDependencies":{"nyc":"^15.1.0","chai":"^4.3.7","mocha":"^10.2.0","typedoc":"^0.24.8","ts-mocha":"^10.0.0","chai-bytes":"^0.1.2","typescript":"^5.1.3","@types/chai":"^4.3.5","@types/node":"^20.2.5","@types/mocha":"^10.0.1"},"_npmOperationalInternal":{"tmp":"tmp/bip322-js_1.0.2_1687938375477_0.030753570195440005","host":"s3://npm-registry-packages"}},"1.0.3":{"name":"bip322-js","version":"1.0.3","keywords":["bip322","bitcoinjs","javascript","typescript","no-WASM"],"author":{"name":"Ken Sze","email":"acken2@outlook.com"},"license":"MIT","_id":"bip322-js@1.0.3","maintainers":[{"name":"acken2","email":"acken2@outlook.com"}],"homepage":"https://github.com/ACken2/bip322-js#readme","bugs":{"url":"https://github.com/ACken2/bip322-js/issues"},"dist":{"shasum":"f3672dedfa73eeca9012ef1342cbd3cd7876dc5c","tarball":"https://registry.npmjs.org/bip322-js/-/bip322-js-1.0.3.tgz","fileCount":36,"integrity":"sha512-EU0nmkNsxo5X6PQx6hNAXjpkJatHppHWY7lOo+w+SxESaCLAeyentHkUkfDYSF/BDnMy+U/pPDfodKWmamwVzw==","signatures":[{"sig":"MEYCIQD4JYMnTi/J4XwZKeMf8LotYiCFQNrYBY7L8eWwohY7AwIhAPGffc8P8xiIX/0W6yXtxAVvRgzksjfjIi59Xz7dOURh","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":87956},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"84b5b1c002f4c8b8c5dd12e622d854cb54716fc4","scripts":{"doc":"typedoc src/index.ts","test":"ts-mocha 'test/**/*.test.ts'","build":"tsc","prepack":"npm run build","test:coverage":"nyc --reporter=text --reporter=text-summary --reporter=lcov npm test"},"_npmUser":{"name":"acken2","email":"acken2@outlook.com"},"repository":{"url":"git+https://github.com/ACken2/bip322-js.git","type":"git"},"_npmVersion":"9.6.7","description":"A Javascript library that provides utility functions related to the BIP-322 signature scheme","directories":{},"_nodeVersion":"18.16.0","dependencies":{"ecpair":"^2.1.0","fast-sha256":"^1.3.0","bitcoinjs-lib":"^6.1.1","bitcoinjs-message":"^2.2.0","@bitcoinerlab/secp256k1":"^1.0.2"},"_hasShrinkwrap":false,"devDependencies":{"nyc":"^15.1.0","chai":"^4.3.7","mocha":"^10.2.0","typedoc":"^0.24.8","ts-mocha":"^10.0.0","chai-bytes":"^0.1.2","typescript":"^5.1.3","@types/chai":"^4.3.5","@types/node":"^20.2.5","@types/mocha":"^10.0.1"},"_npmOperationalInternal":{"tmp":"tmp/bip322-js_1.0.3_1688014572512_0.931352400729133","host":"s3://npm-registry-packages"}},"1.1.0":{"name":"bip322-js","version":"1.1.0","keywords":["bip322","bitcoinjs","javascript","typescript","no-WASM"],"author":{"name":"Ken Sze","email":"acken2@outlook.com"},"license":"MIT","_id":"bip322-js@1.1.0","maintainers":[{"name":"acken2","email":"acken2@outlook.com"}],"homepage":"https://github.com/ACken2/bip322-js#readme","bugs":{"url":"https://github.com/ACken2/bip322-js/issues"},"dist":{"shasum":"1c827a5d749080a897ec380f103fa12a1d67743b","tarball":"https://registry.npmjs.org/bip322-js/-/bip322-js-1.1.0.tgz","fileCount":39,"integrity":"sha512-Nxyw4lnhh4qm/zitfagJYpO7HofkABbt7Cce+Wiy4PGeilJ/hOvtqM0pxmTZxMoOhRnvDPZ55NzkFPrsyq43ew==","signatures":[{"sig":"MEUCIQDk86pCA15AndrQYWMDusZw7FiSMiJ4zHYSthIop9DDbwIgefOjDq41qK5S/aAux18JuW8lY2JLA4XoMbqHAjS5k1c=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":99911},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"159456f44f31f0b38097b957bbe75c0eae4971bf","scripts":{"doc":"typedoc src/index.ts","test":"ts-mocha 'test/**/*.test.ts'","build":"tsc","prepack":"npm run build","test:coverage":"nyc --reporter=text --reporter=text-summary --reporter=lcov npm test"},"_npmUser":{"name":"acken2","email":"acken2@outlook.com"},"repository":{"url":"git+https://github.com/ACken2/bip322-js.git","type":"git"},"_npmVersion":"9.6.7","description":"A Javascript library that provides utility functions related to the BIP-322 signature scheme","directories":{},"_nodeVersion":"18.16.0","dependencies":{"ecpair":"^2.1.0","secp256k1":"^5.0.0","fast-sha256":"^1.3.0","bitcoinjs-lib":"^6.1.1","bitcoinjs-message":"^2.2.0","@bitcoinerlab/secp256k1":"^1.0.2"},"_hasShrinkwrap":false,"devDependencies":{"nyc":"^15.1.0","chai":"^4.3.7","mocha":"^10.2.0","typedoc":"^0.24.8","ts-mocha":"^10.0.0","chai-bytes":"^0.1.2","typescript":"^5.1.3","@types/chai":"^4.3.5","@types/node":"^20.2.5","@types/mocha":"^10.0.1","@types/secp256k1":"^4.0.3"},"_npmOperationalInternal":{"tmp":"tmp/bip322-js_1.1.0_1692512974967_0.9529188682197851","host":"s3://npm-registry-packages"}},"1.1.1":{"name":"bip322-js","version":"1.1.1","keywords":["bip322","bitcoinjs","javascript","typescript","no-WASM"],"author":{"name":"Ken Sze","email":"acken2@outlook.com"},"license":"MIT","_id":"bip322-js@1.1.1","maintainers":[{"name":"acken2","email":"acken2@outlook.com"}],"homepage":"https://github.com/ACken2/bip322-js#readme","bugs":{"url":"https://github.com/ACken2/bip322-js/issues"},"dist":{"shasum":"fd7891e4d3679601ec1b3d4f848dc0a08d435dee","tarball":"https://registry.npmjs.org/bip322-js/-/bip322-js-1.1.1.tgz","fileCount":39,"integrity":"sha512-e++avAwHuVhygO6w6BqAYs5BdR4mAtm5z/eKaGwBQqu2YseXzuVxRxyVMspZdVpp58BUatyTTW5hVtFO/IpsiA==","signatures":[{"sig":"MEUCIQDZ620L5Il02HcEilbNZLCBUeO+uybdbLrVrhChmC5iaAIgNorYTvJxa0mv8IKn2nYwj931WsLknGkpaxqhB/jraUU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":117789},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"2ef55a581c52b62e0112ec89800af6282bb44cb4","scripts":{"doc":"typedoc src/index.ts","test":"ts-mocha 'test/**/*.test.ts'","build":"tsc","prepack":"npm run build","test:coverage":"nyc --reporter=text --reporter=text-summary --reporter=lcov npm test"},"_npmUser":{"name":"acken2","email":"acken2@outlook.com"},"repository":{"url":"git+https://github.com/ACken2/bip322-js.git","type":"git"},"_npmVersion":"10.2.3","description":"A Javascript library that provides utility functions related to the BIP-322 signature scheme","directories":{},"_nodeVersion":"20.10.0","dependencies":{"ecpair":"^2.1.0","elliptic":"^6.5.5","secp256k1":"^5.0.0","fast-sha256":"^1.3.0","bitcoinjs-lib":"^6.1.1","bitcoinjs-message":"^2.2.0","@bitcoinerlab/secp256k1":"^1.0.2"},"_hasShrinkwrap":false,"devDependencies":{"nyc":"^15.1.0","chai":"^4.3.7","mocha":"^10.2.0","typedoc":"^0.24.8","ts-mocha":"^10.0.0","chai-bytes":"^0.1.2","typescript":"^5.1.3","@types/chai":"^4.3.5","@types/node":"^20.2.5","@types/mocha":"^10.0.1","@types/elliptic":"^6.4.18","@types/secp256k1":"^4.0.3"},"_npmOperationalInternal":{"tmp":"tmp/bip322-js_1.1.1_1712299029841_0.4637231743283634","host":"s3://npm-registry-packages"}},"2.0.0":{"name":"bip322-js","version":"2.0.0","keywords":["bip322","bitcoinjs","javascript","typescript","no-WASM"],"author":{"name":"Ken Sze","email":"acken2@outlook.com"},"license":"MIT","_id":"bip322-js@2.0.0","maintainers":[{"name":"acken2","email":"acken2@outlook.com"}],"homepage":"https://github.com/ACken2/bip322-js#readme","bugs":{"url":"https://github.com/ACken2/bip322-js/issues"},"dist":{"shasum":"827126d5563c21795d2be51b088a3734996b4fcf","tarball":"https://registry.npmjs.org/bip322-js/-/bip322-js-2.0.0.tgz","fileCount":42,"integrity":"sha512-wyewxyCLl+wudZWiyvA46SaNQL41dVDJ+sx4HvD6zRXScHzAycwuKEMmbvr2qN+P/IIYArF4XVqlyZVnjutELQ==","signatures":[{"sig":"MEUCIEU7ArOVgZmdEegSzsqsTjs3qHErd9G1awvHKWLuHKtvAiEAj3rObJhOGJlRESdLHF9Db1ijwkPQE/Je1bk7rO/bQQo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":130661},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"f0f9373b3a1da19e017c518b891522eaa4bcccdd","scripts":{"doc":"typedoc src/index.ts","test":"ts-mocha 'test/**/*.test.ts'","build":"tsc","prepack":"npm run build","test:coverage":"nyc --reporter=text --reporter=text-summary --reporter=lcov npm test"},"_npmUser":{"name":"acken2","email":"acken2@outlook.com"},"repository":{"url":"git+https://github.com/ACken2/bip322-js.git","type":"git"},"_npmVersion":"10.7.0","description":"A Javascript library that provides utility functions related to the BIP-322 signature scheme","directories":{},"_nodeVersion":"20.10.0","dependencies":{"ecpair":"^2.1.0","elliptic":"^6.5.5","secp256k1":"^5.0.0","fast-sha256":"^1.3.0","bitcoinjs-lib":"^6.1.5","bitcoinjs-message":"^2.2.0","@bitcoinerlab/secp256k1":"^1.1.1"},"_hasShrinkwrap":false,"devDependencies":{"nyc":"^15.1.0","chai":"^4.3.7","mocha":"^10.4.0","typedoc":"^0.25.13","ts-mocha":"^10.0.0","chai-bytes":"^0.1.2","typescript":"^5.4.5","@types/chai":"^4.3.5","@types/node":"^20.12.12","@types/mocha":"^10.0.6","@types/elliptic":"^6.4.18","@types/secp256k1":"^4.0.6"},"_npmOperationalInternal":{"tmp":"tmp/bip322-js_2.0.0_1715845637951_0.29136550434037","host":"s3://npm-registry-packages"}},"3.0.0":{"name":"bip322-js","version":"3.0.0","keywords":["bip322","bitcoinjs","javascript","typescript","no-WASM"],"author":{"name":"Ken Sze","email":"acken2@outlook.com"},"license":"MIT","_id":"bip322-js@3.0.0","maintainers":[{"name":"acken2","email":"acken2@outlook.com"}],"homepage":"https://github.com/ACken2/bip322-js#readme","bugs":{"url":"https://github.com/ACken2/bip322-js/issues"},"dist":{"shasum":"06077f1114be6ea01278feb493c2ace69306630b","tarball":"https://registry.npmjs.org/bip322-js/-/bip322-js-3.0.0.tgz","fileCount":45,"integrity":"sha512-v57yQsdlK3ch2r7tyy0+Sas8Ut7GXwsE+GnYJu+IO5HlAu77lQhWu0fKdjaao9clGBzo5HgAsABs4f7UkXtXIA==","signatures":[{"sig":"MEUCIFHPT2QT25QkGh3wYlrZnT6hZTA2GIkrK8f3bUoY+kcBAiEAudemHJZci6dgU5WiCQo6qFPrPKIcKR51lGv7Z6iocFo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":134167},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"7ebcf0a48e5e0d73d464b331c821ec8e78ba530c","scripts":{"doc":"typedoc src/index.ts","test":"ts-mocha 'test/**/*.test.ts'","build":"tsc","prepack":"npm run build","test:coverage":"nyc --reporter=text --reporter=text-summary --reporter=lcov npm test"},"_npmUser":{"name":"acken2","email":"acken2@outlook.com"},"repository":{"url":"git+https://github.com/ACken2/bip322-js.git","type":"git"},"_npmVersion":"11.3.0","description":"A Javascript library that provides utility functions related to the BIP-322 signature scheme","directories":{},"_nodeVersion":"22.14.0","dependencies":{"ecpair":"^2.1.0","elliptic":"^6.6.1","secp256k1":"^5.0.1","fast-sha256":"^1.3.0","bitcoinjs-lib":"^6.1.7","bitcoinjs-message":"^2.2.0","@bitcoinerlab/secp256k1":"^1.2.0"},"_hasShrinkwrap":false,"devDependencies":{"nyc":"^15.1.0","chai":"^4.3.7","mocha":"^10.4.0","typedoc":"^0.25.13","ts-mocha":"^10.0.0","chai-bytes":"^0.1.2","typescript":"^5.4.5","@types/chai":"^4.3.5","@types/node":"^20.12.12","@types/mocha":"^10.0.6","@types/elliptic":"^6.4.18","@types/secp256k1":"^4.0.6"},"_npmOperationalInternal":{"tmp":"tmp/bip322-js_3.0.0_1745755826482_0.34211940458384804","host":"s3://npm-registry-packages-npm-production"}},"4.0.0":{"name":"bip322-js","version":"4.0.0","description":"A Javascript library that provides utility functions related to the BIP-322 signature scheme","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","doc":"typedoc src/index.ts","prepack":"npm run build","test":"ts-mocha 'test/**/*.test.ts'","test:coverage":"nyc --reporter=text --reporter=text-summary --reporter=lcov npm test","test:pack":"node scripts/smoke-pack.js"},"keywords":["bip322","bitcoinjs","javascript","typescript","no-WASM"],"engines":{"node":">=20.19.0"},"author":{"name":"Ken Sze","email":"acken2@outlook.com"},"repository":{"type":"git","url":"git+https://github.com/ACken2/bip322-js.git"},"license":"MIT","devDependencies":{"@types/chai":"^4.3.5","@types/mocha":"^10.0.10","@types/node":"^20.19.43","bitcoinjs-message":"^2.2.0","chai":"^4.5.0","chai-bytes":"^0.1.2","mocha":"^11.8.0","nyc":"^18.0.0","ts-mocha":"^11.1.0","ts-node":"^10.9.2","typedoc":"^0.28.20","typescript":"~5.9.3"},"dependencies":{"@bitcoinerlab/secp256k1":"^1.2.0","@noble/curves":"^2.3.0","@noble/hashes":"^2.3.0","bitcoinjs-lib":"^7.0.1","ecpair":"^3.0.1","fast-sha256":"^1.3.0"},"gitHead":"b9cc205351737fe50fe877a6c67c40324cfb1449","_id":"bip322-js@4.0.0","bugs":{"url":"https://github.com/ACken2/bip322-js/issues"},"homepage":"https://github.com/ACken2/bip322-js#readme","_nodeVersion":"24.16.0","_npmVersion":"11.13.0","dist":{"integrity":"sha512-84DYLDeOSFG8M9S49DIimmoZjYGiAkbRBkthUd0G8PQ3Fh8+878JlKBkk7dNwiE4RM/FZqlFGxxG91K3wcWJ3Q==","shasum":"d5bc1863ad2571d2a457dbe04a89d39fd34f82b6","tarball":"https://registry.npmjs.org/bip322-js/-/bip322-js-4.0.0.tgz","fileCount":48,"unpackedSize":158285,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDWxNtgmJQmzgd4GCjfm0NxmIy3SKap1mRPpQsrsRvqDgIhAPGWiFd7HZBtXPRfsOZIs4zXXAAXgEfIhlTHLMkfnwdO"}]},"_npmUser":{"name":"acken2","email":"acken2@outlook.com"},"directories":{},"maintainers":[{"name":"acken2","email":"acken2@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/bip322-js_4.0.0_1787302307114_0.6084752331225607"},"_hasShrinkwrap":false}},"time":{"created":"2023-06-28T06:57:44.880Z","modified":"2026-08-21T08:51:47.478Z","1.0.0":"2023-06-27T05:38:35.310Z","1.0.1":"2023-06-28T06:57:45.102Z","1.0.2":"2023-06-28T07:46:15.734Z","1.0.3":"2023-06-29T04:56:12.684Z","1.1.0":"2023-08-20T06:29:35.134Z","1.1.1":"2024-04-05T06:37:10.002Z","2.0.0":"2024-05-16T07:47:18.097Z","3.0.0":"2025-04-27T12:10:26.663Z","4.0.0":"2026-08-21T08:51:47.274Z"},"bugs":{"url":"https://github.com/ACken2/bip322-js/issues"},"author":{"name":"Ken Sze","email":"acken2@outlook.com"},"license":"MIT","homepage":"https://github.com/ACken2/bip322-js#readme","keywords":["bip322","bitcoinjs","javascript","typescript","no-WASM"],"repository":{"type":"git","url":"git+https://github.com/ACken2/bip322-js.git"},"description":"A Javascript library that provides utility functions related to the BIP-322 signature scheme","maintainers":[{"name":"acken2","email":"acken2@outlook.com"}],"readme":"# BIP322-JS\n\n![Unit Test Status](https://github.com/ACken2/bip322-js/actions/workflows/unit_test.yml/badge.svg)\n[![Coverage Status](https://coveralls.io/repos/github/ACken2/bip322-js/badge.svg?branch=main)](https://coveralls.io/github/ACken2/bip322-js?branch=main)\n\nA Javascript library that provides utility functions related to the BIP-322 signature scheme.\n\n## Documentation\n\nAvailable at https://acken2.github.io/bip322-js/\n\n## Supported Features\n\nThe following features are supported on mainnet, testnet, and regtest \nfor P2PKH, P2SH-P2WPKH, P2WPKH, and single-key-spend P2TR addresses:\n\n1. Generate raw toSpend and toSign BIP-322 transactions.\n2. Sign a BIP-322 signature using a private key.\n3. Verify a legacy BIP-137 signature loosely (see below).\n4. Verify a simple BIP-322 signature.\n\n## Usage\n\nUse the **Signer** class to sign a BIP-322 signature:\n```js\nSigner.sign(privateKey, address, message)\n```\n\nUse the **Verifier** class to verify a BIP-322 signature (which also validates a BIP-137 signature):\n```js\nVerifier.verifySignature(address, message, signature)\n```\n\n## Loose BIP-137 Verification\n\nA BIP-322 signature is backward compatible with the legacy signature scheme (i.e., BIP-137 signature). \nAs a result, this library also recognizes valid BIP-137 signatures.\n\nIn a BIP-137 signature, a header flag indicates the type of Bitcoin address for which the signature is signed:\n- 27-30: P2PKH uncompressed\n- 31-34: P2PKH compressed\n- 35-38: Segwit P2SH\n- 39-42: Segwit Bech32\n\nHowever, some wallets' implementations of the BIP-137 signature did not strictly follow this header flag specification, \nand some may have signed signatures with the wrong header (e.g., using header 27 for a native segwit address).\n\nIt is trivial, however, to convert a BIP-137 signature with an incorrect header flag to one with the correct header \nflag since the \"address type\" component in the header flag is not part of the actual signature.\n\nAs such, some BIP-137 signature verifiers online, such as [this one](https://www.verifybitcoinmessage.com/), \nactively help to swap out any erroneous header flags.\n\nThis library defines this behavior as **\"Loose BIP-137 Verification\"**.\n\nThis behavior assumes that a signature proving ownership of the private key associated with public key $X$ \nis valid for all addresses $y_1$, $y_2$, ..., $y_n$ derivable from the same public key $X$.\n\nThis behavior is enabled by default in this library, but can be disabled by passing the \noptional useStrictVerification flag in Verifier.verifySignature:\n\n```js\nVerifier.verifySignature(signerAddress, message, signatureBase64, true)\n```\n\nConsequently, this also allows BIP-137 signatures to be used for taproot addresses, which is technically out-of-spec \naccording to both BIP-137 and BIP-322 specifications, as implemented by some wallet implementations. \nPlease refer to [issue #1](https://github.com/ACken2/bip322-js/issues/1) for relevant discussions.\n\nNote that this behavior does not exist in actual BIP-322 signature due to how BIP-322 signature is constructed.\n\n## Example\n\n```js\n// Import modules that are useful to you\nconst { BIP322, Signer, Verifier } = require('bip322-js');\n\n// Signing a BIP-322 signature with a private key\nconst privateKey = 'L3VFeEujGtevx9w18HD1fhRbCH67Az2dpCymeRE1SoPK6XQtaN2k';\nconst address = 'bc1q9vza2e8x573nczrlzms0wvx3gsqjx7vavgkx0l'; // P2WPKH address\nconst addressTestnet = 'tb1q9vza2e8x573nczrlzms0wvx3gsqjx7vaxwd45v'; // Equivalent testnet address\nconst addressRegtest = 'bcrt1q9vza2e8x573nczrlzms0wvx3gsqjx7vay85cr9'; // Equivalent regtest address\nconst taprootAddress = 'bc1ppv609nr0vr25u07u95waq5lucwfm6tde4nydujnu8npg4q75mr5sxq8lt3'; // P2TR address\nconst nestedSegwitAddress = '37qyp7jQAzqb2rCBpMvVtLDuuzKAUCVnJb'; // P2SH-P2WPKH address\nconst message = 'Hello World';\nconst signature = Signer.sign(privateKey, address, message);\nconst signatureTestnet = Signer.sign(privateKey, addressTestnet, message); // Wworks with testnet address\nconst signatureRegtest = Signer.sign(privateKey, addressRegtest, message); // And regtest address\nconst signatureP2TR = Signer.sign(privateKey, taprootAddress, message); // Also works with P2TR address\nconst signatureP2SH = Signer.sign(privateKey, nestedSegwitAddress, message); // And P2SH-P2WPKH address\nconsole.log({ signature, signatureTestnet, signatureRegtest, signatureP2TR, signatureP2SH });\n\n// Verifying a simple BIP-322 signature\nconst validity = Verifier.verifySignature(address, message, signature);\nconst validityTestnet = Verifier.verifySignature(addressTestnet, message, signatureTestnet); // Works with testnet address\nconst validityRegtest = Verifier.verifySignature(addressRegtest, message, signatureRegtest); // And regtest address\nconst validityP2TR = Verifier.verifySignature(taprootAddress, message, signatureP2TR); // Also works with P2TR address\nconst validityP2SH = Verifier.verifySignature(nestedSegwitAddress, message, signatureP2SH); // And P2SH-P2WPKH address\nconsole.log({ validity, validityTestnet, validityRegtest, validityP2TR, validityP2SH }); // True\n\n// You can also get the raw unsigned BIP-322 toSpend and toSign transaction directly\nconst scriptPubKey = Buffer.from('00142b05d564e6a7a33c087f16e0f730d1440123799d', 'hex');\nconst toSpend = BIP322.buildToSpendTx(message, scriptPubKey); // bitcoin.Transaction\nconst toSpendTxId = toSpend.getId();\nconst toSign = BIP322.buildToSignTx(toSpendTxId, scriptPubKey); // bitcoin.Psbt\n// Do whatever you want to do with the PSBT\n```\n\nMore working examples can be found within the unit test for BIP322, Signer, and Verifier.\n\n## ⚠️ Breaking Change and Migration Guide\n\n### From v1.X\n\n1. If you previously used `Address.compressPublicKey` or `Address.uncompressPublicKey`, \nreplace them with `Key.compressPublicKey` and `Key.uncompressPublicKey` respectively.\n\n2. In v1.X, there was an option to pass the `network` parameter into `Signer.sign`: `Signer.sign(privateKey, address, message, network)`. \nThis option has been removed, as the network is now automatically inferred from the given address.\n\n### From v2.X\n\n1. If your code depended on receiving a Buffer from `Signer.sign` for P2PKH addresses, you must update it to handle the returned Base64-encoded string instead.\n\n2. Signature Handling: Version 1.2.0 of the underlying `@bitcoinerlab/secp256k1` library introduced a change to signSchnorr. It now incorporates secure random data (auxRand) by default during Schnorr signature generation (used in BIP-322), whereas previous versions might have produced deterministic outputs under certain conditions. This means signing the same message with the same key will now yield different, but equally valid, signature bytes each time.\n\n### From v3.X\n\nThis library now depends on `bitcoinjs-lib` 7 and `ecpair` 3.\n\n1. If you use `BIP322.buildToSpendTx` or `BIP322.buildToSignTx` and inspect the returned `bitcoin.Transaction` / `bitcoin.Psbt` objects, treat amounts as `bigint` (`value: 0n`, not `value: 0`) and treat binary fields (`script`, `witness`, keys) as `Uint8Array`.\n\n2. Package-owned helpers such as `Address.convertAdressToScriptPubkey` and `BitcoinMessage.sign` still return Node.js `Buffer`. High-level `Signer.sign` and `Verifier.verifySignature` still accept strings/`Buffer` messages and return or consume Base64 signature strings.\n\n3. Buffer inputs remain accepted where they were accepted before. You do not need to convert caller-owned Buffers to `Uint8Array` before passing them into this library.\n\n4. The package now declares `engines.node` of `>=20.19.0`, required by `@noble/curves` and `@noble/hashes` 2.x. `ecpair` 3 also requires Node.js 20 or later. Node.js 18 and earlier are unsupported.\n\n5. Compiled JavaScript now targets ES2020 (for example, `0n` bigint literals). Downstream TypeScript projects targeting an older `lib`/`target` may need to bump those settings.\n\n6. Do not rely on `elliptic`, `secp256k1`, or `bitcoinjs-message` being installed via this package. They are no longer runtime dependencies. If you previously used `bitcoinjs-message` through this library, use the exported `BitcoinMessage` helper instead.","readmeFilename":"README.md"}