@did-btcr2/keypair 0.5.1 → 0.6.0

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.
@@ -1,69 +1,84 @@
1
1
  import { Hex, KeyBytes, Maybe, MultibaseObject, PublicKeyObject } from '@did-btcr2/common';
2
- import { SecretKey } from './secret.js';
2
+ import { Secp256k1SecretKey } from './secret.js';
3
3
  export interface Point {
4
4
  x: KeyBytes;
5
5
  y: KeyBytes;
6
6
  }
7
7
  /**
8
- * Interface for the PublicKey class.
9
- * @interface IPublicKey
10
- * @type {IPublicKey}
8
+ * General PublicKey Interface used by CompressedSecp256k1PublicKey.
9
+ * @interface PublicKey
10
+ * @type {PublicKey}
11
11
  */
12
- export interface IPublicKey {
12
+ export interface PublicKey {
13
+ /**
14
+ * Compressed public key getter.
15
+ * @readonly @type {KeyBytes} The 33 byte compressed public key [parity, x-coord].
16
+ */
17
+ compressed: KeyBytes;
13
18
  /**
14
19
  * Uncompressed public key getter.
15
20
  * @readonly @type {KeyBytes} The 65 byte uncompressed public key [0x04, x-coord, y-coord].
16
21
  */
17
22
  uncompressed: KeyBytes;
18
23
  /**
19
- * Compressed public key getter.
20
- * @readonly @type {KeyBytes} The 33 byte compressed public key [parity, x-coord].
24
+ * X-only public key getter.
25
+ * @readonly @type {KeyBytes} The 32 byte x-only public key [x-coord].
21
26
  */
22
- compressed: KeyBytes;
27
+ xOnly: KeyBytes;
23
28
  /**
24
- * PublicKey parity getter.
29
+ * CompressedSecp256k1PublicKey parity getter.
25
30
  * @readonly @type {number} The 1 byte parity (0x02 if even, 0x03 if odd).
26
31
  */
27
32
  parity: number;
28
33
  /**
29
- * PublicKey x-coordinate getter.
34
+ * CompressedSecp256k1PublicKey isEven getter.
35
+ * @readonly @type {boolean} True if the public key is even, false if odd.
36
+ */
37
+ isEven: boolean;
38
+ /**
39
+ * CompressedSecp256k1PublicKey x-coordinate getter.
30
40
  * @readonly @type {KeyBytes} The 32 byte x-coordinate of the public key.
31
41
  */
32
42
  x: KeyBytes;
33
43
  /**
34
- * PublicKey y-coordinate getter.
44
+ * CompressedSecp256k1PublicKey y-coordinate getter.
35
45
  * @readonly @type {KeyBytes} The 32 byte y-coordinate of the public key.
36
46
  */
37
47
  y: KeyBytes;
38
48
  /**
39
- * PublicKey multibase getter.
49
+ * CompressedSecp256k1PublicKey multibase getter.
40
50
  * @readonly @returns {MultibaseObject} The public key as MultibaseObject as a address string, key and prefix bytes.
41
51
  */
42
52
  multibase: MultibaseObject;
43
53
  /**
44
- * PublicKey hex string getter.
54
+ * CompressedSecp256k1PublicKey hex string getter.
45
55
  * @readonly @type {Hex} The public key as a hex string.
46
56
  */
47
57
  hex: Hex;
58
+ /**
59
+ * CompressedSecp256k1PublicKey point getter.
60
+ * @readonly @type {Point} The public key as a point (x, y).
61
+ */
62
+ point: Point;
48
63
  /**
49
64
  * Decode the base58btc multibase string to the compressed public key prefixed with 0x02.
50
65
  * @returns {KeyBytes} The public key as a 33-byte compressed public key with header.
51
66
  */
52
67
  decode(): KeyBytes;
53
68
  /**
54
- * Encode the PublicKey as an x-only base58btc multibase public key.
69
+ * Encode the CompressedSecp256k1PublicKey as an x-only base58btc multibase public key.
55
70
  * @returns {string} The public key formatted a base58btc multibase string.
56
71
  */
57
72
  encode(): string;
58
73
  /**
59
- * PublicKey key equality check. Checks if `this` public key is equal to `other` public key.
60
- * @param {PublicKey} other The public key to compare.
74
+ * CompressedSecp256k1PublicKey key equality check. Checks if `this` public key is equal to `other` public key.
75
+ * @param {CompressedSecp256k1PublicKey} other The public key to compare.
61
76
  * @returns {boolean} True if the public keys are equal.
62
77
  */
63
- equals(other: PublicKey): boolean;
78
+ equals(other: CompressedSecp256k1PublicKey): boolean;
64
79
  /**
65
- * JSON representation of a PublicKey object.
66
- * @returns {PublicKeyObject} The PublicKey as a JSON object.
80
+ * JSON representation of a CompressedSecp256k1PublicKey object.
81
+ * @returns {PublicKeyObject} The CompressedSecp256k1PublicKey as a JSON object.
67
82
  */
68
83
  json(): PublicKeyObject;
69
84
  }
@@ -71,16 +86,16 @@ export interface IPublicKey {
71
86
  * Encapsulates a secp256k1 public key compliant to BIP-340 BIP schnorr signature scheme.
72
87
  * Provides get methods for different formats (compressed, x-only, multibase).
73
88
  * Provides helpers methods for comparison and serialization.
74
- * @class PublicKey
75
- * @type {PublicKey}
89
+ * @class CompressedSecp256k1PublicKey
90
+ * @type {CompressedSecp256k1PublicKey}
76
91
  */
77
- export declare class PublicKey implements PublicKey {
92
+ export declare class CompressedSecp256k1PublicKey implements PublicKey {
78
93
  /** @type {KeyBytes} The public key bytes */
79
94
  private readonly _bytes;
80
95
  /** @type {MultibaseObject} The public key as a MultibaseObject */
81
96
  private _multibase;
82
97
  /**
83
- * Creates a PublicKey instance.
98
+ * Creates a CompressedSecp256k1PublicKey instance.
84
99
  * @param {KeyBytes} bytes The public key byte array.
85
100
  * @throws {PublicKeyError} if the byte length is not 32 (x-only) or 33 (compressed)
86
101
  */
@@ -96,10 +111,19 @@ export declare class PublicKey implements PublicKey {
96
111
  */
97
112
  get uncompressed(): KeyBytes;
98
113
  /**
99
- * Get the parity byte of the public key.
100
- * @returns {number} The parity byte of the public key.
114
+ * X-only (32-byte) view of the public key per BIP-340.
115
+ */
116
+ get xOnly(): KeyBytes;
117
+ /**
118
+ * Parity of the SEC compressed public key.
119
+ * @returns {0 | 1} The parity of the public key. 0 = even (0x02), 1 = odd (0x03).
120
+ */
121
+ get parity(): 0 | 1;
122
+ /**
123
+ * Whether the SEC compressed public key has even Y.
124
+ * @returns {boolean} True if the public key has even Y.
101
125
  */
102
- get parity(): number;
126
+ get isEven(): boolean;
103
127
  /**
104
128
  * Get the x-coordinate of the public key.
105
129
  * @returns {Uint8Array} The 32-byte x-coordinate of the public key.
@@ -125,6 +149,11 @@ export declare class PublicKey implements PublicKey {
125
149
  * @returns {Point} The public key point.
126
150
  */
127
151
  get point(): Point;
152
+ /**
153
+ * Returns the BIP-340 (x-only) representation of this key.
154
+ * @returns {KeyBytes} The BIP-340 (x-only) representation of the public key.
155
+ */
156
+ bip340(): KeyBytes;
128
157
  /**
129
158
  * Returns the point of the public key.
130
159
  * @param {Hex} pk The public key in hex (Uint8Array or string) format.
@@ -144,27 +173,27 @@ export declare class PublicKey implements PublicKey {
144
173
  encode(): string;
145
174
  /**
146
175
  * Compares this public key to another public key.
147
- * @param {PublicKey} other The other public key to compare
176
+ * @param {CompressedSecp256k1PublicKey} other The other public key to compare
148
177
  * @returns {boolean} True if the public keys are equal, false otherwise.
149
178
  */
150
- equals(other: PublicKey): boolean;
179
+ equals(other: CompressedSecp256k1PublicKey): boolean;
151
180
  /**
152
- * JSON representation of a PublicKey object.
153
- * @returns {PublicKeyObject} The PublicKey as a JSON object.
181
+ * JSON representation of a CompressedSecp256k1PublicKey object.
182
+ * @returns {PublicKeyObject} The CompressedSecp256k1PublicKey as a JSON object.
154
183
  */
155
184
  json(): PublicKeyObject;
156
185
  /**
157
- * Creates a PublicKey object from a JSON representation.
158
- * @param {PublicKeyObject} json The JSON object to initialize the PublicKey.
159
- * @returns {PublicKey} The initialized PublicKey object.
186
+ * Creates a CompressedSecp256k1PublicKey object from a JSON representation.
187
+ * @param {PublicKeyObject} json The JSON object to initialize the CompressedSecp256k1PublicKey.
188
+ * @returns {CompressedSecp256k1PublicKey} The initialized CompressedSecp256k1PublicKey object.
160
189
  */
161
- static fromJSON(json: Maybe<PublicKeyObject>): PublicKey;
190
+ static fromJSON(json: Maybe<PublicKeyObject>): CompressedSecp256k1PublicKey;
162
191
  /**
163
- * Computes the deterministic public key for a given private key.
164
- * @param {PrivateKey | KeyBytes} sk The PrivateKey object or the private key bytes
165
- * @returns {PublicKey} A new PublicKey object
192
+ * Computes the deterministic public key for a given secret key.
193
+ * @param {Secp256k1SecretKey | KeyBytes} sk The Secp256k1SecretKey object or the secret key bytes
194
+ * @returns {CompressedSecp256k1PublicKey} A new CompressedSecp256k1PublicKey object
166
195
  */
167
- static fromSecretKey(sk: SecretKey | KeyBytes): PublicKey;
196
+ static fromSecretKey(sk: Secp256k1SecretKey | KeyBytes): CompressedSecp256k1PublicKey;
168
197
  /**
169
198
  * Computes modular exponentiation: (base^exp) % mod.
170
199
  * Used for computing modular square roots.
@@ -188,10 +217,4 @@ export declare class PublicKey implements PublicKey {
188
217
  * @returns {Uint8Array} 65-byte uncompressed public key (starts with `0x04`)
189
218
  */
190
219
  liftX(): Uint8Array;
191
- /**
192
- * Static version of liftX method.
193
- * @param {KeyBytes} x The 32-byte x-coordinate to lift.
194
- * @returns {Uint8Array} The 65-byte uncompressed public key (0x04, x, y).
195
- */
196
- static xOnly(x: KeyBytes): Uint8Array;
197
220
  }
@@ -1 +1 @@
1
- {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/public.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,GAAG,EACH,QAAQ,EACR,KAAK,EACL,eAAe,EAEf,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,WAAW,KAAK;IACpB,CAAC,EAAE,QAAQ,CAAC;IACZ,CAAC,EAAE,QAAQ,CAAC;CACb;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,YAAY,EAAE,QAAQ,CAAC;IAEvB;;;OAGG;IACH,UAAU,EAAE,QAAQ,CAAC;IAErB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,CAAC,EAAE,QAAQ,CAAC;IAEZ;;;OAGG;IACH,CAAC,EAAE,QAAQ,CAAC;IAEZ;;;OAGG;IACH,SAAS,EAAE,eAAe,CAAC;IAE3B;;;OAGG;IACH,GAAG,EAAE,GAAG,CAAC;IAET;;;OAGG;IACH,MAAM,IAAI,QAAQ,CAAC;IAEnB;;;OAGG;IACH,MAAM,IAAI,MAAM,CAAC;IAEjB;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,OAA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;;OAMG;IACI,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM;IAI5C;;;;OAIG;IACI,KAAK,IAAI,UAAU;CAwB3B"}
@@ -1,12 +1,12 @@
1
1
  import { Bytes, Entropy, Hex, KeyBytes, SecretKeyObject } from '@did-btcr2/common';
2
2
  import { SchnorrKeyPair } from './pair.js';
3
- import { PublicKey } from './public.js';
3
+ import { CompressedSecp256k1PublicKey } from './public.js';
4
4
  /**
5
- * Interface for the SecretKey class.
6
- * @interface ISecretKey
7
- * @type {ISecretKey}
5
+ * General SecretKey interface for the Secp256k1SecretKey class.
6
+ * @interface SecretKey
7
+ * @type {SecretKey}
8
8
  */
9
- export interface ISecretKey {
9
+ export interface SecretKey {
10
10
  /**
11
11
  * Get the secret key bytes.
12
12
  * @readonly @type {KeyBytes} The secret key bytes.
@@ -25,13 +25,13 @@ export interface ISecretKey {
25
25
  hex: Hex;
26
26
  /**
27
27
  * Checks if this secret key is equal to another secret key.
28
- *
28
+ * @param {Secp256k1SecretKey} other The other secret key to compare.
29
29
  * @returns {boolean} True if the private keys are equal.
30
30
  */
31
- equals(other: SecretKey): boolean;
31
+ equals(other: Secp256k1SecretKey): boolean;
32
32
  /**
33
33
  * Uses the secret key to compute the corresponding public key.
34
- * @returns {KeyBytes} A new PublicKey object.
34
+ * @returns {KeyBytes} The computed public key bytes.
35
35
  */
36
36
  computePublicKey(): KeyBytes;
37
37
  /**
@@ -40,8 +40,8 @@ export interface ISecretKey {
40
40
  */
41
41
  isValid(): boolean;
42
42
  /**
43
- * JSON representation of a SecretKey object.
44
- * @returns {SecretKeyObject} The SecretKey as a JSON object.
43
+ * JSON representation of a Secp256k1SecretKey object.
44
+ * @returns {SecretKeyObject} The Secp256k1SecretKey as a JSON object.
45
45
  */
46
46
  json(): SecretKeyObject;
47
47
  }
@@ -49,11 +49,11 @@ export interface ISecretKey {
49
49
  * Encapsulates a secp256k1 secret key
50
50
  * Provides get methods for different formats (raw, secret, point).
51
51
  * Provides helpers methods for comparison, serialization and publicKey generation.
52
- * @class SecretKey
53
- * @type {SecretKey}
54
- *
52
+ * @class Secp256k1SecretKey
53
+ * @type {Secp256k1SecretKey}
54
+ * @implements {SecretKey}
55
55
  */
56
- export declare class SecretKey implements ISecretKey {
56
+ export declare class Secp256k1SecretKey implements SecretKey {
57
57
  /** @type {KeyBytes} The entropy for the secret key as a byte array */
58
58
  private _bytes?;
59
59
  /** @type {bigint} The entropy for the secret key as a bigint */
@@ -61,7 +61,7 @@ export declare class SecretKey implements ISecretKey {
61
61
  /** @type {string} The secret key as a secretKeyMultibase */
62
62
  private _multibase;
63
63
  /**
64
- * Instantiates an instance of SecretKey.
64
+ * Instantiates an instance of Secp256k1SecretKey.
65
65
  * @param {Entropy} entropy bytes (Uint8Array) or secret (bigint)
66
66
  * @throws {SecretKeyError} If entropy is not provided, not a valid 32-byte secret key or not a valid bigint seed
67
67
  */
@@ -93,10 +93,10 @@ export declare class SecretKey implements ISecretKey {
93
93
  encode(): string;
94
94
  /**
95
95
  * Checks if this secret key is equal to another.
96
- * @param {SecretKey} other The other secret key
96
+ * @param {Secp256k1SecretKey} other The other secret key
97
97
  * @returns {boolean} True if the private keys are equal, false otherwise
98
98
  */
99
- equals(other: SecretKey): boolean;
99
+ equals(other: Secp256k1SecretKey): boolean;
100
100
  /**
101
101
  * Computes the public key from the secret key bytes.
102
102
  * @returns {KeyBytes} The computed public key
@@ -114,10 +114,10 @@ export declare class SecretKey implements ISecretKey {
114
114
  isValid(): boolean;
115
115
  /**
116
116
  * Checks if the public key is a valid secp256k1 point.
117
- * @param {PublicKey} pk The public key to validate
117
+ * @param {CompressedSecp256k1PublicKey} pk The public key to validate
118
118
  * @returns {boolean} True if the public key is valid, false otherwise
119
119
  */
120
- isValidPair(pk: PublicKey): boolean;
120
+ hasValidPublicKey(pk: CompressedSecp256k1PublicKey): boolean;
121
121
  /**
122
122
  * Decodes the multibase string to the 34-byte secret key (2 byte prefix + 32 byte key).
123
123
  * @param {string} multibase The multibase string to decode
@@ -125,14 +125,14 @@ export declare class SecretKey implements ISecretKey {
125
125
  */
126
126
  static decode(multibase: string): Bytes;
127
127
  /**
128
- * Creates a SecretKey object from a JSON object.
128
+ * Creates a Secp256k1SecretKey object from a JSON object.
129
129
  * @param {SecretKeyObject} json The JSON object containing the secret key bytes
130
- * @returns {SecretKey} A new SecretKey object
130
+ * @returns {Secp256k1SecretKey} A new Secp256k1SecretKey object
131
131
  */
132
- static fromJSON(json: SecretKeyObject): SecretKey;
132
+ static fromJSON(json: SecretKeyObject): Secp256k1SecretKey;
133
133
  /**
134
- * Converts a SecretKey or KeyBytes to a Pair.
135
- * @param {KeyBytes} bytes
134
+ * Converts a Secp256k1SecretKey or KeyBytes to a SchnorrKeyPair.
135
+ * @param {KeyBytes} bytes The secret key bytes
136
136
  * @returns {SchnorrKeyPair} The SchnorrKeyPair object containing the public and private keys
137
137
  * @throws {SecretKeyError} If the secret key is not valid
138
138
  */
@@ -150,21 +150,21 @@ export declare class SecretKey implements ISecretKey {
150
150
  */
151
151
  static toBytes(secret: bigint): KeyBytes;
152
152
  /**
153
- * Creates a new SecretKey object from a bigint secret.
154
- * @param {bigint} secret The secret bigint
155
- * @returns {SecretKey} A new SecretKey object
153
+ * Creates a new Secp256k1SecretKey object from a bigint secret.
154
+ * @param {bigint} entropy The secret bigint
155
+ * @returns {Secp256k1SecretKey} A new Secp256k1SecretKey object
156
156
  */
157
- static fromSecret(secret: bigint): SecretKey;
157
+ static fromEntropy(entropy: bigint): Secp256k1SecretKey;
158
158
  /**
159
159
  * Generates random secret key bytes.
160
160
  * @returns {KeyBytes} Uint8Array of 32 random bytes.
161
161
  */
162
162
  static random(): KeyBytes;
163
163
  /**
164
- * Creates a new SecretKey from random secret key bytes.
165
- * @returns {SecretKey} A new SecretKey object
164
+ * Creates a new Secp256k1SecretKey from random secret key bytes.
165
+ * @returns {Secp256k1SecretKey} A new Secp256k1SecretKey object
166
166
  */
167
- static generate(): SecretKey;
167
+ static generate(): Secp256k1SecretKey;
168
168
  /**
169
169
  * Generates a public key from the given secret key bytes.
170
170
  * @param {KeyBytes} bytes The secret key bytes
@@ -1 +1 @@
1
- {"version":3,"file":"secret.d.ts","sourceRoot":"","sources":["../../src/secret.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,EAEL,OAAO,EACP,GAAG,EACH,QAAQ,EAER,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,KAAK,EAAE,QAAQ,CAAC;IAEhB;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,GAAG,EAAE,GAAG,CAAC;IAET;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC;IAElC;;;OAGG;IACH,gBAAgB,IAAI,QAAQ,CAAC;IAE7B;;;OAGG;IACH,OAAO,IAAI,OAAO,CAAC;IAGnB;;;OAGG;IACH,IAAI,IAAI,eAAe,CAAC;CACzB;AAED;;;;;;;GAOG;AACH,qBAAa,SAAU,YAAW,UAAU;IAC1C,sEAAsE;IACtE,OAAO,CAAC,MAAM,CAAC,CAAW;IAE1B,gEAAgE;IAChE,OAAO,CAAC,KAAK,CAAC,CAAS;IAEvB,4DAA4D;IAC5D,OAAO,CAAC,UAAU,CAAS;IAE3B;;;;OAIG;gBACS,OAAO,EAAE,OAAO;IAyC5B;;;OAGG;IACH,IAAI,KAAK,IAAI,UAAU,CAItB;IAED;;;OAGG;IACH,IAAI,IAAI,IAAI,MAAM,CAIjB;IAED;;;OAGG;IACH,IAAI,GAAG,IAAI,GAAG,CAGb;IAGD;;;OAGG;IACH,IAAI,SAAS,IAAI,MAAM,CAGtB;IAED;;;OAGG;IACI,MAAM,IAAI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IG;WACW,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ;IAiB/C;;;;OAIG;WACW,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB;IAS9D;;;OAGG;WACW,MAAM,IAAI,QAAQ;IAShC;;;OAGG;WACW,QAAQ,IAAI,kBAAkB;IAQ5C;;;;OAIG;WACW,YAAY,CAAC,KAAK,EAAE,QAAQ,GAAG,QAAQ;CAItD"}
@@ -0,0 +1,16 @@
1
+ import { KeyBytes } from '@did-btcr2/common';
2
+ import { CompressedSecp256k1PublicKey } from './public.js';
3
+ import { Secp256k1SecretKey } from './secret.js';
4
+ export type RawSchnorrKeyPair = {
5
+ public: KeyBytes;
6
+ secret?: KeyBytes;
7
+ };
8
+ /** Params for the {@link SchnorrKeyPair} constructor */
9
+ export interface SchnorrKeyPairParams {
10
+ secretKey?: Secp256k1SecretKey | KeyBytes;
11
+ publicKey?: CompressedSecp256k1PublicKey | KeyBytes;
12
+ }
13
+ export interface MultibaseKeys {
14
+ publicKeyMultibase: string;
15
+ secretKeyMultibase: string;
16
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,QAAQ,CAAC;IACjB,MAAM,CAAC,EAAE,QAAQ,CAAA;CAClB,CAAA;AAED,wDAAwD;AACxD,MAAM,WAAW,oBAAoB;IACnC,SAAS,CAAC,EAAE,kBAAkB,GAAG,QAAQ,CAAC;IAC1C,SAAS,CAAC,EAAE,4BAA4B,GAAG,QAAQ,CAAC;CACrD;AAED,MAAM,WAAW,aAAa;IAC5B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,kBAAkB,EAAE,MAAM,CAAA;CAC3B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@did-btcr2/keypair",
3
- "version": "0.5.1",
3
+ "version": "0.6.0",
4
4
  "type": "module",
5
5
  "description": "JavaScript/TypeScript implementation of secp256k1 public/private key pairs with BIP340 schnorr signatures. Used by various parts of the did-btcr2-js monorepo.",
6
6
  "main": "./dist/cjs/index.js",
@@ -62,7 +62,7 @@
62
62
  "@noble/hashes": "^1.7.1",
63
63
  "multiformats": "^13.3.2",
64
64
  "tiny-secp256k1": "^2.2.3",
65
- "@did-btcr2/common": "2.0.0"
65
+ "@did-btcr2/common": "2.2.0"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@eslint/js": "^9.20.0",
@@ -104,8 +104,7 @@
104
104
  "build:esm": "rimraf dist/esm dist/types && pnpm tsc -p tsconfig.json",
105
105
  "build:cjs": "rimraf dist/cjs && tsc -p tsconfig.cjs.json && echo '{\"type\": \"commonjs\"}' > ./dist/cjs/package.json",
106
106
  "build:tests": "pnpm tsc -p tests/tsconfig.json",
107
- "build:docs": "typedoc --options typedoc.json",
108
- "build:all": "pnpm build && pnpm build:tests && pnpm build:docs",
107
+ "build:all": "pnpm build && pnpm build:tests",
109
108
  "release": "pnpm build && pnpm pack && mv *.tgz ../../release/key-pair",
110
109
  "lint": "eslint . --max-warnings 0",
111
110
  "lint:fix": "eslint . --fix",
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './pair.js';
2
2
  export * from './secret.js';
3
- export * from './public.js';
3
+ export * from './public.js';
4
+ export * from './types.js';