@btc-vision/bitcoin 7.0.0-alpha.2 → 7.0.0-alpha.3

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.
Files changed (51) hide show
  1. package/README.md +334 -161
  2. package/browser/ecc/context.d.ts +22 -21
  3. package/browser/ecc/context.d.ts.map +1 -1
  4. package/browser/ecc/index.d.ts +1 -1
  5. package/browser/ecc/index.d.ts.map +1 -1
  6. package/browser/ecc/types.d.ts +10 -123
  7. package/browser/ecc/types.d.ts.map +1 -1
  8. package/browser/index.d.ts +2 -2
  9. package/browser/index.d.ts.map +1 -1
  10. package/browser/index.js +5790 -4062
  11. package/browser/payments/p2tr.d.ts.map +1 -1
  12. package/browser/psbt/types.d.ts +2 -68
  13. package/browser/psbt/types.d.ts.map +1 -1
  14. package/browser/psbt.d.ts +9 -11
  15. package/browser/psbt.d.ts.map +1 -1
  16. package/browser/types.d.ts +1 -1
  17. package/browser/types.d.ts.map +1 -1
  18. package/build/ecc/context.d.ts +22 -21
  19. package/build/ecc/context.d.ts.map +1 -1
  20. package/build/ecc/context.js +19 -114
  21. package/build/ecc/context.js.map +1 -1
  22. package/build/ecc/index.d.ts +1 -1
  23. package/build/ecc/index.d.ts.map +1 -1
  24. package/build/ecc/types.d.ts +7 -126
  25. package/build/ecc/types.d.ts.map +1 -1
  26. package/build/ecc/types.js +4 -1
  27. package/build/ecc/types.js.map +1 -1
  28. package/build/index.d.ts +2 -2
  29. package/build/index.d.ts.map +1 -1
  30. package/build/index.js.map +1 -1
  31. package/build/payments/p2tr.d.ts.map +1 -1
  32. package/build/payments/p2tr.js +2 -3
  33. package/build/payments/p2tr.js.map +1 -1
  34. package/build/psbt/types.d.ts +2 -68
  35. package/build/psbt/types.d.ts.map +1 -1
  36. package/build/psbt.d.ts +9 -11
  37. package/build/psbt.d.ts.map +1 -1
  38. package/build/psbt.js +38 -53
  39. package/build/psbt.js.map +1 -1
  40. package/build/tsconfig.build.tsbuildinfo +1 -1
  41. package/build/types.d.ts +1 -1
  42. package/build/types.d.ts.map +1 -1
  43. package/package.json +4 -4
  44. package/src/ecc/context.ts +26 -147
  45. package/src/ecc/index.ts +2 -2
  46. package/src/ecc/types.ts +7 -138
  47. package/src/index.ts +1 -2
  48. package/src/payments/p2tr.ts +2 -2
  49. package/src/psbt/types.ts +2 -84
  50. package/src/psbt.ts +63 -121
  51. package/src/types.ts +1 -1
@@ -4,9 +4,8 @@
4
4
  *
5
5
  * @packageDocumentation
6
6
  */
7
- import type { EccLib } from './types.js';
8
- import { equals, fromHex } from '../io/index.js';
9
- import type { Bytes32, XOnlyPublicKey } from '../types.js';
7
+ import type { CryptoBackend } from '@btc-vision/ecpair';
8
+ import { verifyCryptoBackend } from '@btc-vision/ecpair';
10
9
 
11
10
  /**
12
11
  * Context class for managing the ECC library instance.
@@ -15,10 +14,11 @@ import type { Bytes32, XOnlyPublicKey } from '../types.js';
15
14
  * @example
16
15
  * ```typescript
17
16
  * import { EccContext } from '@btc-vision/bitcoin';
18
- * import * as secp256k1 from 'tiny-secp256k1';
17
+ * import { createNobleBackend } from '@btc-vision/ecpair';
19
18
  *
20
19
  * // Initialize once at app startup
21
- * EccContext.init(secp256k1);
20
+ * const backend = createNobleBackend();
21
+ * EccContext.init(backend);
22
22
  *
23
23
  * // Get instance anywhere in your code
24
24
  * const ecc = EccContext.get();
@@ -29,16 +29,16 @@ import type { Bytes32, XOnlyPublicKey } from '../types.js';
29
29
  */
30
30
  export class EccContext {
31
31
  static #instance: EccContext | undefined;
32
- readonly #lib: EccLib;
32
+ readonly #lib: CryptoBackend;
33
33
 
34
- private constructor(lib: EccLib) {
34
+ private constructor(lib: CryptoBackend) {
35
35
  this.#lib = lib;
36
36
  }
37
37
 
38
38
  /**
39
39
  * The underlying ECC library instance.
40
40
  */
41
- get lib(): EccLib {
41
+ get lib(): CryptoBackend {
42
42
  return this.#lib;
43
43
  }
44
44
 
@@ -46,24 +46,24 @@ export class EccContext {
46
46
  * Initializes the ECC context with the provided library.
47
47
  * The library is verified before being set as active.
48
48
  *
49
- * @param lib - The ECC library instance to initialize
49
+ * @param lib - The CryptoBackend instance to initialize
50
50
  * @returns The initialized EccContext instance
51
- * @throws Error if the ECC library fails verification
51
+ * @throws Error if the CryptoBackend fails verification
52
52
  *
53
53
  * @example
54
54
  * ```typescript
55
55
  * import { EccContext } from '@btc-vision/bitcoin';
56
- * import * as secp256k1 from 'tiny-secp256k1';
56
+ * import { createNobleBackend } from '@btc-vision/ecpair';
57
57
  *
58
- * const context = EccContext.init(secp256k1);
58
+ * const context = EccContext.init(createNobleBackend());
59
59
  * ```
60
60
  */
61
- static init(lib: EccLib): EccContext {
61
+ static init(lib: CryptoBackend): EccContext {
62
62
  // Skip re-verification if same lib is already initialized
63
63
  if (EccContext.#instance && EccContext.#instance.#lib === lib) {
64
64
  return EccContext.#instance;
65
65
  }
66
- verifyEcc(lib);
66
+ verifyCryptoBackend(lib);
67
67
  EccContext.#instance = new EccContext(lib);
68
68
  return EccContext.#instance;
69
69
  }
@@ -79,7 +79,7 @@ export class EccContext {
79
79
  * import { EccContext } from '@btc-vision/bitcoin';
80
80
  *
81
81
  * const context = EccContext.get();
82
- * const isValid = context.lib.isXOnlyPoint(someKey);
82
+ * const tweaked = context.lib.xOnlyPointAddTweak(key, tweak);
83
83
  * ```
84
84
  */
85
85
  static get(): EccContext {
@@ -117,7 +117,7 @@ export class EccContext {
117
117
  * import { EccContext } from '@btc-vision/bitcoin';
118
118
  *
119
119
  * if (!EccContext.isInitialized()) {
120
- * EccContext.init(secp256k1);
120
+ * EccContext.init(createNobleBackend());
121
121
  * }
122
122
  * ```
123
123
  */
@@ -131,22 +131,22 @@ export class EccContext {
131
131
  * This is a convenience function that wraps EccContext.init().
132
132
  * Pass `undefined` to clear the library.
133
133
  *
134
- * @param eccLib - The ECC library instance to initialize, or undefined to clear
135
- * @throws Error if the ECC library fails verification
134
+ * @param eccLib - The CryptoBackend instance to initialize, or undefined to clear
135
+ * @throws Error if the CryptoBackend fails verification
136
136
  *
137
137
  * @example
138
138
  * ```typescript
139
139
  * import { initEccLib } from '@btc-vision/bitcoin';
140
- * import * as secp256k1 from 'tiny-secp256k1';
140
+ * import { createNobleBackend } from '@btc-vision/ecpair';
141
141
  *
142
142
  * // Initialize the ECC library
143
- * initEccLib(secp256k1);
143
+ * initEccLib(createNobleBackend());
144
144
  *
145
145
  * // Clear the library
146
146
  * initEccLib(undefined);
147
147
  * ```
148
148
  */
149
- export function initEccLib(eccLib: EccLib | undefined): void {
149
+ export function initEccLib(eccLib: CryptoBackend | undefined): void {
150
150
  if (eccLib === undefined) {
151
151
  EccContext.clear();
152
152
  return;
@@ -158,141 +158,20 @@ export function initEccLib(eccLib: EccLib | undefined): void {
158
158
  * Retrieves the initialized ECC library instance.
159
159
  * This is a convenience function that wraps EccContext.get().lib.
160
160
  *
161
- * @returns The ECC library instance
161
+ * @returns The CryptoBackend instance
162
162
  * @throws Error if the ECC library has not been initialized
163
163
  *
164
164
  * @example
165
165
  * ```typescript
166
166
  * import { getEccLib, initEccLib } from '@btc-vision/bitcoin';
167
- * import * as secp256k1 from 'tiny-secp256k1';
167
+ * import { createNobleBackend } from '@btc-vision/ecpair';
168
168
  *
169
- * initEccLib(secp256k1);
169
+ * initEccLib(createNobleBackend());
170
170
  *
171
171
  * const ecc = getEccLib();
172
- * const isValid = ecc.isXOnlyPoint(somePublicKey);
172
+ * const tweaked = ecc.xOnlyPointAddTweak(pubkey, tweak);
173
173
  * ```
174
174
  */
175
- export function getEccLib(): EccLib {
175
+ export function getEccLib(): CryptoBackend {
176
176
  return EccContext.get().lib;
177
177
  }
178
-
179
- // ============================================================================
180
- // Verification
181
- // ============================================================================
182
-
183
- interface TweakAddVector {
184
- pubkey: Uint8Array;
185
- tweak: Uint8Array;
186
- parity: 0 | 1 | -1;
187
- result: Uint8Array | null;
188
- }
189
-
190
- // Lazily decoded test vectors (decoded once on first verification)
191
- let _tweakVectors: TweakAddVector[] | undefined;
192
- let _validPoints: Uint8Array[] | undefined;
193
- let _invalidPoints: Uint8Array[] | undefined;
194
-
195
- function getTweakVectors(): TweakAddVector[] {
196
- if (!_tweakVectors) {
197
- _tweakVectors = [
198
- {
199
- pubkey: fromHex('79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798'),
200
- tweak: fromHex('fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140'),
201
- parity: -1,
202
- result: null,
203
- },
204
- {
205
- pubkey: fromHex('1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b'),
206
- tweak: fromHex('a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac'),
207
- parity: 1,
208
- result: fromHex('e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf'),
209
- },
210
- {
211
- pubkey: fromHex('2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991'),
212
- tweak: fromHex('823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47'),
213
- parity: 0,
214
- result: fromHex('9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c'),
215
- },
216
- ];
217
- }
218
- return _tweakVectors;
219
- }
220
-
221
- function getValidPoints(): Uint8Array[] {
222
- if (!_validPoints) {
223
- _validPoints = [
224
- fromHex('79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798'),
225
- fromHex('fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e'),
226
- fromHex('f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9'),
227
- fromHex('0000000000000000000000000000000000000000000000000000000000000001'),
228
- ];
229
- }
230
- return _validPoints;
231
- }
232
-
233
- function getInvalidPoints(): Uint8Array[] {
234
- if (!_invalidPoints) {
235
- _invalidPoints = [
236
- fromHex('0000000000000000000000000000000000000000000000000000000000000000'),
237
- fromHex('fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f'),
238
- ];
239
- }
240
- return _invalidPoints;
241
- }
242
-
243
- /**
244
- * Verifies that the ECC library implementation is correct.
245
- * Tests `isXOnlyPoint` and `xOnlyPointAddTweak` with known test vectors.
246
- *
247
- * @param ecc - The ECC library to verify
248
- * @throws Error if any verification test fails
249
- */
250
- function verifyEcc(ecc: EccLib): void {
251
- if (typeof ecc.isXOnlyPoint !== 'function') {
252
- throw new Error('ECC library missing isXOnlyPoint function');
253
- }
254
-
255
- // Test isXOnlyPoint with valid points (pre-decoded)
256
- for (const point of getValidPoints()) {
257
- if (!ecc.isXOnlyPoint(point)) {
258
- throw new Error('ECC library isXOnlyPoint failed for a valid point');
259
- }
260
- }
261
-
262
- // Test isXOnlyPoint with invalid points (pre-decoded)
263
- for (const point of getInvalidPoints()) {
264
- if (ecc.isXOnlyPoint(point)) {
265
- throw new Error('ECC library isXOnlyPoint should reject invalid point');
266
- }
267
- }
268
-
269
- // Test xOnlyPointAddTweak
270
- if (typeof ecc.xOnlyPointAddTweak !== 'function') {
271
- throw new Error('ECC library missing xOnlyPointAddTweak function');
272
- }
273
-
274
- for (const vector of getTweakVectors()) {
275
- const result = ecc.xOnlyPointAddTweak(
276
- vector.pubkey as XOnlyPublicKey,
277
- vector.tweak as Bytes32,
278
- );
279
-
280
- if (vector.result === null) {
281
- if (result !== null) {
282
- throw new Error(
283
- 'ECC library xOnlyPointAddTweak should return null for test vector',
284
- );
285
- }
286
- } else {
287
- if (result === null) {
288
- throw new Error('ECC library xOnlyPointAddTweak returned null unexpectedly');
289
- }
290
- if (result.parity !== vector.parity) {
291
- throw new Error('ECC library xOnlyPointAddTweak parity mismatch');
292
- }
293
- if (!equals(result.xOnlyPubkey, vector.result)) {
294
- throw new Error('ECC library xOnlyPointAddTweak result mismatch');
295
- }
296
- }
297
- }
298
- }
package/src/ecc/index.ts CHANGED
@@ -7,8 +7,8 @@
7
7
  * @packageDocumentation
8
8
  */
9
9
 
10
- // Core types
11
- export type { EccLib, XOnlyPointAddTweakResult, Parity } from './types.js';
10
+ // Core types (CryptoBackend is the canonical name; EccLib is a deprecated alias)
11
+ export type { CryptoBackend, EccLib, XOnlyPointAddTweakResult, Parity } from './types.js';
12
12
 
13
13
  // Context management
14
14
  export { EccContext, initEccLib, getEccLib } from './context.js';
package/src/ecc/types.ts CHANGED
@@ -1,147 +1,16 @@
1
1
  /**
2
2
  * ECC (Elliptic Curve Cryptography) type definitions.
3
- * Defines interfaces for secp256k1 operations used in Taproot and signatures.
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
10
 
8
- import type { Bytes32, PrivateKey, PublicKey, SchnorrSignature, Signature, XOnlyPublicKey, } from '../branded.js';
9
-
10
- /**
11
- * Parity of the y-coordinate for an x-only public key.
12
- * - 0: even y-coordinate
13
- * - 1: odd y-coordinate
14
- */
15
- export type Parity = 0 | 1;
16
-
17
- /**
18
- * Result of x-only point addition with tweak.
19
- */
20
- export interface XOnlyPointAddTweakResult {
21
- /** Parity of the resulting y-coordinate (0 = even, 1 = odd) */
22
- readonly parity: Parity;
23
- /** The resulting x-only public key */
24
- readonly xOnlyPubkey: XOnlyPublicKey;
25
- }
11
+ export type { CryptoBackend, XOnlyPointAddTweakResult, Parity } from '@btc-vision/ecpair';
26
12
 
27
13
  /**
28
- * Interface for the ECC library used by this library.
29
- * This is compatible with tiny-secp256k1 and @noble/secp256k1.
30
- *
31
- * @example
32
- * ```typescript
33
- * import { EccLib, initEccLib } from '@btc-vision/bitcoin';
34
- * import * as secp256k1 from 'tiny-secp256k1';
35
- *
36
- * // tiny-secp256k1 implements EccLib
37
- * const ecc: EccLib = secp256k1;
38
- * initEccLib(ecc);
39
- * ```
14
+ * @deprecated Use {@link CryptoBackend} from `@btc-vision/ecpair` instead.
40
15
  */
41
- export interface EccLib {
42
- /**
43
- * Checks if a 32-byte value is a valid x-only public key.
44
- *
45
- * @param p - 32-byte x-coordinate
46
- * @returns True if the point is valid on the secp256k1 curve
47
- */
48
- isXOnlyPoint(p: Uint8Array): boolean;
49
-
50
- /**
51
- * Adds a tweak to an x-only public key.
52
- *
53
- * @param p - 32-byte x-only public key
54
- * @param tweak - 32-byte scalar to add
55
- * @returns The tweaked public key with parity, or null if result is invalid
56
- */
57
- xOnlyPointAddTweak(p: XOnlyPublicKey, tweak: Bytes32): XOnlyPointAddTweakResult | null;
58
-
59
- /**
60
- * Signs a 32-byte message hash with a private key (ECDSA).
61
- * Optional - only needed for signing operations.
62
- *
63
- * @param hash - 32-byte message hash
64
- * @param privateKey - 32-byte private key
65
- * @returns DER-encoded signature
66
- */
67
- sign?(hash: Bytes32, privateKey: PrivateKey): Signature;
68
-
69
- /**
70
- * Signs a 32-byte message hash with a private key (Schnorr/BIP340).
71
- * Optional - only needed for Taproot key-path signing.
72
- *
73
- * @param hash - 32-byte message hash
74
- * @param privateKey - 32-byte private key
75
- * @returns 64-byte Schnorr signature
76
- */
77
- signSchnorr?(hash: Bytes32, privateKey: PrivateKey): SchnorrSignature;
78
-
79
- /**
80
- * Verifies an ECDSA signature.
81
- * Optional - only needed for signature verification.
82
- *
83
- * @param hash - 32-byte message hash
84
- * @param publicKey - 33 or 65-byte public key
85
- * @param signature - DER-encoded signature
86
- * @returns True if signature is valid
87
- */
88
- verify?(hash: Bytes32, publicKey: PublicKey, signature: Signature): boolean;
89
-
90
- /**
91
- * Verifies a Schnorr/BIP340 signature.
92
- * Optional - only needed for Taproot signature verification.
93
- *
94
- * @param hash - 32-byte message hash
95
- * @param publicKey - 32-byte x-only public key
96
- * @param signature - 64-byte Schnorr signature
97
- * @returns True if signature is valid
98
- */
99
- verifySchnorr?(hash: Bytes32, publicKey: XOnlyPublicKey, signature: SchnorrSignature): boolean;
100
-
101
- /**
102
- * Derives a public key from a private key.
103
- * Optional - only needed for key derivation.
104
- *
105
- * @param privateKey - 32-byte private key
106
- * @param compressed - Whether to return compressed (33-byte) or uncompressed (65-byte)
107
- * @returns The public key, or null if private key is invalid
108
- */
109
- pointFromScalar?(privateKey: PrivateKey, compressed?: boolean): PublicKey | null;
110
-
111
- /**
112
- * Computes the x-only public key from a private key.
113
- * Optional - only needed for Taproot key derivation.
114
- *
115
- * @param privateKey - 32-byte private key
116
- * @returns 32-byte x-only public key, or null if private key is invalid
117
- */
118
- xOnlyPointFromScalar?(privateKey: PrivateKey): XOnlyPublicKey | null;
119
-
120
- /**
121
- * Converts a full public key to x-only format.
122
- * Optional - only needed when working with x-only keys.
123
- *
124
- * @param pubkey - 33 or 65-byte public key
125
- * @returns 32-byte x-only public key
126
- */
127
- xOnlyPointFromPoint?(pubkey: PublicKey): XOnlyPublicKey;
128
-
129
- /**
130
- * Adds a scalar to a private key.
131
- * Optional - only needed for key tweaking.
132
- *
133
- * @param privateKey - 32-byte private key
134
- * @param tweak - 32-byte scalar to add
135
- * @returns The tweaked private key, or null if result is invalid
136
- */
137
- privateAdd?(privateKey: PrivateKey, tweak: Bytes32): PrivateKey | null;
138
-
139
- /**
140
- * Negates a private key.
141
- * Optional - only needed for Taproot parity handling.
142
- *
143
- * @param privateKey - 32-byte private key
144
- * @returns The negated private key
145
- */
146
- privateNegate?(privateKey: PrivateKey): PrivateKey;
147
- }
16
+ export type { CryptoBackend as EccLib } from '@btc-vision/ecpair';
package/src/index.ts CHANGED
@@ -63,7 +63,6 @@ export type {
63
63
  PsbtOutputExtendedScript,
64
64
  HDSigner,
65
65
  HDSignerAsync,
66
- SignerAlternative,
67
66
  Signer,
68
67
  SignerAsync,
69
68
  TaprootHashCheckSigner,
@@ -83,7 +82,7 @@ export type { TaprootHashCache } from './transaction.js';
83
82
  export type { Network } from './networks.js';
84
83
  /** @hidden */
85
84
  export { initEccLib, getEccLib, EccContext } from './ecc/context.js';
86
- export type { EccLib } from './ecc/types.js';
85
+ export type { CryptoBackend, EccLib } from './ecc/types.js';
87
86
  export { PaymentType } from './payments/index.js';
88
87
  export type {
89
88
  Payment,
@@ -9,11 +9,11 @@
9
9
 
10
10
  import { bech32m } from 'bech32';
11
11
  import { fromBech32 } from '../bech32utils.js';
12
- import { getEccLib } from '../ecc/context.js';
13
12
  import { bitcoin as BITCOIN_NETWORK, type Network } from '../networks.js';
14
13
  import * as bscript from '../script.js';
15
14
  import {
16
15
  type Bytes32,
16
+ isXOnlyPublicKey,
17
17
  type SchnorrSignature,
18
18
  type Script,
19
19
  stacksEqual,
@@ -716,7 +716,7 @@ export class P2TR {
716
716
  throw new TypeError('Internal pubkey mismatch');
717
717
  }
718
718
 
719
- if (!getEccLib().isXOnlyPoint(internalPk)) {
719
+ if (!isXOnlyPublicKey(internalPk)) {
720
720
  throw new TypeError('Invalid internalPubkey for p2tr witness');
721
721
  }
722
722
 
package/src/psbt/types.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  import type { Psbt as PsbtBase, PsbtGlobal, PsbtInput, PsbtOutput } from 'bip174';
7
7
  import type { Network } from '../networks.js';
8
8
  import type { TaprootHashCache, Transaction } from '../transaction.js';
9
- import type { Bytes32, MessageHash, PublicKey, Satoshi, SchnorrSignature, Script, Signature } from '../types.js';
9
+ import type { Bytes32, MessageHash, PublicKey, Satoshi, Script } from '../types.js';
10
10
 
11
11
  /**
12
12
  * Transaction input interface for PSBT.
@@ -102,89 +102,7 @@ export interface PsbtOutputExtendedScript extends PsbtOutput {
102
102
  readonly value: Satoshi;
103
103
  }
104
104
 
105
- /**
106
- * Base interface for HD signers.
107
- */
108
- interface HDSignerBase {
109
- /**
110
- * DER format compressed publicKey Uint8Array
111
- */
112
- readonly publicKey: PublicKey;
113
- /**
114
- * The first 4 bytes of the sha256-ripemd160 of the publicKey
115
- */
116
- readonly fingerprint: Uint8Array;
117
- }
118
-
119
- /**
120
- * HD signer interface for synchronous signing.
121
- */
122
- export interface HDSigner extends HDSignerBase {
123
- /**
124
- * The path string must match /^m(\/\d+'?)+$/
125
- * ex. m/44'/0'/0'/1/23 levels with ' must be hard derivations
126
- */
127
- derivePath(path: string): HDSigner;
128
-
129
- /**
130
- * Input hash (the "message digest") for the signature algorithm
131
- * Return a 64 byte signature (32 byte r and 32 byte s in that order)
132
- */
133
- sign(hash: MessageHash): Uint8Array;
134
- }
135
-
136
- /**
137
- * HD signer interface for asynchronous signing.
138
- */
139
- export interface HDSignerAsync extends HDSignerBase {
140
- derivePath(path: string): HDSignerAsync;
141
-
142
- sign(hash: MessageHash): Promise<Uint8Array>;
143
- }
144
-
145
- /**
146
- * Alternative signer interface with lowR support.
147
- */
148
- export interface SignerAlternative {
149
- readonly publicKey: PublicKey;
150
- readonly lowR: boolean;
151
-
152
- sign(hash: MessageHash, lowR?: boolean): Signature;
153
-
154
- verify(hash: MessageHash, signature: Signature): boolean;
155
-
156
- signSchnorr(hash: MessageHash): SchnorrSignature;
157
-
158
- verifySchnorr(hash: MessageHash, signature: SchnorrSignature): boolean;
159
- }
160
-
161
- /**
162
- * Basic signer interface for synchronous signing.
163
- */
164
- export interface Signer {
165
- readonly publicKey: PublicKey;
166
- readonly network?: Network | undefined;
167
-
168
- sign(hash: MessageHash, lowR?: boolean): Signature;
169
-
170
- signSchnorr?(hash: MessageHash): SchnorrSignature;
171
-
172
- getPublicKey?(): PublicKey;
173
- }
174
-
175
- /**
176
- * Basic signer interface for asynchronous signing.
177
- */
178
- export interface SignerAsync {
179
- readonly publicKey: PublicKey;
180
- readonly network?: Network | undefined;
181
-
182
- sign(hash: MessageHash, lowR?: boolean): Promise<Signature>;
183
-
184
- signSchnorr?(hash: MessageHash): Promise<SchnorrSignature>;
185
-
186
- getPublicKey?(): PublicKey;
187
- }
105
+ export type { Signer, SignerAsync, HDSigner, HDSignerAsync } from '@btc-vision/ecpair';
188
106
 
189
107
  /**
190
108
  * Minimal key pair interface for checking Taproot hashes.