@btc-vision/bitcoin 6.5.6 → 7.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HOW_TO_WRITE_GOOD_CODE.md +2436 -0
- package/benchmark/psbt-2000-inputs.bench.ts +178 -0
- package/benchmark/signing.bench.ts +147 -0
- package/browser/address.d.ts +57 -10
- package/browser/address.d.ts.map +1 -0
- package/browser/bech32utils.d.ts +9 -1
- package/browser/bech32utils.d.ts.map +1 -0
- package/browser/bip66.d.ts +11 -6
- package/browser/bip66.d.ts.map +1 -0
- package/browser/block.d.ts +117 -11
- package/browser/block.d.ts.map +1 -0
- package/browser/branded.d.ts +20 -0
- package/browser/branded.d.ts.map +1 -0
- package/browser/crypto/crypto.d.ts +1 -0
- package/browser/crypto/crypto.d.ts.map +1 -0
- package/browser/crypto.d.ts +46 -7
- package/browser/crypto.d.ts.map +1 -0
- package/browser/ecc/context.d.ts +129 -0
- package/browser/ecc/context.d.ts.map +1 -0
- package/browser/ecc/index.d.ts +11 -0
- package/browser/ecc/index.d.ts.map +1 -0
- package/browser/ecc/types.d.ts +128 -0
- package/browser/ecc/types.d.ts.map +1 -0
- package/browser/ecpair.d.ts +99 -0
- package/browser/errors.d.ts +124 -0
- package/browser/errors.d.ts.map +1 -0
- package/browser/index.d.ts +32 -5
- package/browser/index.d.ts.map +1 -0
- package/browser/index.js +12477 -101
- package/browser/io/BinaryReader.d.ts +276 -0
- package/browser/io/BinaryReader.d.ts.map +1 -0
- package/browser/io/BinaryWriter.d.ts +391 -0
- package/browser/io/BinaryWriter.d.ts.map +1 -0
- package/browser/io/MemoryPool.d.ts +220 -0
- package/browser/io/MemoryPool.d.ts.map +1 -0
- package/browser/io/base64.d.ts +13 -0
- package/browser/io/base64.d.ts.map +1 -0
- package/browser/io/hex.d.ts +67 -0
- package/browser/io/hex.d.ts.map +1 -0
- package/browser/io/index.d.ts +17 -0
- package/browser/io/index.d.ts.map +1 -0
- package/browser/io/utils.d.ts +199 -0
- package/browser/io/utils.d.ts.map +1 -0
- package/browser/merkle.d.ts +10 -1
- package/browser/merkle.d.ts.map +1 -0
- package/browser/networks.d.ts +70 -9
- package/browser/networks.d.ts.map +1 -0
- package/browser/opcodes.d.ts +1 -0
- package/browser/opcodes.d.ts.map +1 -0
- package/browser/payments/bip341.d.ts +35 -9
- package/browser/payments/bip341.d.ts.map +1 -0
- package/browser/payments/embed.d.ts +112 -1
- package/browser/payments/embed.d.ts.map +1 -0
- package/browser/payments/index.d.ts +17 -10
- package/browser/payments/index.d.ts.map +1 -0
- package/browser/payments/p2ms.d.ts +150 -0
- package/browser/payments/p2ms.d.ts.map +1 -0
- package/browser/payments/p2op.d.ts +150 -24
- package/browser/payments/p2op.d.ts.map +1 -0
- package/browser/payments/p2pk.d.ts +154 -1
- package/browser/payments/p2pk.d.ts.map +1 -0
- package/browser/payments/p2pkh.d.ts +176 -1
- package/browser/payments/p2pkh.d.ts.map +1 -0
- package/browser/payments/p2sh.d.ts +150 -1
- package/browser/payments/p2sh.d.ts.map +1 -0
- package/browser/payments/p2tr.d.ts +185 -1
- package/browser/payments/p2tr.d.ts.map +1 -0
- package/browser/payments/p2wpkh.d.ts +161 -1
- package/browser/payments/p2wpkh.d.ts.map +1 -0
- package/browser/payments/p2wsh.d.ts +146 -1
- package/browser/payments/p2wsh.d.ts.map +1 -0
- package/browser/payments/types.d.ts +94 -64
- package/browser/payments/types.d.ts.map +1 -0
- package/browser/psbt/bip371.d.ts +34 -8
- package/browser/psbt/bip371.d.ts.map +1 -0
- package/browser/psbt/psbtutils.d.ts +56 -16
- package/browser/psbt/psbtutils.d.ts.map +1 -0
- package/browser/psbt/types.d.ts +245 -0
- package/browser/psbt/types.d.ts.map +1 -0
- package/browser/psbt/utils.d.ts +64 -0
- package/browser/psbt/utils.d.ts.map +1 -0
- package/browser/psbt/validation.d.ts +84 -0
- package/browser/psbt/validation.d.ts.map +1 -0
- package/browser/psbt.d.ts +82 -118
- package/browser/psbt.d.ts.map +1 -0
- package/browser/pubkey.d.ts +27 -6
- package/browser/pubkey.d.ts.map +1 -0
- package/browser/push_data.d.ts +24 -2
- package/browser/push_data.d.ts.map +1 -0
- package/browser/script.d.ts +33 -8
- package/browser/script.d.ts.map +1 -0
- package/browser/script_number.d.ts +17 -0
- package/browser/script_number.d.ts.map +1 -0
- package/browser/script_signature.d.ts +23 -5
- package/browser/script_signature.d.ts.map +1 -0
- package/browser/transaction.d.ts +160 -18
- package/browser/transaction.d.ts.map +1 -0
- package/browser/types.d.ts +36 -38
- package/browser/types.d.ts.map +1 -0
- package/browser/workers/WorkerSigningPool.d.ts +143 -0
- package/browser/workers/WorkerSigningPool.d.ts.map +1 -0
- package/browser/workers/WorkerSigningPool.node.d.ts +116 -0
- package/browser/workers/WorkerSigningPool.node.d.ts.map +1 -0
- package/browser/workers/ecc-bundle.d.ts +25 -0
- package/browser/workers/ecc-bundle.d.ts.map +1 -0
- package/browser/workers/index.d.ts +91 -0
- package/browser/workers/index.d.ts.map +1 -0
- package/browser/workers/psbt-parallel.d.ts +88 -0
- package/browser/workers/psbt-parallel.d.ts.map +1 -0
- package/browser/workers/signing-worker.d.ts +37 -0
- package/browser/workers/signing-worker.d.ts.map +1 -0
- package/browser/workers/types.d.ts +365 -0
- package/browser/workers/types.d.ts.map +1 -0
- package/build/address.d.ts +58 -11
- package/build/address.d.ts.map +1 -0
- package/build/address.js +82 -25
- package/build/address.js.map +1 -0
- package/build/bech32utils.d.ts +9 -1
- package/build/bech32utils.d.ts.map +1 -0
- package/build/bech32utils.js +10 -2
- package/build/bech32utils.js.map +1 -0
- package/build/bip66.d.ts +11 -6
- package/build/bip66.d.ts.map +1 -0
- package/build/bip66.js +32 -3
- package/build/bip66.js.map +1 -0
- package/build/block.d.ts +117 -11
- package/build/block.d.ts.map +1 -0
- package/build/block.js +202 -72
- package/build/block.js.map +1 -0
- package/build/branded.d.ts +20 -0
- package/build/branded.d.ts.map +1 -0
- package/build/branded.js +7 -0
- package/build/branded.js.map +1 -0
- package/build/crypto/crypto.d.ts +1 -0
- package/build/crypto/crypto.d.ts.map +1 -0
- package/build/crypto/crypto.js +1 -0
- package/build/crypto/crypto.js.map +1 -0
- package/build/crypto.d.ts +46 -7
- package/build/crypto.d.ts.map +1 -0
- package/build/crypto.js +65 -20
- package/build/crypto.js.map +1 -0
- package/build/ecc/context.d.ts +135 -0
- package/build/ecc/context.d.ts.map +1 -0
- package/build/ecc/context.js +232 -0
- package/build/ecc/context.js.map +1 -0
- package/build/ecc/index.d.ts +11 -0
- package/build/ecc/index.d.ts.map +1 -0
- package/build/ecc/index.js +11 -0
- package/build/ecc/index.js.map +1 -0
- package/build/ecc/types.d.ts +134 -0
- package/build/ecc/types.d.ts.map +1 -0
- package/build/ecc/types.js +8 -0
- package/build/ecc/types.js.map +1 -0
- package/build/errors.d.ts +124 -0
- package/build/errors.d.ts.map +1 -0
- package/build/errors.js +155 -0
- package/build/errors.js.map +1 -0
- package/build/index.d.ts +32 -5
- package/build/index.d.ts.map +1 -0
- package/build/index.js +26 -3
- package/build/index.js.map +1 -0
- package/build/io/BinaryReader.d.ts +276 -0
- package/build/io/BinaryReader.d.ts.map +1 -0
- package/build/io/BinaryReader.js +425 -0
- package/build/io/BinaryReader.js.map +1 -0
- package/build/io/BinaryWriter.d.ts +391 -0
- package/build/io/BinaryWriter.d.ts.map +1 -0
- package/build/io/BinaryWriter.js +611 -0
- package/build/io/BinaryWriter.js.map +1 -0
- package/build/io/MemoryPool.d.ts +220 -0
- package/build/io/MemoryPool.d.ts.map +1 -0
- package/build/io/MemoryPool.js +309 -0
- package/build/io/MemoryPool.js.map +1 -0
- package/build/io/base64.d.ts +13 -0
- package/build/io/base64.d.ts.map +1 -0
- package/build/io/base64.js +20 -0
- package/build/io/base64.js.map +1 -0
- package/build/io/hex.d.ts +67 -0
- package/build/io/hex.d.ts.map +1 -0
- package/build/io/hex.js +138 -0
- package/build/io/hex.js.map +1 -0
- package/build/io/index.d.ts +17 -0
- package/build/io/index.d.ts.map +1 -0
- package/build/io/index.js +23 -0
- package/build/io/index.js.map +1 -0
- package/build/io/utils.d.ts +199 -0
- package/build/io/utils.d.ts.map +1 -0
- package/build/io/utils.js +271 -0
- package/build/io/utils.js.map +1 -0
- package/build/merkle.d.ts +10 -1
- package/build/merkle.d.ts.map +1 -0
- package/build/merkle.js +12 -1
- package/build/merkle.js.map +1 -0
- package/build/networks.d.ts +70 -9
- package/build/networks.d.ts.map +1 -0
- package/build/networks.js +90 -4
- package/build/networks.js.map +1 -0
- package/build/opcodes.d.ts +1 -0
- package/build/opcodes.d.ts.map +1 -0
- package/build/opcodes.js +1 -0
- package/build/opcodes.js.map +1 -0
- package/build/payments/bip341.d.ts +35 -9
- package/build/payments/bip341.d.ts.map +1 -0
- package/build/payments/bip341.js +34 -15
- package/build/payments/bip341.js.map +1 -0
- package/build/payments/embed.d.ts +120 -1
- package/build/payments/embed.d.ts.map +1 -0
- package/build/payments/embed.js +215 -34
- package/build/payments/embed.js.map +1 -0
- package/build/payments/index.d.ts +17 -10
- package/build/payments/index.d.ts.map +1 -0
- package/build/payments/index.js +20 -10
- package/build/payments/index.js.map +1 -0
- package/build/payments/p2ms.d.ts +159 -1
- package/build/payments/p2ms.d.ts.map +1 -0
- package/build/payments/p2ms.js +427 -108
- package/build/payments/p2ms.js.map +1 -0
- package/build/payments/p2op.d.ts +158 -24
- package/build/payments/p2op.d.ts.map +1 -0
- package/build/payments/p2op.js +379 -93
- package/build/payments/p2op.js.map +1 -0
- package/build/payments/p2pk.d.ts +162 -1
- package/build/payments/p2pk.d.ts.map +1 -0
- package/build/payments/p2pk.js +327 -58
- package/build/payments/p2pk.js.map +1 -0
- package/build/payments/p2pkh.d.ts +185 -1
- package/build/payments/p2pkh.d.ts.map +1 -0
- package/build/payments/p2pkh.js +467 -114
- package/build/payments/p2pkh.js.map +1 -0
- package/build/payments/p2sh.d.ts +159 -1
- package/build/payments/p2sh.d.ts.map +1 -0
- package/build/payments/p2sh.js +500 -150
- package/build/payments/p2sh.js.map +1 -0
- package/build/payments/p2tr.d.ts +193 -1
- package/build/payments/p2tr.d.ts.map +1 -0
- package/build/payments/p2tr.js +592 -174
- package/build/payments/p2tr.js.map +1 -0
- package/build/payments/p2wpkh.d.ts +170 -1
- package/build/payments/p2wpkh.d.ts.map +1 -0
- package/build/payments/p2wpkh.js +428 -103
- package/build/payments/p2wpkh.js.map +1 -0
- package/build/payments/p2wsh.d.ts +155 -1
- package/build/payments/p2wsh.d.ts.map +1 -0
- package/build/payments/p2wsh.js +465 -143
- package/build/payments/p2wsh.js.map +1 -0
- package/build/payments/types.d.ts +98 -64
- package/build/payments/types.d.ts.map +1 -0
- package/build/payments/types.js +17 -13
- package/build/payments/types.js.map +1 -0
- package/build/psbt/bip371.d.ts +35 -9
- package/build/psbt/bip371.d.ts.map +1 -0
- package/build/psbt/bip371.js +117 -28
- package/build/psbt/bip371.js.map +1 -0
- package/build/psbt/psbtutils.d.ts +56 -16
- package/build/psbt/psbtutils.d.ts.map +1 -0
- package/build/psbt/psbtutils.js +71 -16
- package/build/psbt/psbtutils.js.map +1 -0
- package/build/psbt/types.d.ts +249 -0
- package/build/psbt/types.d.ts.map +1 -0
- package/build/psbt/types.js +6 -0
- package/build/psbt/types.js.map +1 -0
- package/build/psbt/utils.d.ts +68 -0
- package/build/psbt/utils.d.ts.map +1 -0
- package/build/psbt/utils.js +171 -0
- package/build/psbt/utils.js.map +1 -0
- package/build/psbt/validation.d.ts +88 -0
- package/build/psbt/validation.d.ts.map +1 -0
- package/build/psbt/validation.js +149 -0
- package/build/psbt/validation.js.map +1 -0
- package/build/psbt.d.ts +84 -120
- package/build/psbt.d.ts.map +1 -0
- package/build/psbt.js +406 -413
- package/build/psbt.js.map +1 -0
- package/build/pubkey.d.ts +27 -6
- package/build/pubkey.d.ts.map +1 -0
- package/build/pubkey.js +36 -12
- package/build/pubkey.js.map +1 -0
- package/build/push_data.d.ts +24 -2
- package/build/push_data.d.ts.map +1 -0
- package/build/push_data.js +44 -12
- package/build/push_data.js.map +1 -0
- package/build/script.d.ts +33 -8
- package/build/script.d.ts.map +1 -0
- package/build/script.js +101 -37
- package/build/script.js.map +1 -0
- package/build/script_number.d.ts +17 -0
- package/build/script_number.d.ts.map +1 -0
- package/build/script_number.js +19 -0
- package/build/script_number.js.map +1 -0
- package/build/script_signature.d.ts +23 -5
- package/build/script_signature.d.ts.map +1 -0
- package/build/script_signature.js +48 -15
- package/build/script_signature.js.map +1 -0
- package/build/transaction.d.ts +160 -18
- package/build/transaction.d.ts.map +1 -0
- package/build/transaction.js +443 -176
- package/build/transaction.js.map +1 -0
- package/build/tsconfig.build.tsbuildinfo +1 -0
- package/build/types.d.ts +36 -38
- package/build/types.d.ts.map +1 -0
- package/build/types.js +169 -57
- package/build/types.js.map +1 -0
- package/build/workers/WorkerSigningPool.d.ts +174 -0
- package/build/workers/WorkerSigningPool.d.ts.map +1 -0
- package/build/workers/WorkerSigningPool.js +553 -0
- package/build/workers/WorkerSigningPool.js.map +1 -0
- package/build/workers/WorkerSigningPool.node.d.ts +124 -0
- package/build/workers/WorkerSigningPool.node.d.ts.map +1 -0
- package/build/workers/WorkerSigningPool.node.js +753 -0
- package/build/workers/WorkerSigningPool.node.js.map +1 -0
- package/build/workers/ecc-bundle.d.ts +25 -0
- package/build/workers/ecc-bundle.d.ts.map +1 -0
- package/build/workers/ecc-bundle.js +25 -0
- package/build/workers/ecc-bundle.js.map +1 -0
- package/build/workers/index.d.ts +91 -0
- package/build/workers/index.d.ts.map +1 -0
- package/build/workers/index.js +114 -0
- package/build/workers/index.js.map +1 -0
- package/build/workers/psbt-parallel.d.ts +117 -0
- package/build/workers/psbt-parallel.d.ts.map +1 -0
- package/build/workers/psbt-parallel.js +233 -0
- package/build/workers/psbt-parallel.js.map +1 -0
- package/build/workers/signing-worker.d.ts +37 -0
- package/build/workers/signing-worker.d.ts.map +1 -0
- package/build/workers/signing-worker.js +350 -0
- package/build/workers/signing-worker.js.map +1 -0
- package/build/workers/types.d.ts +365 -0
- package/build/workers/types.d.ts.map +1 -0
- package/build/workers/types.js +60 -0
- package/build/workers/types.js.map +1 -0
- package/package.json +68 -9
- package/scripts/bundle-ecc.ts +111 -0
- package/src/address.ts +91 -45
- package/src/bech32utils.ts +3 -3
- package/src/bip66.ts +34 -24
- package/src/block.ts +205 -86
- package/src/branded.ts +18 -0
- package/src/crypto.ts +64 -26
- package/src/ecc/context.ts +280 -0
- package/src/ecc/index.ts +14 -0
- package/src/ecc/types.ts +147 -0
- package/src/ecpair.d.ts +99 -0
- package/src/errors.ts +163 -0
- package/src/index.ts +112 -9
- package/src/io/BinaryReader.ts +461 -0
- package/src/io/BinaryWriter.ts +696 -0
- package/src/io/MemoryPool.ts +343 -0
- package/src/io/base64.ts +20 -0
- package/src/io/hex.ts +155 -0
- package/src/io/index.ts +41 -0
- package/src/io/utils.ts +283 -0
- package/src/merkle.ts +14 -9
- package/src/networks.ts +9 -9
- package/src/payments/bip341.ts +32 -33
- package/src/payments/embed.ts +244 -41
- package/src/payments/index.ts +12 -10
- package/src/payments/p2ms.ts +497 -118
- package/src/payments/p2op.ts +432 -134
- package/src/payments/p2pk.ts +370 -72
- package/src/payments/p2pkh.ts +524 -130
- package/src/payments/p2sh.ts +572 -169
- package/src/payments/p2tr.ts +686 -194
- package/src/payments/p2wpkh.ts +482 -105
- package/src/payments/p2wsh.ts +524 -162
- package/src/payments/types.ts +80 -66
- package/src/psbt/bip371.ts +72 -51
- package/src/psbt/psbtutils.ts +39 -40
- package/src/psbt/types.ts +324 -0
- package/src/psbt/utils.ts +188 -0
- package/src/psbt/validation.ts +185 -0
- package/src/psbt.ts +608 -827
- package/src/pubkey.ts +22 -23
- package/src/push_data.ts +18 -16
- package/src/script.ts +81 -66
- package/src/script_number.ts +6 -6
- package/src/script_signature.ts +33 -36
- package/src/transaction.ts +462 -239
- package/src/types.ts +229 -100
- package/src/workers/WorkerSigningPool.node.ts +887 -0
- package/src/workers/WorkerSigningPool.ts +666 -0
- package/src/workers/ecc-bundle.ts +26 -0
- package/src/workers/index.ts +165 -0
- package/src/workers/psbt-parallel.ts +327 -0
- package/src/workers/signing-worker.ts +353 -0
- package/src/workers/types.ts +417 -0
- package/test/address.spec.ts +9 -6
- package/test/bitcoin.core.spec.ts +16 -17
- package/test/block.spec.ts +8 -7
- package/test/bufferutils.spec.ts +228 -214
- package/test/crypto.spec.ts +19 -11
- package/test/fixtures/p2pk.json +0 -8
- package/test/fixtures/p2pkh.json +1 -1
- package/test/fixtures/p2sh.json +1 -1
- package/test/fixtures/script.json +1 -1
- package/test/fixtures/transaction.json +2 -2
- package/test/integration/_regtest.ts +25 -0
- package/test/integration/addresses.spec.ts +4 -3
- package/test/integration/bip32.spec.ts +2 -1
- package/test/integration/blocks.spec.ts +1 -1
- package/test/integration/cltv.spec.ts +18 -16
- package/test/integration/csv.spec.ts +37 -64
- package/test/integration/payments.spec.ts +5 -3
- package/test/integration/taproot.spec.ts +76 -83
- package/test/integration/transactions.spec.ts +38 -35
- package/test/payments.spec.ts +35 -13
- package/test/payments.utils.ts +17 -16
- package/test/psbt.spec.ts +111 -100
- package/test/script.spec.ts +11 -10
- package/test/script_signature.spec.ts +9 -11
- package/test/taproot-cache.spec.ts +694 -0
- package/test/transaction.spec.ts +32 -40
- package/test/types.spec.ts +74 -29
- package/test/workers-pool.spec.ts +963 -0
- package/test/workers-signing.spec.ts +635 -0
- package/test/workers.spec.ts +1390 -0
- package/tsconfig.base.json +34 -18
- package/tsconfig.browser.json +15 -0
- package/tsconfig.build.json +5 -0
- package/tsconfig.json +5 -14
- package/typedoc.json +29 -0
- package/vite.config.browser.ts +3 -42
- package/vitest.config.integration.ts +2 -0
- package/browser/bufferutils.d.ts +0 -34
- package/browser/chunks/crypto-BhCpKpek.js +0 -2033
- package/browser/chunks/payments-B1wlSccx.js +0 -1089
- package/browser/chunks/psbt-BCNk7JUx.js +0 -4055
- package/browser/chunks/script-DyPItFEl.js +0 -318
- package/browser/chunks/transaction-C_UbhMGn.js +0 -432
- package/browser/chunks/utils-DNZi-T5W.js +0 -761
- package/browser/ecc_lib.d.ts +0 -3
- package/browser/hooks/AdvancedSignatureManager.d.ts +0 -16
- package/browser/hooks/HookedSigner.d.ts +0 -4
- package/browser/hooks/SignatureManager.d.ts +0 -13
- package/browser/payments/lazy.d.ts +0 -2
- package/browser/typeforce.d.ts +0 -38
- package/build/bufferutils.d.ts +0 -34
- package/build/bufferutils.js +0 -141
- package/build/ecc_lib.d.ts +0 -3
- package/build/ecc_lib.js +0 -61
- package/build/hooks/AdvancedSignatureManager.d.ts +0 -16
- package/build/hooks/AdvancedSignatureManager.js +0 -52
- package/build/hooks/HookedSigner.d.ts +0 -4
- package/build/hooks/HookedSigner.js +0 -64
- package/build/hooks/SignatureManager.d.ts +0 -13
- package/build/hooks/SignatureManager.js +0 -45
- package/build/payments/lazy.d.ts +0 -2
- package/build/payments/lazy.js +0 -28
- package/build/tsconfig.tsbuildinfo +0 -1
- package/src/bufferutils.ts +0 -188
- package/src/ecc_lib.ts +0 -94
- package/src/hooks/AdvancedSignatureManager.ts +0 -104
- package/src/hooks/HookedSigner.ts +0 -108
- package/src/hooks/SignatureManager.ts +0 -84
- package/src/payments/lazy.ts +0 -28
- package/src/typeforce.d.ts +0 -38
- package/tsconfig.webpack.json +0 -18
package/build/crypto.js
CHANGED
|
@@ -1,20 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cryptographic hashing functions for Bitcoin.
|
|
3
|
+
* Includes ripemd160, sha1, sha256, hash160, hash256, and taggedHash.
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
1
7
|
import { ripemd160 as _ripemd160, sha1 as _sha1 } from '@noble/hashes/legacy.js';
|
|
2
8
|
import { sha256 as _sha256 } from '@noble/hashes/sha2.js';
|
|
3
|
-
|
|
4
|
-
|
|
9
|
+
import { concat } from './io/index.js';
|
|
10
|
+
/**
|
|
11
|
+
* Computes RIPEMD-160 hash of the input.
|
|
12
|
+
* @param data - Input data
|
|
13
|
+
* @returns 20-byte hash (Bytes20)
|
|
14
|
+
*/
|
|
15
|
+
export function ripemd160(data) {
|
|
16
|
+
return _ripemd160(data);
|
|
5
17
|
}
|
|
6
|
-
|
|
7
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Computes SHA-1 hash of the input.
|
|
20
|
+
* @param data - Input data
|
|
21
|
+
* @returns 20-byte hash (Bytes20)
|
|
22
|
+
*/
|
|
23
|
+
export function sha1(data) {
|
|
24
|
+
return _sha1(data);
|
|
8
25
|
}
|
|
9
|
-
|
|
10
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Computes SHA-256 hash of the input.
|
|
28
|
+
* @param data - Input data
|
|
29
|
+
* @returns 32-byte hash (Bytes32)
|
|
30
|
+
*/
|
|
31
|
+
export function sha256(data) {
|
|
32
|
+
return _sha256(data);
|
|
11
33
|
}
|
|
12
|
-
|
|
13
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Computes HASH160 (RIPEMD160(SHA256(data))) of the input.
|
|
36
|
+
* @param data - Input data
|
|
37
|
+
* @returns 20-byte hash (Bytes20)
|
|
38
|
+
*/
|
|
39
|
+
export function hash160(data) {
|
|
40
|
+
return _ripemd160(_sha256(data));
|
|
14
41
|
}
|
|
15
|
-
|
|
16
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Computes double SHA-256 hash of the input.
|
|
44
|
+
* @param data - Input data
|
|
45
|
+
* @returns 32-byte hash (Bytes32)
|
|
46
|
+
*/
|
|
47
|
+
export function hash256(data) {
|
|
48
|
+
return _sha256(_sha256(data));
|
|
17
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* BIP340/Taproot tag names for tagged hashing.
|
|
52
|
+
*/
|
|
18
53
|
export const TAGS = [
|
|
19
54
|
'BIP0340/challenge',
|
|
20
55
|
'BIP0340/aux',
|
|
@@ -26,61 +61,71 @@ export const TAGS = [
|
|
|
26
61
|
'KeyAgg list',
|
|
27
62
|
'KeyAgg coefficient',
|
|
28
63
|
];
|
|
64
|
+
/**
|
|
65
|
+
* Precomputed tagged hash prefixes: SHA256(tag) || SHA256(tag)
|
|
66
|
+
*/
|
|
29
67
|
export const TAGGED_HASH_PREFIXES = {
|
|
30
|
-
'BIP0340/challenge':
|
|
68
|
+
'BIP0340/challenge': new Uint8Array([
|
|
31
69
|
123, 181, 45, 122, 159, 239, 88, 50, 62, 177, 191, 122, 64, 125, 179, 130, 210, 243, 242,
|
|
32
70
|
216, 27, 177, 34, 79, 73, 254, 81, 143, 109, 72, 211, 124, 123, 181, 45, 122, 159, 239, 88,
|
|
33
71
|
50, 62, 177, 191, 122, 64, 125, 179, 130, 210, 243, 242, 216, 27, 177, 34, 79, 73, 254, 81,
|
|
34
72
|
143, 109, 72, 211, 124,
|
|
35
73
|
]),
|
|
36
|
-
'BIP0340/aux':
|
|
74
|
+
'BIP0340/aux': new Uint8Array([
|
|
37
75
|
241, 239, 78, 94, 192, 99, 202, 218, 109, 148, 202, 250, 157, 152, 126, 160, 105, 38, 88,
|
|
38
76
|
57, 236, 193, 31, 151, 45, 119, 165, 46, 216, 193, 204, 144, 241, 239, 78, 94, 192, 99, 202,
|
|
39
77
|
218, 109, 148, 202, 250, 157, 152, 126, 160, 105, 38, 88, 57, 236, 193, 31, 151, 45, 119,
|
|
40
78
|
165, 46, 216, 193, 204, 144,
|
|
41
79
|
]),
|
|
42
|
-
'BIP0340/nonce':
|
|
80
|
+
'BIP0340/nonce': new Uint8Array([
|
|
43
81
|
7, 73, 119, 52, 167, 155, 203, 53, 91, 155, 140, 125, 3, 79, 18, 28, 244, 52, 215, 62, 247,
|
|
44
82
|
45, 218, 25, 135, 0, 97, 251, 82, 191, 235, 47, 7, 73, 119, 52, 167, 155, 203, 53, 91, 155,
|
|
45
83
|
140, 125, 3, 79, 18, 28, 244, 52, 215, 62, 247, 45, 218, 25, 135, 0, 97, 251, 82, 191, 235,
|
|
46
84
|
47,
|
|
47
85
|
]),
|
|
48
|
-
TapLeaf:
|
|
86
|
+
TapLeaf: new Uint8Array([
|
|
49
87
|
174, 234, 143, 220, 66, 8, 152, 49, 5, 115, 75, 88, 8, 29, 30, 38, 56, 211, 95, 28, 181, 64,
|
|
50
88
|
8, 212, 211, 87, 202, 3, 190, 120, 233, 238, 174, 234, 143, 220, 66, 8, 152, 49, 5, 115, 75,
|
|
51
89
|
88, 8, 29, 30, 38, 56, 211, 95, 28, 181, 64, 8, 212, 211, 87, 202, 3, 190, 120, 233, 238,
|
|
52
90
|
]),
|
|
53
|
-
TapBranch:
|
|
91
|
+
TapBranch: new Uint8Array([
|
|
54
92
|
25, 65, 161, 242, 229, 110, 185, 95, 162, 169, 241, 148, 190, 92, 1, 247, 33, 111, 51, 237,
|
|
55
93
|
130, 176, 145, 70, 52, 144, 208, 91, 245, 22, 160, 21, 25, 65, 161, 242, 229, 110, 185, 95,
|
|
56
94
|
162, 169, 241, 148, 190, 92, 1, 247, 33, 111, 51, 237, 130, 176, 145, 70, 52, 144, 208, 91,
|
|
57
95
|
245, 22, 160, 21,
|
|
58
96
|
]),
|
|
59
|
-
TapSighash:
|
|
97
|
+
TapSighash: new Uint8Array([
|
|
60
98
|
244, 10, 72, 223, 75, 42, 112, 200, 180, 146, 75, 242, 101, 70, 97, 237, 61, 149, 253, 102,
|
|
61
99
|
163, 19, 235, 135, 35, 117, 151, 198, 40, 228, 160, 49, 244, 10, 72, 223, 75, 42, 112, 200,
|
|
62
100
|
180, 146, 75, 242, 101, 70, 97, 237, 61, 149, 253, 102, 163, 19, 235, 135, 35, 117, 151,
|
|
63
101
|
198, 40, 228, 160, 49,
|
|
64
102
|
]),
|
|
65
|
-
TapTweak:
|
|
103
|
+
TapTweak: new Uint8Array([
|
|
66
104
|
232, 15, 225, 99, 156, 156, 160, 80, 227, 175, 27, 57, 193, 67, 198, 62, 66, 156, 188, 235,
|
|
67
105
|
21, 217, 64, 251, 181, 197, 161, 244, 175, 87, 197, 233, 232, 15, 225, 99, 156, 156, 160,
|
|
68
106
|
80, 227, 175, 27, 57, 193, 67, 198, 62, 66, 156, 188, 235, 21, 217, 64, 251, 181, 197, 161,
|
|
69
107
|
244, 175, 87, 197, 233,
|
|
70
108
|
]),
|
|
71
|
-
'KeyAgg list':
|
|
109
|
+
'KeyAgg list': new Uint8Array([
|
|
72
110
|
72, 28, 151, 28, 60, 11, 70, 215, 240, 178, 117, 174, 89, 141, 78, 44, 126, 215, 49, 156,
|
|
73
111
|
89, 74, 92, 110, 199, 158, 160, 212, 153, 2, 148, 240, 72, 28, 151, 28, 60, 11, 70, 215,
|
|
74
112
|
240, 178, 117, 174, 89, 141, 78, 44, 126, 215, 49, 156, 89, 74, 92, 110, 199, 158, 160, 212,
|
|
75
113
|
153, 2, 148, 240,
|
|
76
114
|
]),
|
|
77
|
-
'KeyAgg coefficient':
|
|
115
|
+
'KeyAgg coefficient': new Uint8Array([
|
|
78
116
|
191, 201, 4, 3, 77, 28, 136, 232, 200, 14, 34, 229, 61, 36, 86, 109, 100, 130, 78, 214, 66,
|
|
79
117
|
114, 129, 192, 145, 0, 249, 77, 205, 82, 201, 129, 191, 201, 4, 3, 77, 28, 136, 232, 200,
|
|
80
118
|
14, 34, 229, 61, 36, 86, 109, 100, 130, 78, 214, 66, 114, 129, 192, 145, 0, 249, 77, 205,
|
|
81
119
|
82, 201, 129,
|
|
82
120
|
]),
|
|
83
121
|
};
|
|
122
|
+
/**
|
|
123
|
+
* Computes a BIP340-style tagged hash.
|
|
124
|
+
* @param prefix - The tag name
|
|
125
|
+
* @param data - Input data
|
|
126
|
+
* @returns 32-byte hash (Bytes32)
|
|
127
|
+
*/
|
|
84
128
|
export function taggedHash(prefix, data) {
|
|
85
|
-
return sha256(
|
|
129
|
+
return sha256(concat([TAGGED_HASH_PREFIXES[prefix], data]));
|
|
86
130
|
}
|
|
131
|
+
//# sourceMappingURL=crypto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../src/crypto.ts"],"names":[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
|
2
|
+
* ECC library context management with dependency injection.
|
|
3
|
+
* Provides initialization, access, and lifecycle management for the ECC library.
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
import type { EccLib } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Context class for managing the ECC library instance.
|
|
10
|
+
* Uses dependency injection pattern instead of global singleton.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { EccContext } from '@btc-vision/bitcoin';
|
|
15
|
+
* import * as secp256k1 from 'tiny-secp256k1';
|
|
16
|
+
*
|
|
17
|
+
* // Initialize once at app startup
|
|
18
|
+
* EccContext.init(secp256k1);
|
|
19
|
+
*
|
|
20
|
+
* // Get instance anywhere in your code
|
|
21
|
+
* const ecc = EccContext.get();
|
|
22
|
+
*
|
|
23
|
+
* // Clear when done (optional, for testing)
|
|
24
|
+
* EccContext.clear();
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare class EccContext {
|
|
28
|
+
#private;
|
|
29
|
+
private constructor();
|
|
30
|
+
/**
|
|
31
|
+
* The underlying ECC library instance.
|
|
32
|
+
*/
|
|
33
|
+
get lib(): EccLib;
|
|
34
|
+
/**
|
|
35
|
+
* Initializes the ECC context with the provided library.
|
|
36
|
+
* The library is verified before being set as active.
|
|
37
|
+
*
|
|
38
|
+
* @param lib - The ECC library instance to initialize
|
|
39
|
+
* @returns The initialized EccContext instance
|
|
40
|
+
* @throws Error if the ECC library fails verification
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* import { EccContext } from '@btc-vision/bitcoin';
|
|
45
|
+
* import * as secp256k1 from 'tiny-secp256k1';
|
|
46
|
+
*
|
|
47
|
+
* const context = EccContext.init(secp256k1);
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
static init(lib: EccLib): EccContext;
|
|
51
|
+
/**
|
|
52
|
+
* Gets the initialized ECC context.
|
|
53
|
+
*
|
|
54
|
+
* @returns The EccContext instance
|
|
55
|
+
* @throws Error if the context has not been initialized
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* import { EccContext } from '@btc-vision/bitcoin';
|
|
60
|
+
*
|
|
61
|
+
* const context = EccContext.get();
|
|
62
|
+
* const isValid = context.lib.isXOnlyPoint(someKey);
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
static get(): EccContext;
|
|
66
|
+
/**
|
|
67
|
+
* Clears the ECC context.
|
|
68
|
+
* Useful for testing or when reinitializing with a different library.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* import { EccContext } from '@btc-vision/bitcoin';
|
|
73
|
+
*
|
|
74
|
+
* EccContext.clear();
|
|
75
|
+
* // Context is now uninitialized
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
static clear(): void;
|
|
79
|
+
/**
|
|
80
|
+
* Checks if the ECC context has been initialized.
|
|
81
|
+
*
|
|
82
|
+
* @returns True if initialized
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* import { EccContext } from '@btc-vision/bitcoin';
|
|
87
|
+
*
|
|
88
|
+
* if (!EccContext.isInitialized()) {
|
|
89
|
+
* EccContext.init(secp256k1);
|
|
90
|
+
* }
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
static isInitialized(): boolean;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Initializes the ECC library with the provided instance.
|
|
97
|
+
* This is a convenience function that wraps EccContext.init().
|
|
98
|
+
* Pass `undefined` to clear the library.
|
|
99
|
+
*
|
|
100
|
+
* @param eccLib - The ECC library instance to initialize, or undefined to clear
|
|
101
|
+
* @throws Error if the ECC library fails verification
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* import { initEccLib } from '@btc-vision/bitcoin';
|
|
106
|
+
* import * as secp256k1 from 'tiny-secp256k1';
|
|
107
|
+
*
|
|
108
|
+
* // Initialize the ECC library
|
|
109
|
+
* initEccLib(secp256k1);
|
|
110
|
+
*
|
|
111
|
+
* // Clear the library
|
|
112
|
+
* initEccLib(undefined);
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
export declare function initEccLib(eccLib: EccLib | undefined): void;
|
|
116
|
+
/**
|
|
117
|
+
* Retrieves the initialized ECC library instance.
|
|
118
|
+
* This is a convenience function that wraps EccContext.get().lib.
|
|
119
|
+
*
|
|
120
|
+
* @returns The ECC library instance
|
|
121
|
+
* @throws Error if the ECC library has not been initialized
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```typescript
|
|
125
|
+
* import { getEccLib, initEccLib } from '@btc-vision/bitcoin';
|
|
126
|
+
* import * as secp256k1 from 'tiny-secp256k1';
|
|
127
|
+
*
|
|
128
|
+
* initEccLib(secp256k1);
|
|
129
|
+
*
|
|
130
|
+
* const ecc = getEccLib();
|
|
131
|
+
* const isValid = ecc.isXOnlyPoint(somePublicKey);
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
export declare function getEccLib(): EccLib;
|
|
135
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/ecc/context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAIzC;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,UAAU;;IAInB,OAAO;IAIP;;OAEG;IACH,IAAI,GAAG,IAAI,MAAM,CAEhB;IAED;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU;IAMpC;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,GAAG,IAAI,UAAU;IASxB;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,KAAK,IAAI,IAAI;IAIpB;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,aAAa,IAAI,OAAO;CAGlC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAM3D;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAElC"}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { equals, fromHex } from '../io/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Context class for managing the ECC library instance.
|
|
4
|
+
* Uses dependency injection pattern instead of global singleton.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { EccContext } from '@btc-vision/bitcoin';
|
|
9
|
+
* import * as secp256k1 from 'tiny-secp256k1';
|
|
10
|
+
*
|
|
11
|
+
* // Initialize once at app startup
|
|
12
|
+
* EccContext.init(secp256k1);
|
|
13
|
+
*
|
|
14
|
+
* // Get instance anywhere in your code
|
|
15
|
+
* const ecc = EccContext.get();
|
|
16
|
+
*
|
|
17
|
+
* // Clear when done (optional, for testing)
|
|
18
|
+
* EccContext.clear();
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export class EccContext {
|
|
22
|
+
static #instance;
|
|
23
|
+
#lib;
|
|
24
|
+
constructor(lib) {
|
|
25
|
+
this.#lib = lib;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The underlying ECC library instance.
|
|
29
|
+
*/
|
|
30
|
+
get lib() {
|
|
31
|
+
return this.#lib;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Initializes the ECC context with the provided library.
|
|
35
|
+
* The library is verified before being set as active.
|
|
36
|
+
*
|
|
37
|
+
* @param lib - The ECC library instance to initialize
|
|
38
|
+
* @returns The initialized EccContext instance
|
|
39
|
+
* @throws Error if the ECC library fails verification
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* import { EccContext } from '@btc-vision/bitcoin';
|
|
44
|
+
* import * as secp256k1 from 'tiny-secp256k1';
|
|
45
|
+
*
|
|
46
|
+
* const context = EccContext.init(secp256k1);
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
static init(lib) {
|
|
50
|
+
verifyEcc(lib);
|
|
51
|
+
EccContext.#instance = new EccContext(lib);
|
|
52
|
+
return EccContext.#instance;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Gets the initialized ECC context.
|
|
56
|
+
*
|
|
57
|
+
* @returns The EccContext instance
|
|
58
|
+
* @throws Error if the context has not been initialized
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* import { EccContext } from '@btc-vision/bitcoin';
|
|
63
|
+
*
|
|
64
|
+
* const context = EccContext.get();
|
|
65
|
+
* const isValid = context.lib.isXOnlyPoint(someKey);
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
static get() {
|
|
69
|
+
if (!EccContext.#instance) {
|
|
70
|
+
throw new Error('ECC library not initialized. Call EccContext.init() or initEccLib() first.');
|
|
71
|
+
}
|
|
72
|
+
return EccContext.#instance;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Clears the ECC context.
|
|
76
|
+
* Useful for testing or when reinitializing with a different library.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* import { EccContext } from '@btc-vision/bitcoin';
|
|
81
|
+
*
|
|
82
|
+
* EccContext.clear();
|
|
83
|
+
* // Context is now uninitialized
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
static clear() {
|
|
87
|
+
EccContext.#instance = undefined;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Checks if the ECC context has been initialized.
|
|
91
|
+
*
|
|
92
|
+
* @returns True if initialized
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* import { EccContext } from '@btc-vision/bitcoin';
|
|
97
|
+
*
|
|
98
|
+
* if (!EccContext.isInitialized()) {
|
|
99
|
+
* EccContext.init(secp256k1);
|
|
100
|
+
* }
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
static isInitialized() {
|
|
104
|
+
return EccContext.#instance !== undefined;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Initializes the ECC library with the provided instance.
|
|
109
|
+
* This is a convenience function that wraps EccContext.init().
|
|
110
|
+
* Pass `undefined` to clear the library.
|
|
111
|
+
*
|
|
112
|
+
* @param eccLib - The ECC library instance to initialize, or undefined to clear
|
|
113
|
+
* @throws Error if the ECC library fails verification
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```typescript
|
|
117
|
+
* import { initEccLib } from '@btc-vision/bitcoin';
|
|
118
|
+
* import * as secp256k1 from 'tiny-secp256k1';
|
|
119
|
+
*
|
|
120
|
+
* // Initialize the ECC library
|
|
121
|
+
* initEccLib(secp256k1);
|
|
122
|
+
*
|
|
123
|
+
* // Clear the library
|
|
124
|
+
* initEccLib(undefined);
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
export function initEccLib(eccLib) {
|
|
128
|
+
if (eccLib === undefined) {
|
|
129
|
+
EccContext.clear();
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
EccContext.init(eccLib);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Retrieves the initialized ECC library instance.
|
|
136
|
+
* This is a convenience function that wraps EccContext.get().lib.
|
|
137
|
+
*
|
|
138
|
+
* @returns The ECC library instance
|
|
139
|
+
* @throws Error if the ECC library has not been initialized
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* import { getEccLib, initEccLib } from '@btc-vision/bitcoin';
|
|
144
|
+
* import * as secp256k1 from 'tiny-secp256k1';
|
|
145
|
+
*
|
|
146
|
+
* initEccLib(secp256k1);
|
|
147
|
+
*
|
|
148
|
+
* const ecc = getEccLib();
|
|
149
|
+
* const isValid = ecc.isXOnlyPoint(somePublicKey);
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
export function getEccLib() {
|
|
153
|
+
return EccContext.get().lib;
|
|
154
|
+
}
|
|
155
|
+
const TWEAK_ADD_VECTORS = [
|
|
156
|
+
{
|
|
157
|
+
pubkey: '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
|
|
158
|
+
tweak: 'fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140',
|
|
159
|
+
parity: -1,
|
|
160
|
+
result: null,
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
pubkey: '1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b',
|
|
164
|
+
tweak: 'a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac',
|
|
165
|
+
parity: 1,
|
|
166
|
+
result: 'e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf',
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
pubkey: '2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991',
|
|
170
|
+
tweak: '823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47',
|
|
171
|
+
parity: 0,
|
|
172
|
+
result: '9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c',
|
|
173
|
+
},
|
|
174
|
+
];
|
|
175
|
+
/**
|
|
176
|
+
* Verifies that the ECC library implementation is correct.
|
|
177
|
+
* Tests `isXOnlyPoint` and `xOnlyPointAddTweak` with known test vectors.
|
|
178
|
+
*
|
|
179
|
+
* @param ecc - The ECC library to verify
|
|
180
|
+
* @throws Error if any verification test fails
|
|
181
|
+
*/
|
|
182
|
+
function verifyEcc(ecc) {
|
|
183
|
+
if (typeof ecc.isXOnlyPoint !== 'function') {
|
|
184
|
+
throw new Error('ECC library missing isXOnlyPoint function');
|
|
185
|
+
}
|
|
186
|
+
// Test isXOnlyPoint with valid points
|
|
187
|
+
const validPoints = [
|
|
188
|
+
'79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
|
|
189
|
+
'fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e',
|
|
190
|
+
'f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9',
|
|
191
|
+
'0000000000000000000000000000000000000000000000000000000000000001',
|
|
192
|
+
];
|
|
193
|
+
for (const hex of validPoints) {
|
|
194
|
+
if (!ecc.isXOnlyPoint(fromHex(hex))) {
|
|
195
|
+
throw new Error(`ECC library isXOnlyPoint failed for valid point: ${hex}`);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
// Test isXOnlyPoint with invalid points
|
|
199
|
+
const invalidPoints = [
|
|
200
|
+
'0000000000000000000000000000000000000000000000000000000000000000',
|
|
201
|
+
'fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f',
|
|
202
|
+
];
|
|
203
|
+
for (const hex of invalidPoints) {
|
|
204
|
+
if (ecc.isXOnlyPoint(fromHex(hex))) {
|
|
205
|
+
throw new Error(`ECC library isXOnlyPoint should reject invalid point: ${hex}`);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
// Test xOnlyPointAddTweak
|
|
209
|
+
if (typeof ecc.xOnlyPointAddTweak !== 'function') {
|
|
210
|
+
throw new Error('ECC library missing xOnlyPointAddTweak function');
|
|
211
|
+
}
|
|
212
|
+
for (const vector of TWEAK_ADD_VECTORS) {
|
|
213
|
+
const result = ecc.xOnlyPointAddTweak(fromHex(vector.pubkey), fromHex(vector.tweak));
|
|
214
|
+
if (vector.result === null) {
|
|
215
|
+
if (result !== null) {
|
|
216
|
+
throw new Error(`ECC library xOnlyPointAddTweak should return null for: ${vector.pubkey}`);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
if (result === null) {
|
|
221
|
+
throw new Error(`ECC library xOnlyPointAddTweak returned null unexpectedly for: ${vector.pubkey}`);
|
|
222
|
+
}
|
|
223
|
+
if (result.parity !== vector.parity) {
|
|
224
|
+
throw new Error(`ECC library xOnlyPointAddTweak parity mismatch for: ${vector.pubkey}`);
|
|
225
|
+
}
|
|
226
|
+
if (!equals(result.xOnlyPubkey, fromHex(vector.result))) {
|
|
227
|
+
throw new Error(`ECC library xOnlyPointAddTweak result mismatch for: ${vector.pubkey}`);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/ecc/context.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAGjD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAAO,UAAU;IACnB,MAAM,CAAC,SAAS,CAAyB;IAChC,IAAI,CAAS;IAEtB,YAAoB,GAAW;QAC3B,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,IAAI,GAAG;QACH,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,IAAI,CAAC,GAAW;QACnB,SAAS,CAAC,GAAG,CAAC,CAAC;QACf,UAAU,CAAC,SAAS,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC;QAC3C,OAAO,UAAU,CAAC,SAAS,CAAC;IAChC,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,GAAG;QACN,IAAI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;gBAClB,MAAM,IAAI,KAAK,CACX,kEAAkE,MAAM,CAAC,MAAM,EAAE,CACpF,CAAC;YACN,CAAC;YACD,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC;gBAClC,MAAM,IAAI,KAAK,CACX,uDAAuD,MAAM,CAAC,MAAM,EAAE,CACzE,CAAC;YACN,CAAC;YACD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;gBACtD,MAAM,IAAI,KAAK,CACX,uDAAuD,MAAM,CAAC,MAAM,EAAE,CACzE,CAAC;YACN,CAAC;QACL,CAAC;IACL,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ECC (Elliptic Curve Cryptography) module.
|
|
3
|
+
*
|
|
4
|
+
* Provides dependency injection for the secp256k1 elliptic curve library
|
|
5
|
+
* required for Taproot (BIP340/BIP341) operations.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
export type { EccLib, XOnlyPointAddTweakResult, Parity } from './types.js';
|
|
10
|
+
export { EccContext, initEccLib, getEccLib } from './context.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ecc/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,YAAY,EAAE,MAAM,EAAE,wBAAwB,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAG3E,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ECC (Elliptic Curve Cryptography) module.
|
|
3
|
+
*
|
|
4
|
+
* Provides dependency injection for the secp256k1 elliptic curve library
|
|
5
|
+
* required for Taproot (BIP340/BIP341) operations.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
// Context management
|
|
10
|
+
export { EccContext, initEccLib, getEccLib } from './context.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ecc/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,qBAAqB;AACrB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC"}
|