@btc-vision/bitcoin 7.0.0-alpha.0 → 7.0.0-alpha.10
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/README.md +455 -155
- package/browser/address.d.ts +6 -2
- package/browser/address.d.ts.map +1 -1
- package/browser/block.d.ts.map +1 -1
- package/browser/branded.d.ts +3 -14
- package/browser/branded.d.ts.map +1 -1
- package/browser/chunks/psbt-parallel-BBFlkmiv.js +10717 -0
- package/browser/crypto.d.ts +1 -1
- package/browser/ecc/context.d.ts +25 -24
- package/browser/ecc/context.d.ts.map +1 -1
- package/browser/ecc/index.d.ts +1 -1
- package/browser/ecc/index.d.ts.map +1 -1
- package/browser/ecc/types.d.ts +10 -123
- package/browser/ecc/types.d.ts.map +1 -1
- package/browser/env.d.ts +13 -0
- package/browser/env.d.ts.map +1 -0
- package/browser/index.d.ts +7 -7
- package/browser/index.d.ts.map +1 -1
- package/browser/index.js +2497 -11686
- package/browser/io/BinaryReader.d.ts +15 -15
- package/browser/io/BinaryReader.d.ts.map +1 -1
- package/browser/io/BinaryWriter.d.ts +17 -17
- package/browser/io/BinaryWriter.d.ts.map +1 -1
- package/browser/io/hex.d.ts.map +1 -1
- package/browser/io/index.d.ts +0 -1
- package/browser/io/index.d.ts.map +1 -1
- package/browser/opcodes.d.ts +11 -0
- package/browser/opcodes.d.ts.map +1 -1
- package/browser/payments/bip341.d.ts +1 -1
- package/browser/payments/bip341.d.ts.map +1 -1
- package/browser/payments/embed.d.ts +1 -1
- package/browser/payments/embed.d.ts.map +1 -1
- package/browser/payments/p2ms.d.ts.map +1 -1
- package/browser/payments/p2op.d.ts +1 -1
- package/browser/payments/p2op.d.ts.map +1 -1
- package/browser/payments/p2pk.d.ts +1 -1
- package/browser/payments/p2pk.d.ts.map +1 -1
- package/browser/payments/p2pkh.d.ts +1 -1
- package/browser/payments/p2pkh.d.ts.map +1 -1
- package/browser/payments/p2sh.d.ts.map +1 -1
- package/browser/payments/p2tr.d.ts +2 -2
- package/browser/payments/p2tr.d.ts.map +1 -1
- package/browser/payments/p2wpkh.d.ts +1 -1
- package/browser/payments/p2wpkh.d.ts.map +1 -1
- package/browser/payments/p2wsh.d.ts.map +1 -1
- package/browser/payments/types.d.ts +1 -1
- package/browser/payments/types.d.ts.map +1 -1
- package/browser/psbt/PsbtCache.d.ts +54 -0
- package/browser/psbt/PsbtCache.d.ts.map +1 -0
- package/browser/psbt/PsbtFinalizer.d.ts +21 -0
- package/browser/psbt/PsbtFinalizer.d.ts.map +1 -0
- package/browser/psbt/PsbtSigner.d.ts +32 -0
- package/browser/psbt/PsbtSigner.d.ts.map +1 -0
- package/browser/psbt/PsbtTransaction.d.ts +25 -0
- package/browser/psbt/PsbtTransaction.d.ts.map +1 -0
- package/browser/psbt/bip371.d.ts.map +1 -1
- package/browser/psbt/types.d.ts +5 -71
- package/browser/psbt/types.d.ts.map +1 -1
- package/browser/psbt/validation.d.ts +1 -1
- package/browser/psbt/validation.d.ts.map +1 -1
- package/browser/psbt.d.ts +26 -40
- package/browser/psbt.d.ts.map +1 -1
- package/browser/script.d.ts.map +1 -1
- package/browser/transaction.d.ts +4 -4
- package/browser/transaction.d.ts.map +1 -1
- package/browser/types.d.ts +5 -3
- package/browser/types.d.ts.map +1 -1
- package/browser/workers/WorkerSigningPool.d.ts +24 -17
- package/browser/workers/WorkerSigningPool.d.ts.map +1 -1
- package/browser/workers/WorkerSigningPool.node.d.ts +19 -12
- package/browser/workers/WorkerSigningPool.node.d.ts.map +1 -1
- package/browser/workers/WorkerSigningPool.sequential.d.ts +67 -0
- package/browser/workers/WorkerSigningPool.sequential.d.ts.map +1 -0
- package/browser/workers/WorkerSigningPool.worklet.d.ts +64 -0
- package/browser/workers/WorkerSigningPool.worklet.d.ts.map +1 -0
- package/browser/workers/index.browser.d.ts +16 -0
- package/browser/workers/index.browser.d.ts.map +1 -0
- package/browser/workers/index.d.ts +4 -64
- package/browser/workers/index.d.ts.map +1 -1
- package/browser/workers/index.js +28 -0
- package/browser/workers/index.node.d.ts +17 -0
- package/browser/workers/index.node.d.ts.map +1 -0
- package/browser/workers/index.react-native.d.ts +28 -0
- package/browser/workers/index.react-native.d.ts.map +1 -0
- package/browser/workers/index.shared.d.ts +15 -0
- package/browser/workers/index.shared.d.ts.map +1 -0
- package/browser/workers/psbt-parallel.d.ts +2 -3
- package/browser/workers/psbt-parallel.d.ts.map +1 -1
- package/browser/workers/types.d.ts +17 -0
- package/browser/workers/types.d.ts.map +1 -1
- package/build/address.d.ts +6 -2
- package/build/address.d.ts.map +1 -1
- package/build/address.js +32 -19
- package/build/address.js.map +1 -1
- package/build/bech32utils.js.map +1 -1
- package/build/block.d.ts.map +1 -1
- package/build/block.js +2 -4
- package/build/block.js.map +1 -1
- package/build/branded.d.ts +3 -14
- package/build/branded.d.ts.map +1 -1
- package/build/branded.js +0 -5
- package/build/branded.js.map +1 -1
- package/build/crypto.d.ts +1 -1
- package/build/ecc/context.d.ts +25 -24
- package/build/ecc/context.d.ts.map +1 -1
- package/build/ecc/context.js +29 -101
- package/build/ecc/context.js.map +1 -1
- package/build/ecc/index.d.ts +1 -1
- package/build/ecc/index.d.ts.map +1 -1
- package/build/ecc/types.d.ts +7 -126
- package/build/ecc/types.d.ts.map +1 -1
- package/build/ecc/types.js +4 -1
- package/build/ecc/types.js.map +1 -1
- package/build/env.d.ts +13 -0
- package/build/env.d.ts.map +1 -0
- package/build/env.js +198 -0
- package/build/env.js.map +1 -0
- package/build/index.d.ts +8 -7
- package/build/index.d.ts.map +1 -1
- package/build/index.js +9 -7
- package/build/index.js.map +1 -1
- package/build/io/BinaryReader.d.ts +15 -15
- package/build/io/BinaryReader.d.ts.map +1 -1
- package/build/io/BinaryReader.js +17 -17
- package/build/io/BinaryReader.js.map +1 -1
- package/build/io/BinaryWriter.d.ts +17 -17
- package/build/io/BinaryWriter.d.ts.map +1 -1
- package/build/io/BinaryWriter.js +39 -39
- package/build/io/BinaryWriter.js.map +1 -1
- package/build/io/hex.d.ts.map +1 -1
- package/build/io/hex.js +2 -1
- package/build/io/hex.js.map +1 -1
- package/build/io/index.d.ts +0 -1
- package/build/io/index.d.ts.map +1 -1
- package/build/io/index.js +0 -2
- package/build/io/index.js.map +1 -1
- package/build/opcodes.d.ts +11 -0
- package/build/opcodes.d.ts.map +1 -1
- package/build/opcodes.js +19 -4
- package/build/opcodes.js.map +1 -1
- package/build/payments/bip341.d.ts +1 -2
- package/build/payments/bip341.d.ts.map +1 -1
- package/build/payments/bip341.js +1 -2
- package/build/payments/bip341.js.map +1 -1
- package/build/payments/embed.d.ts +1 -1
- package/build/payments/embed.d.ts.map +1 -1
- package/build/payments/embed.js +14 -14
- package/build/payments/embed.js.map +1 -1
- package/build/payments/p2ms.d.ts.map +1 -1
- package/build/payments/p2ms.js +21 -21
- package/build/payments/p2ms.js.map +1 -1
- package/build/payments/p2op.d.ts +1 -1
- package/build/payments/p2op.d.ts.map +1 -1
- package/build/payments/p2op.js +18 -18
- package/build/payments/p2op.js.map +1 -1
- package/build/payments/p2pk.d.ts +1 -1
- package/build/payments/p2pk.d.ts.map +1 -1
- package/build/payments/p2pk.js +17 -17
- package/build/payments/p2pk.js.map +1 -1
- package/build/payments/p2pkh.d.ts +1 -1
- package/build/payments/p2pkh.d.ts.map +1 -1
- package/build/payments/p2pkh.js +20 -20
- package/build/payments/p2pkh.js.map +1 -1
- package/build/payments/p2sh.d.ts.map +1 -1
- package/build/payments/p2sh.js +22 -20
- package/build/payments/p2sh.js.map +1 -1
- package/build/payments/p2tr.d.ts +2 -2
- package/build/payments/p2tr.d.ts.map +1 -1
- package/build/payments/p2tr.js +25 -26
- package/build/payments/p2tr.js.map +1 -1
- package/build/payments/p2wpkh.d.ts +1 -1
- package/build/payments/p2wpkh.d.ts.map +1 -1
- package/build/payments/p2wpkh.js +20 -20
- package/build/payments/p2wpkh.js.map +1 -1
- package/build/payments/p2wsh.d.ts.map +1 -1
- package/build/payments/p2wsh.js +22 -22
- package/build/payments/p2wsh.js.map +1 -1
- package/build/payments/types.d.ts +1 -1
- package/build/payments/types.d.ts.map +1 -1
- package/build/psbt/PsbtCache.d.ts +54 -0
- package/build/psbt/PsbtCache.d.ts.map +1 -0
- package/build/psbt/PsbtCache.js +249 -0
- package/build/psbt/PsbtCache.js.map +1 -0
- package/build/psbt/PsbtFinalizer.d.ts +21 -0
- package/build/psbt/PsbtFinalizer.d.ts.map +1 -0
- package/build/psbt/PsbtFinalizer.js +157 -0
- package/build/psbt/PsbtFinalizer.js.map +1 -0
- package/build/psbt/PsbtSigner.d.ts +32 -0
- package/build/psbt/PsbtSigner.d.ts.map +1 -0
- package/build/psbt/PsbtSigner.js +192 -0
- package/build/psbt/PsbtSigner.js.map +1 -0
- package/build/psbt/PsbtTransaction.d.ts +25 -0
- package/build/psbt/PsbtTransaction.d.ts.map +1 -0
- package/build/psbt/PsbtTransaction.js +61 -0
- package/build/psbt/PsbtTransaction.js.map +1 -0
- package/build/psbt/bip371.d.ts.map +1 -1
- package/build/psbt/bip371.js +6 -2
- package/build/psbt/bip371.js.map +1 -1
- package/build/psbt/psbtutils.js +1 -1
- package/build/psbt/psbtutils.js.map +1 -1
- package/build/psbt/types.d.ts +5 -71
- package/build/psbt/types.d.ts.map +1 -1
- package/build/psbt/validation.d.ts +1 -1
- package/build/psbt/validation.d.ts.map +1 -1
- package/build/psbt/validation.js +1 -1
- package/build/psbt/validation.js.map +1 -1
- package/build/psbt.d.ts +26 -40
- package/build/psbt.d.ts.map +1 -1
- package/build/psbt.js +180 -808
- package/build/psbt.js.map +1 -1
- package/build/script.d.ts.map +1 -1
- package/build/script.js +4 -4
- package/build/script.js.map +1 -1
- package/build/transaction.d.ts +4 -4
- package/build/transaction.d.ts.map +1 -1
- package/build/transaction.js +6 -5
- package/build/transaction.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/build/types.d.ts +5 -3
- package/build/types.d.ts.map +1 -1
- package/build/types.js +14 -25
- package/build/types.js.map +1 -1
- package/build/workers/WorkerSigningPool.d.ts +24 -17
- package/build/workers/WorkerSigningPool.d.ts.map +1 -1
- package/build/workers/WorkerSigningPool.js +36 -25
- package/build/workers/WorkerSigningPool.js.map +1 -1
- package/build/workers/WorkerSigningPool.node.d.ts +19 -12
- package/build/workers/WorkerSigningPool.node.d.ts.map +1 -1
- package/build/workers/WorkerSigningPool.node.js +60 -28
- package/build/workers/WorkerSigningPool.node.js.map +1 -1
- package/build/workers/WorkerSigningPool.sequential.d.ts +76 -0
- package/build/workers/WorkerSigningPool.sequential.d.ts.map +1 -0
- package/build/workers/WorkerSigningPool.sequential.js +160 -0
- package/build/workers/WorkerSigningPool.sequential.js.map +1 -0
- package/build/workers/WorkerSigningPool.worklet.d.ts +79 -0
- package/build/workers/WorkerSigningPool.worklet.d.ts.map +1 -0
- package/build/workers/WorkerSigningPool.worklet.js +390 -0
- package/build/workers/WorkerSigningPool.worklet.js.map +1 -0
- package/build/workers/index.browser.d.ts +24 -0
- package/build/workers/index.browser.d.ts.map +1 -0
- package/build/workers/index.browser.js +30 -0
- package/build/workers/index.browser.js.map +1 -0
- package/build/workers/index.d.ts +6 -18
- package/build/workers/index.d.ts.map +1 -1
- package/build/workers/index.js +12 -14
- package/build/workers/index.js.map +1 -1
- package/build/workers/index.node.d.ts +38 -0
- package/build/workers/index.node.d.ts.map +1 -0
- package/build/workers/index.node.js +45 -0
- package/build/workers/index.node.js.map +1 -0
- package/build/workers/index.react-native.d.ts +28 -0
- package/build/workers/index.react-native.d.ts.map +1 -0
- package/build/workers/index.react-native.js +67 -0
- package/build/workers/index.react-native.js.map +1 -0
- package/build/workers/index.shared.d.ts +15 -0
- package/build/workers/index.shared.d.ts.map +1 -0
- package/build/workers/index.shared.js +20 -0
- package/build/workers/index.shared.js.map +1 -0
- package/build/workers/psbt-parallel.d.ts +2 -3
- package/build/workers/psbt-parallel.d.ts.map +1 -1
- package/build/workers/psbt-parallel.js +4 -4
- package/build/workers/psbt-parallel.js.map +1 -1
- package/build/workers/types.d.ts +17 -0
- package/build/workers/types.d.ts.map +1 -1
- package/build/workers/types.js.map +1 -1
- package/package.json +48 -9
- package/src/address.ts +53 -21
- package/src/bech32utils.ts +3 -3
- package/src/block.ts +17 -10
- package/src/branded.ts +15 -13
- package/src/crypto.ts +1 -1
- package/src/ecc/context.ts +36 -136
- package/src/ecc/index.ts +2 -2
- package/src/ecc/types.ts +7 -145
- package/src/env.ts +239 -0
- package/src/index.ts +57 -22
- package/src/io/BinaryReader.ts +18 -18
- package/src/io/BinaryWriter.ts +43 -43
- package/src/io/hex.ts +2 -1
- package/src/io/index.ts +0 -3
- package/src/opcodes.ts +21 -4
- package/src/payments/bip341.ts +5 -7
- package/src/payments/embed.ts +19 -19
- package/src/payments/p2ms.ts +34 -27
- package/src/payments/p2op.ts +22 -22
- package/src/payments/p2pk.ts +22 -22
- package/src/payments/p2pkh.ts +28 -28
- package/src/payments/p2sh.ts +33 -30
- package/src/payments/p2tr.ts +40 -40
- package/src/payments/p2wpkh.ts +30 -30
- package/src/payments/p2wsh.ts +29 -29
- package/src/payments/types.ts +1 -1
- package/src/psbt/PsbtCache.ts +325 -0
- package/src/psbt/PsbtFinalizer.ts +213 -0
- package/src/psbt/PsbtSigner.ts +302 -0
- package/src/psbt/PsbtTransaction.ts +82 -0
- package/src/psbt/bip371.ts +7 -3
- package/src/psbt/psbtutils.ts +1 -1
- package/src/psbt/types.ts +5 -94
- package/src/psbt/validation.ts +5 -12
- package/src/psbt.ts +376 -1201
- package/src/script.ts +6 -9
- package/src/transaction.ts +19 -15
- package/src/types.ts +33 -45
- package/src/workers/WorkerSigningPool.node.ts +72 -36
- package/src/workers/WorkerSigningPool.sequential.ts +191 -0
- package/src/workers/WorkerSigningPool.ts +48 -39
- package/src/workers/WorkerSigningPool.worklet.ts +522 -0
- package/src/workers/index.browser.ts +34 -0
- package/src/workers/index.node.ts +50 -0
- package/src/workers/index.react-native.ts +110 -0
- package/src/workers/index.shared.ts +58 -0
- package/src/workers/index.ts +14 -65
- package/src/workers/psbt-parallel.ts +8 -13
- package/src/workers/types.ts +26 -1
- package/test/address.spec.ts +2 -2
- package/test/bitcoin.core.spec.ts +5 -2
- package/test/browser/payments.spec.ts +151 -0
- package/test/browser/psbt.spec.ts +1510 -0
- package/test/browser/script.spec.ts +223 -0
- package/test/browser/setup.ts +13 -0
- package/test/browser/workers-signing.spec.ts +537 -0
- package/test/crypto.spec.ts +2 -2
- package/test/env.spec.ts +418 -0
- package/test/fixtures/core/base58_encode_decode.json +12 -48
- package/test/fixtures/core/base58_keys_invalid.json +50 -150
- package/test/fixtures/core/sighash.json +1 -3
- package/test/fixtures/core/tx_valid.json +133 -501
- package/test/fixtures/embed.json +3 -11
- package/test/fixtures/p2ms.json +21 -91
- package/test/fixtures/p2pk.json +5 -24
- package/test/fixtures/p2pkh.json +7 -36
- package/test/fixtures/p2sh.json +8 -54
- package/test/fixtures/p2tr.json +2 -6
- package/test/fixtures/p2wpkh.json +7 -36
- package/test/fixtures/p2wsh.json +14 -59
- package/test/fixtures/psbt.json +2 -6
- package/test/fixtures/script.json +12 -48
- package/test/integration/addresses.spec.ts +11 -5
- package/test/integration/bip32.spec.ts +1 -1
- package/test/integration/cltv.spec.ts +10 -6
- package/test/integration/csv.spec.ts +10 -9
- package/test/integration/payments.spec.ts +8 -4
- package/test/integration/taproot.spec.ts +26 -6
- package/test/integration/transactions.spec.ts +22 -8
- package/test/payments.spec.ts +1 -1
- package/test/payments.utils.ts +1 -1
- package/test/psbt.spec.ts +250 -64
- package/test/script_signature.spec.ts +1 -1
- package/test/transaction.spec.ts +18 -5
- package/test/tsconfig.json +6 -20
- package/test/workers-pool.spec.ts +65 -23
- package/test/workers-sequential.spec.ts +669 -0
- package/test/workers-signing.spec.ts +7 -3
- package/test/workers-worklet.spec.ts +500 -0
- package/test/workers.spec.ts +6 -7
- package/typedoc.json +39 -0
- package/vite.config.browser.ts +31 -6
- package/vitest.config.browser.ts +68 -0
- package/browser/ecpair.d.ts +0 -99
- package/browser/io/MemoryPool.d.ts +0 -220
- package/browser/io/MemoryPool.d.ts.map +0 -1
- package/build/io/MemoryPool.d.ts +0 -220
- package/build/io/MemoryPool.d.ts.map +0 -1
- package/build/io/MemoryPool.js +0 -309
- package/build/io/MemoryPool.js.map +0 -1
- package/src/ecpair.d.ts +0 -99
- package/src/io/MemoryPool.ts +0 -343
- package/test/taproot-cache.spec.ts +0 -694
package/build/branded.d.ts
CHANGED
|
@@ -1,20 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Branded type definitions for type-safe primitives.
|
|
3
3
|
*
|
|
4
|
+
* Re-exported from @btc-vision/ecpair to ensure cross-package type compatibility.
|
|
5
|
+
*
|
|
4
6
|
* @packageDocumentation
|
|
5
7
|
*/
|
|
6
|
-
|
|
7
|
-
type Brand<T, B extends string> = T & {
|
|
8
|
-
readonly [__brand]: B;
|
|
9
|
-
};
|
|
10
|
-
export type Bytes32 = Brand<Uint8Array, 'Bytes32'>;
|
|
11
|
-
export type Bytes20 = Brand<Uint8Array, 'Bytes20'>;
|
|
12
|
-
export type PublicKey = Brand<Uint8Array, 'PublicKey'>;
|
|
13
|
-
export type XOnlyPublicKey = Brand<Uint8Array, 'XOnlyPublicKey'>;
|
|
14
|
-
export type Satoshi = Brand<bigint, 'Satoshi'>;
|
|
15
|
-
export type PrivateKey = Brand<Uint8Array, 'PrivateKey'>;
|
|
16
|
-
export type Signature = Brand<Uint8Array, 'Signature'>;
|
|
17
|
-
export type SchnorrSignature = Brand<Uint8Array, 'SchnorrSignature'>;
|
|
18
|
-
export type Script = Brand<Uint8Array, 'Script'>;
|
|
19
|
-
export {};
|
|
8
|
+
export type { Brand, Bytes32, Bytes20, PublicKey, XOnlyPublicKey, Satoshi, PrivateKey, Signature, SchnorrSignature, MessageHash, Script, } from '@btc-vision/ecpair';
|
|
20
9
|
//# sourceMappingURL=branded.d.ts.map
|
package/build/branded.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"branded.d.ts","sourceRoot":"","sources":["../src/branded.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"branded.d.ts","sourceRoot":"","sources":["../src/branded.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,YAAY,EACR,KAAK,EACL,OAAO,EACP,OAAO,EACP,SAAS,EACT,cAAc,EACd,OAAO,EACP,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,WAAW,EACX,MAAM,GACT,MAAM,oBAAoB,CAAC"}
|
package/build/branded.js
CHANGED
package/build/branded.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"branded.js","sourceRoot":"","sources":["../src/branded.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"branded.js","sourceRoot":"","sources":["../src/branded.ts"],"names":[],"mappings":""}
|
package/build/crypto.d.ts
CHANGED
package/build/ecc/context.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @packageDocumentation
|
|
6
6
|
*/
|
|
7
|
-
import type {
|
|
7
|
+
import type { CryptoBackend } from '@btc-vision/ecpair';
|
|
8
8
|
/**
|
|
9
9
|
* Context class for managing the ECC library instance.
|
|
10
10
|
* Uses dependency injection pattern instead of global singleton.
|
|
@@ -12,10 +12,11 @@ import type { EccLib } from './types.js';
|
|
|
12
12
|
* @example
|
|
13
13
|
* ```typescript
|
|
14
14
|
* import { EccContext } from '@btc-vision/bitcoin';
|
|
15
|
-
* import
|
|
15
|
+
* import { createNobleBackend } from '@btc-vision/ecpair';
|
|
16
16
|
*
|
|
17
17
|
* // Initialize once at app startup
|
|
18
|
-
*
|
|
18
|
+
* const backend = createNobleBackend();
|
|
19
|
+
* EccContext.init(backend);
|
|
19
20
|
*
|
|
20
21
|
* // Get instance anywhere in your code
|
|
21
22
|
* const ecc = EccContext.get();
|
|
@@ -27,23 +28,27 @@ import type { EccLib } from './types.js';
|
|
|
27
28
|
export declare class EccContext {
|
|
28
29
|
#private;
|
|
29
30
|
private constructor();
|
|
31
|
+
/**
|
|
32
|
+
* The underlying ECC library instance.
|
|
33
|
+
*/
|
|
34
|
+
get lib(): CryptoBackend;
|
|
30
35
|
/**
|
|
31
36
|
* Initializes the ECC context with the provided library.
|
|
32
37
|
* The library is verified before being set as active.
|
|
33
38
|
*
|
|
34
|
-
* @param lib - The
|
|
39
|
+
* @param lib - The CryptoBackend instance to initialize
|
|
35
40
|
* @returns The initialized EccContext instance
|
|
36
|
-
* @throws Error if the
|
|
41
|
+
* @throws Error if the CryptoBackend fails verification
|
|
37
42
|
*
|
|
38
43
|
* @example
|
|
39
44
|
* ```typescript
|
|
40
45
|
* import { EccContext } from '@btc-vision/bitcoin';
|
|
41
|
-
* import
|
|
46
|
+
* import { createNobleBackend } from '@btc-vision/ecpair';
|
|
42
47
|
*
|
|
43
|
-
* const context = EccContext.init(
|
|
48
|
+
* const context = EccContext.init(createNobleBackend());
|
|
44
49
|
* ```
|
|
45
50
|
*/
|
|
46
|
-
static init(lib:
|
|
51
|
+
static init(lib: CryptoBackend): EccContext;
|
|
47
52
|
/**
|
|
48
53
|
* Gets the initialized ECC context.
|
|
49
54
|
*
|
|
@@ -55,7 +60,7 @@ export declare class EccContext {
|
|
|
55
60
|
* import { EccContext } from '@btc-vision/bitcoin';
|
|
56
61
|
*
|
|
57
62
|
* const context = EccContext.get();
|
|
58
|
-
* const
|
|
63
|
+
* const tweaked = context.lib.xOnlyPointAddTweak(key, tweak);
|
|
59
64
|
* ```
|
|
60
65
|
*/
|
|
61
66
|
static get(): EccContext;
|
|
@@ -82,54 +87,50 @@ export declare class EccContext {
|
|
|
82
87
|
* import { EccContext } from '@btc-vision/bitcoin';
|
|
83
88
|
*
|
|
84
89
|
* if (!EccContext.isInitialized()) {
|
|
85
|
-
* EccContext.init(
|
|
90
|
+
* EccContext.init(createNobleBackend());
|
|
86
91
|
* }
|
|
87
92
|
* ```
|
|
88
93
|
*/
|
|
89
94
|
static isInitialized(): boolean;
|
|
90
|
-
/**
|
|
91
|
-
* The underlying ECC library instance.
|
|
92
|
-
*/
|
|
93
|
-
get lib(): EccLib;
|
|
94
95
|
}
|
|
95
96
|
/**
|
|
96
97
|
* Initializes the ECC library with the provided instance.
|
|
97
98
|
* This is a convenience function that wraps EccContext.init().
|
|
98
99
|
* Pass `undefined` to clear the library.
|
|
99
100
|
*
|
|
100
|
-
* @param eccLib - The
|
|
101
|
-
* @throws Error if the
|
|
101
|
+
* @param eccLib - The CryptoBackend instance to initialize, or undefined to clear
|
|
102
|
+
* @throws Error if the CryptoBackend fails verification
|
|
102
103
|
*
|
|
103
104
|
* @example
|
|
104
105
|
* ```typescript
|
|
105
106
|
* import { initEccLib } from '@btc-vision/bitcoin';
|
|
106
|
-
* import
|
|
107
|
+
* import { createNobleBackend } from '@btc-vision/ecpair';
|
|
107
108
|
*
|
|
108
109
|
* // Initialize the ECC library
|
|
109
|
-
* initEccLib(
|
|
110
|
+
* initEccLib(createNobleBackend());
|
|
110
111
|
*
|
|
111
112
|
* // Clear the library
|
|
112
113
|
* initEccLib(undefined);
|
|
113
114
|
* ```
|
|
114
115
|
*/
|
|
115
|
-
export declare function initEccLib(eccLib:
|
|
116
|
+
export declare function initEccLib(eccLib: CryptoBackend | undefined): void;
|
|
116
117
|
/**
|
|
117
118
|
* Retrieves the initialized ECC library instance.
|
|
118
119
|
* This is a convenience function that wraps EccContext.get().lib.
|
|
119
120
|
*
|
|
120
|
-
* @returns The
|
|
121
|
+
* @returns The CryptoBackend instance
|
|
121
122
|
* @throws Error if the ECC library has not been initialized
|
|
122
123
|
*
|
|
123
124
|
* @example
|
|
124
125
|
* ```typescript
|
|
125
126
|
* import { getEccLib, initEccLib } from '@btc-vision/bitcoin';
|
|
126
|
-
* import
|
|
127
|
+
* import { createNobleBackend } from '@btc-vision/ecpair';
|
|
127
128
|
*
|
|
128
|
-
* initEccLib(
|
|
129
|
+
* initEccLib(createNobleBackend());
|
|
129
130
|
*
|
|
130
131
|
* const ecc = getEccLib();
|
|
131
|
-
* const
|
|
132
|
+
* const tweaked = ecc.xOnlyPointAddTweak(pubkey, tweak);
|
|
132
133
|
* ```
|
|
133
134
|
*/
|
|
134
|
-
export declare function getEccLib():
|
|
135
|
+
export declare function getEccLib(): CryptoBackend;
|
|
135
136
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/ecc/context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/ecc/context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGxD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,UAAU;;IAInB,OAAO;IAIP;;OAEG;IACH,IAAI,GAAG,IAAI,aAAa,CAEvB;IAED;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,aAAa,GAAG,UAAU;IAU3C;;;;;;;;;;;;;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,aAAa,GAAG,SAAS,GAAG,IAAI,CAMlE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,SAAS,IAAI,aAAa,CAEzC"}
|
package/build/ecc/context.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { verifyCryptoBackend } from '@btc-vision/ecpair';
|
|
2
2
|
/**
|
|
3
3
|
* Context class for managing the ECC library instance.
|
|
4
4
|
* Uses dependency injection pattern instead of global singleton.
|
|
@@ -6,10 +6,11 @@ import { fromHex, equals } from '../io/index.js';
|
|
|
6
6
|
* @example
|
|
7
7
|
* ```typescript
|
|
8
8
|
* import { EccContext } from '@btc-vision/bitcoin';
|
|
9
|
-
* import
|
|
9
|
+
* import { createNobleBackend } from '@btc-vision/ecpair';
|
|
10
10
|
*
|
|
11
11
|
* // Initialize once at app startup
|
|
12
|
-
*
|
|
12
|
+
* const backend = createNobleBackend();
|
|
13
|
+
* EccContext.init(backend);
|
|
13
14
|
*
|
|
14
15
|
* // Get instance anywhere in your code
|
|
15
16
|
* const ecc = EccContext.get();
|
|
@@ -24,24 +25,34 @@ export class EccContext {
|
|
|
24
25
|
constructor(lib) {
|
|
25
26
|
this.#lib = lib;
|
|
26
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* The underlying ECC library instance.
|
|
30
|
+
*/
|
|
31
|
+
get lib() {
|
|
32
|
+
return this.#lib;
|
|
33
|
+
}
|
|
27
34
|
/**
|
|
28
35
|
* Initializes the ECC context with the provided library.
|
|
29
36
|
* The library is verified before being set as active.
|
|
30
37
|
*
|
|
31
|
-
* @param lib - The
|
|
38
|
+
* @param lib - The CryptoBackend instance to initialize
|
|
32
39
|
* @returns The initialized EccContext instance
|
|
33
|
-
* @throws Error if the
|
|
40
|
+
* @throws Error if the CryptoBackend fails verification
|
|
34
41
|
*
|
|
35
42
|
* @example
|
|
36
43
|
* ```typescript
|
|
37
44
|
* import { EccContext } from '@btc-vision/bitcoin';
|
|
38
|
-
* import
|
|
45
|
+
* import { createNobleBackend } from '@btc-vision/ecpair';
|
|
39
46
|
*
|
|
40
|
-
* const context = EccContext.init(
|
|
47
|
+
* const context = EccContext.init(createNobleBackend());
|
|
41
48
|
* ```
|
|
42
49
|
*/
|
|
43
50
|
static init(lib) {
|
|
44
|
-
|
|
51
|
+
// Skip re-verification if same lib is already initialized
|
|
52
|
+
if (EccContext.#instance && EccContext.#instance.#lib === lib) {
|
|
53
|
+
return EccContext.#instance;
|
|
54
|
+
}
|
|
55
|
+
verifyCryptoBackend(lib);
|
|
45
56
|
EccContext.#instance = new EccContext(lib);
|
|
46
57
|
return EccContext.#instance;
|
|
47
58
|
}
|
|
@@ -56,7 +67,7 @@ export class EccContext {
|
|
|
56
67
|
* import { EccContext } from '@btc-vision/bitcoin';
|
|
57
68
|
*
|
|
58
69
|
* const context = EccContext.get();
|
|
59
|
-
* const
|
|
70
|
+
* const tweaked = context.lib.xOnlyPointAddTweak(key, tweak);
|
|
60
71
|
* ```
|
|
61
72
|
*/
|
|
62
73
|
static get() {
|
|
@@ -90,35 +101,29 @@ export class EccContext {
|
|
|
90
101
|
* import { EccContext } from '@btc-vision/bitcoin';
|
|
91
102
|
*
|
|
92
103
|
* if (!EccContext.isInitialized()) {
|
|
93
|
-
* EccContext.init(
|
|
104
|
+
* EccContext.init(createNobleBackend());
|
|
94
105
|
* }
|
|
95
106
|
* ```
|
|
96
107
|
*/
|
|
97
108
|
static isInitialized() {
|
|
98
109
|
return EccContext.#instance !== undefined;
|
|
99
110
|
}
|
|
100
|
-
/**
|
|
101
|
-
* The underlying ECC library instance.
|
|
102
|
-
*/
|
|
103
|
-
get lib() {
|
|
104
|
-
return this.#lib;
|
|
105
|
-
}
|
|
106
111
|
}
|
|
107
112
|
/**
|
|
108
113
|
* Initializes the ECC library with the provided instance.
|
|
109
114
|
* This is a convenience function that wraps EccContext.init().
|
|
110
115
|
* Pass `undefined` to clear the library.
|
|
111
116
|
*
|
|
112
|
-
* @param eccLib - The
|
|
113
|
-
* @throws Error if the
|
|
117
|
+
* @param eccLib - The CryptoBackend instance to initialize, or undefined to clear
|
|
118
|
+
* @throws Error if the CryptoBackend fails verification
|
|
114
119
|
*
|
|
115
120
|
* @example
|
|
116
121
|
* ```typescript
|
|
117
122
|
* import { initEccLib } from '@btc-vision/bitcoin';
|
|
118
|
-
* import
|
|
123
|
+
* import { createNobleBackend } from '@btc-vision/ecpair';
|
|
119
124
|
*
|
|
120
125
|
* // Initialize the ECC library
|
|
121
|
-
* initEccLib(
|
|
126
|
+
* initEccLib(createNobleBackend());
|
|
122
127
|
*
|
|
123
128
|
* // Clear the library
|
|
124
129
|
* initEccLib(undefined);
|
|
@@ -135,98 +140,21 @@ export function initEccLib(eccLib) {
|
|
|
135
140
|
* Retrieves the initialized ECC library instance.
|
|
136
141
|
* This is a convenience function that wraps EccContext.get().lib.
|
|
137
142
|
*
|
|
138
|
-
* @returns The
|
|
143
|
+
* @returns The CryptoBackend instance
|
|
139
144
|
* @throws Error if the ECC library has not been initialized
|
|
140
145
|
*
|
|
141
146
|
* @example
|
|
142
147
|
* ```typescript
|
|
143
148
|
* import { getEccLib, initEccLib } from '@btc-vision/bitcoin';
|
|
144
|
-
* import
|
|
149
|
+
* import { createNobleBackend } from '@btc-vision/ecpair';
|
|
145
150
|
*
|
|
146
|
-
* initEccLib(
|
|
151
|
+
* initEccLib(createNobleBackend());
|
|
147
152
|
*
|
|
148
153
|
* const ecc = getEccLib();
|
|
149
|
-
* const
|
|
154
|
+
* const tweaked = ecc.xOnlyPointAddTweak(pubkey, tweak);
|
|
150
155
|
* ```
|
|
151
156
|
*/
|
|
152
157
|
export function getEccLib() {
|
|
153
158
|
return EccContext.get().lib;
|
|
154
159
|
}
|
|
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
160
|
//# sourceMappingURL=context.js.map
|
package/build/ecc/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/ecc/context.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/ecc/context.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,UAAU;IACnB,MAAM,CAAC,SAAS,CAAyB;IAChC,IAAI,CAAgB;IAE7B,YAAoB,GAAkB;QAClC,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,GAAkB;QAC1B,0DAA0D;QAC1D,IAAI,UAAU,CAAC,SAAS,IAAI,UAAU,CAAC,SAAS,CAAC,IAAI,KAAK,GAAG,EAAE,CAAC;YAC5D,OAAO,UAAU,CAAC,SAAS,CAAC;QAChC,CAAC;QACD,mBAAmB,CAAC,GAAG,CAAC,CAAC;QACzB,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,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CACX,4EAA4E,CAC/E,CAAC;QACN,CAAC;QACD,OAAO,UAAU,CAAC,SAAS,CAAC;IAChC,CAAC;IAED;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,KAAK;QACR,UAAU,CAAC,SAAS,GAAG,SAAS,CAAC;IACrC,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,aAAa;QAChB,OAAO,UAAU,CAAC,SAAS,KAAK,SAAS,CAAC;IAC9C,CAAC;CACJ;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,UAAU,CAAC,MAAiC;IACxD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACvB,UAAU,CAAC,KAAK,EAAE,CAAC;QACnB,OAAO;IACX,CAAC;IACD,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,SAAS;IACrB,OAAO,UAAU,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC;AAChC,CAAC"}
|
package/build/ecc/index.d.ts
CHANGED
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
|
-
export type { EccLib, XOnlyPointAddTweakResult, Parity } from './types.js';
|
|
9
|
+
export type { CryptoBackend, EccLib, XOnlyPointAddTweakResult, Parity } from './types.js';
|
|
10
10
|
export { EccContext, initEccLib, getEccLib } from './context.js';
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
package/build/ecc/index.d.ts.map
CHANGED
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ecc/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,wBAAwB,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAG1F,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC"}
|
package/build/ecc/types.d.ts
CHANGED
|
@@ -1,134 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ECC (Elliptic Curve Cryptography) type definitions.
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
|
+
* Re-exports {@link CryptoBackend} from `@btc-vision/ecpair` as the canonical
|
|
5
|
+
* interface for secp256k1 operations. The legacy `EccLib` name is kept as a
|
|
6
|
+
* type alias for backward compatibility.
|
|
4
7
|
*
|
|
5
8
|
* @packageDocumentation
|
|
6
9
|
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Parity of the y-coordinate for an x-only public key.
|
|
10
|
-
* - 0: even y-coordinate
|
|
11
|
-
* - 1: odd y-coordinate
|
|
12
|
-
*/
|
|
13
|
-
export type Parity = 0 | 1;
|
|
10
|
+
export type { CryptoBackend, XOnlyPointAddTweakResult, Parity } from '@btc-vision/ecpair';
|
|
14
11
|
/**
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
export interface XOnlyPointAddTweakResult {
|
|
18
|
-
/** Parity of the resulting y-coordinate (0 = even, 1 = odd) */
|
|
19
|
-
readonly parity: Parity;
|
|
20
|
-
/** The resulting x-only public key */
|
|
21
|
-
readonly xOnlyPubkey: XOnlyPublicKey;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Interface for the ECC library used by this library.
|
|
25
|
-
* This is compatible with tiny-secp256k1 and @noble/secp256k1.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```typescript
|
|
29
|
-
* import { EccLib, initEccLib } from '@btc-vision/bitcoin';
|
|
30
|
-
* import * as secp256k1 from 'tiny-secp256k1';
|
|
31
|
-
*
|
|
32
|
-
* // tiny-secp256k1 implements EccLib
|
|
33
|
-
* const ecc: EccLib = secp256k1;
|
|
34
|
-
* initEccLib(ecc);
|
|
35
|
-
* ```
|
|
12
|
+
* @deprecated Use {@link CryptoBackend} from `@btc-vision/ecpair` instead.
|
|
36
13
|
*/
|
|
37
|
-
export
|
|
38
|
-
/**
|
|
39
|
-
* Checks if a 32-byte value is a valid x-only public key.
|
|
40
|
-
*
|
|
41
|
-
* @param p - 32-byte x-coordinate
|
|
42
|
-
* @returns True if the point is valid on the secp256k1 curve
|
|
43
|
-
*/
|
|
44
|
-
isXOnlyPoint(p: Uint8Array): boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Adds a tweak to an x-only public key.
|
|
47
|
-
*
|
|
48
|
-
* @param p - 32-byte x-only public key
|
|
49
|
-
* @param tweak - 32-byte scalar to add
|
|
50
|
-
* @returns The tweaked public key with parity, or null if result is invalid
|
|
51
|
-
*/
|
|
52
|
-
xOnlyPointAddTweak(p: XOnlyPublicKey, tweak: Bytes32): XOnlyPointAddTweakResult | null;
|
|
53
|
-
/**
|
|
54
|
-
* Signs a 32-byte message hash with a private key (ECDSA).
|
|
55
|
-
* Optional - only needed for signing operations.
|
|
56
|
-
*
|
|
57
|
-
* @param hash - 32-byte message hash
|
|
58
|
-
* @param privateKey - 32-byte private key
|
|
59
|
-
* @returns DER-encoded signature
|
|
60
|
-
*/
|
|
61
|
-
sign?(hash: Bytes32, privateKey: PrivateKey): Signature;
|
|
62
|
-
/**
|
|
63
|
-
* Signs a 32-byte message hash with a private key (Schnorr/BIP340).
|
|
64
|
-
* Optional - only needed for Taproot key-path signing.
|
|
65
|
-
*
|
|
66
|
-
* @param hash - 32-byte message hash
|
|
67
|
-
* @param privateKey - 32-byte private key
|
|
68
|
-
* @returns 64-byte Schnorr signature
|
|
69
|
-
*/
|
|
70
|
-
signSchnorr?(hash: Bytes32, privateKey: PrivateKey): SchnorrSignature;
|
|
71
|
-
/**
|
|
72
|
-
* Verifies an ECDSA signature.
|
|
73
|
-
* Optional - only needed for signature verification.
|
|
74
|
-
*
|
|
75
|
-
* @param hash - 32-byte message hash
|
|
76
|
-
* @param publicKey - 33 or 65-byte public key
|
|
77
|
-
* @param signature - DER-encoded signature
|
|
78
|
-
* @returns True if signature is valid
|
|
79
|
-
*/
|
|
80
|
-
verify?(hash: Bytes32, publicKey: PublicKey, signature: Signature): boolean;
|
|
81
|
-
/**
|
|
82
|
-
* Verifies a Schnorr/BIP340 signature.
|
|
83
|
-
* Optional - only needed for Taproot signature verification.
|
|
84
|
-
*
|
|
85
|
-
* @param hash - 32-byte message hash
|
|
86
|
-
* @param publicKey - 32-byte x-only public key
|
|
87
|
-
* @param signature - 64-byte Schnorr signature
|
|
88
|
-
* @returns True if signature is valid
|
|
89
|
-
*/
|
|
90
|
-
verifySchnorr?(hash: Bytes32, publicKey: XOnlyPublicKey, signature: SchnorrSignature): boolean;
|
|
91
|
-
/**
|
|
92
|
-
* Derives a public key from a private key.
|
|
93
|
-
* Optional - only needed for key derivation.
|
|
94
|
-
*
|
|
95
|
-
* @param privateKey - 32-byte private key
|
|
96
|
-
* @param compressed - Whether to return compressed (33-byte) or uncompressed (65-byte)
|
|
97
|
-
* @returns The public key, or null if private key is invalid
|
|
98
|
-
*/
|
|
99
|
-
pointFromScalar?(privateKey: PrivateKey, compressed?: boolean): PublicKey | null;
|
|
100
|
-
/**
|
|
101
|
-
* Computes the x-only public key from a private key.
|
|
102
|
-
* Optional - only needed for Taproot key derivation.
|
|
103
|
-
*
|
|
104
|
-
* @param privateKey - 32-byte private key
|
|
105
|
-
* @returns 32-byte x-only public key, or null if private key is invalid
|
|
106
|
-
*/
|
|
107
|
-
xOnlyPointFromScalar?(privateKey: PrivateKey): XOnlyPublicKey | null;
|
|
108
|
-
/**
|
|
109
|
-
* Converts a full public key to x-only format.
|
|
110
|
-
* Optional - only needed when working with x-only keys.
|
|
111
|
-
*
|
|
112
|
-
* @param pubkey - 33 or 65-byte public key
|
|
113
|
-
* @returns 32-byte x-only public key
|
|
114
|
-
*/
|
|
115
|
-
xOnlyPointFromPoint?(pubkey: PublicKey): XOnlyPublicKey;
|
|
116
|
-
/**
|
|
117
|
-
* Adds a scalar to a private key.
|
|
118
|
-
* Optional - only needed for key tweaking.
|
|
119
|
-
*
|
|
120
|
-
* @param privateKey - 32-byte private key
|
|
121
|
-
* @param tweak - 32-byte scalar to add
|
|
122
|
-
* @returns The tweaked private key, or null if result is invalid
|
|
123
|
-
*/
|
|
124
|
-
privateAdd?(privateKey: PrivateKey, tweak: Bytes32): PrivateKey | null;
|
|
125
|
-
/**
|
|
126
|
-
* Negates a private key.
|
|
127
|
-
* Optional - only needed for Taproot parity handling.
|
|
128
|
-
*
|
|
129
|
-
* @param privateKey - 32-byte private key
|
|
130
|
-
* @returns The negated private key
|
|
131
|
-
*/
|
|
132
|
-
privateNegate?(privateKey: PrivateKey): PrivateKey;
|
|
133
|
-
}
|
|
14
|
+
export type { CryptoBackend as EccLib } from '@btc-vision/ecpair';
|
|
134
15
|
//# sourceMappingURL=types.d.ts.map
|
package/build/ecc/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ecc/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ecc/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,YAAY,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE1F;;GAEG;AACH,YAAY,EAAE,aAAa,IAAI,MAAM,EAAE,MAAM,oBAAoB,CAAC"}
|
package/build/ecc/types.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ECC (Elliptic Curve Cryptography) type definitions.
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
|
+
* Re-exports {@link CryptoBackend} from `@btc-vision/ecpair` as the canonical
|
|
5
|
+
* interface for secp256k1 operations. The legacy `EccLib` name is kept as a
|
|
6
|
+
* type alias for backward compatibility.
|
|
4
7
|
*
|
|
5
8
|
* @packageDocumentation
|
|
6
9
|
*/
|
package/build/ecc/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/ecc/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/ecc/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|
package/build/env.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime capability verification and polyfills.
|
|
3
|
+
*
|
|
4
|
+
* Polyfills features that can be shimmed (TextEncoder, Map, Promise.allSettled, Symbol.dispose).
|
|
5
|
+
* Throws early with a clear error for features that cannot be polyfilled (BigInt, Uint8Array,
|
|
6
|
+
* structuredClone, DataView BigInt methods).
|
|
7
|
+
*
|
|
8
|
+
* Imported as a side effect by the main entry point.
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=env.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
|