@did-btcr2/keypair 0.7.1 → 0.8.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.
- package/dist/cjs/pair.js +34 -32
- package/dist/cjs/pair.js.map +1 -1
- package/dist/cjs/public.js +109 -71
- package/dist/cjs/public.js.map +1 -1
- package/dist/cjs/secret.js +39 -18
- package/dist/cjs/secret.js.map +1 -1
- package/dist/esm/pair.js +34 -32
- package/dist/esm/pair.js.map +1 -1
- package/dist/esm/public.js +109 -71
- package/dist/esm/public.js.map +1 -1
- package/dist/esm/secret.js +39 -18
- package/dist/esm/secret.js.map +1 -1
- package/dist/types/pair.d.ts +9 -20
- package/dist/types/pair.d.ts.map +1 -1
- package/dist/types/public.d.ts +46 -28
- package/dist/types/public.d.ts.map +1 -1
- package/dist/types/secret.d.ts +12 -7
- package/dist/types/secret.d.ts.map +1 -1
- package/dist/types/types.d.ts +3 -0
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/pair.ts +43 -46
- package/src/public.ts +139 -92
- package/src/secret.ts +46 -21
- package/src/types.ts +2 -0
package/dist/esm/secret.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BIP340_SECRET_KEY_MULTIBASE_PREFIX, BIP340_SECRET_KEY_MULTIBASE_PREFIX_HASH, CURVE, SecretKeyError } from '@did-btcr2/common';
|
|
2
2
|
import { sha256 } from '@noble/hashes/sha2';
|
|
3
|
-
import { getRandomValues } from 'crypto';
|
|
3
|
+
import { getRandomValues, randomBytes } from 'crypto';
|
|
4
4
|
import { base58btc } from 'multiformats/bases/base58';
|
|
5
5
|
import * as tinysecp from 'tiny-secp256k1';
|
|
6
6
|
import { SchnorrKeyPair } from './pair.js';
|
|
@@ -15,11 +15,11 @@ import { CompressedSecp256k1PublicKey } from './public.js';
|
|
|
15
15
|
*/
|
|
16
16
|
export class Secp256k1SecretKey {
|
|
17
17
|
/** @type {KeyBytes} The entropy for the secret key as a byte array */
|
|
18
|
-
|
|
18
|
+
#bytes;
|
|
19
19
|
/** @type {bigint} The entropy for the secret key as a bigint */
|
|
20
|
-
|
|
20
|
+
#seed;
|
|
21
21
|
/** @type {string} The secret key as a secretKeyMultibase */
|
|
22
|
-
|
|
22
|
+
#multibase;
|
|
23
23
|
/**
|
|
24
24
|
* Instantiates an instance of Secp256k1SecretKey.
|
|
25
25
|
* @param {Entropy} entropy bytes (Uint8Array) or secret (bigint)
|
|
@@ -34,22 +34,22 @@ export class Secp256k1SecretKey {
|
|
|
34
34
|
}
|
|
35
35
|
// If bytes and bytes are not length 32
|
|
36
36
|
if (isBytes && entropy.length === 32) {
|
|
37
|
-
this
|
|
38
|
-
this
|
|
37
|
+
this.#bytes = entropy;
|
|
38
|
+
this.#seed = Secp256k1SecretKey.toSecret(entropy);
|
|
39
39
|
}
|
|
40
40
|
// If secret and secret is not a valid bigint, throw error
|
|
41
41
|
if (isSecret && !(entropy < 1n || entropy >= CURVE.n)) {
|
|
42
|
-
this
|
|
43
|
-
this
|
|
42
|
+
this.#bytes = Secp256k1SecretKey.toBytes(entropy);
|
|
43
|
+
this.#seed = entropy;
|
|
44
44
|
}
|
|
45
|
-
if (!this
|
|
45
|
+
if (!this.#bytes || this.#bytes.length !== 32) {
|
|
46
46
|
throw new SecretKeyError('Invalid bytes: must be a valid 32-byte secret key', 'CONSTRUCTOR_ERROR');
|
|
47
47
|
}
|
|
48
|
-
if (!this
|
|
48
|
+
if (!this.#seed || (this.#seed < 1n || this.#seed >= CURVE.n)) {
|
|
49
49
|
throw new SecretKeyError('Invalid seed: must must be valid bigint', 'CONSTRUCTOR_ERROR');
|
|
50
50
|
}
|
|
51
51
|
// Set the secret key multibase
|
|
52
|
-
this
|
|
52
|
+
this.#multibase = this.encode();
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
55
|
* Get the secret key entropy as a byte array.
|
|
@@ -57,7 +57,7 @@ export class Secp256k1SecretKey {
|
|
|
57
57
|
*/
|
|
58
58
|
get bytes() {
|
|
59
59
|
// Return a copy of the secret key bytes
|
|
60
|
-
const bytes = new Uint8Array(this
|
|
60
|
+
const bytes = new Uint8Array(this.#bytes);
|
|
61
61
|
return bytes;
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
@@ -66,7 +66,7 @@ export class Secp256k1SecretKey {
|
|
|
66
66
|
*/
|
|
67
67
|
get seed() {
|
|
68
68
|
// Memoize the secret and return
|
|
69
|
-
const seed = BigInt(this
|
|
69
|
+
const seed = BigInt(this.#seed);
|
|
70
70
|
return seed;
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
@@ -82,7 +82,7 @@ export class Secp256k1SecretKey {
|
|
|
82
82
|
* @returns {string} The secret key in base58btc multibase format
|
|
83
83
|
*/
|
|
84
84
|
get multibase() {
|
|
85
|
-
const multibase = this
|
|
85
|
+
const multibase = this.#multibase;
|
|
86
86
|
return multibase;
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
@@ -91,16 +91,16 @@ export class Secp256k1SecretKey {
|
|
|
91
91
|
*/
|
|
92
92
|
encode() {
|
|
93
93
|
// Convert Uint8Array bytes to an Array
|
|
94
|
-
const secretKeyBytes = this.bytes
|
|
94
|
+
const secretKeyBytes = Array.from(this.bytes);
|
|
95
95
|
if (secretKeyBytes.length !== 32) {
|
|
96
96
|
throw new SecretKeyError('Invalid secret key: must be a valid 32-byte secret key', 'ENCODE_MULTIBASE_ERROR');
|
|
97
97
|
}
|
|
98
98
|
// Convert prefix to an array
|
|
99
|
-
const mbaseBytes =
|
|
99
|
+
const mbaseBytes = Array.from(BIP340_SECRET_KEY_MULTIBASE_PREFIX);
|
|
100
100
|
// Push the secret key bytes at the end of the prefix
|
|
101
101
|
mbaseBytes.push(...secretKeyBytes);
|
|
102
102
|
// Encode the bytes in base58btc format and return
|
|
103
|
-
return base58btc.encode(
|
|
103
|
+
return base58btc.encode(Uint8Array.from(mbaseBytes));
|
|
104
104
|
}
|
|
105
105
|
/**
|
|
106
106
|
* Checks if this secret key is equal to another.
|
|
@@ -134,7 +134,7 @@ export class Secp256k1SecretKey {
|
|
|
134
134
|
*/
|
|
135
135
|
json() {
|
|
136
136
|
return {
|
|
137
|
-
bytes: this.bytes
|
|
137
|
+
bytes: Array.from(this.bytes),
|
|
138
138
|
seed: this.seed.toString(),
|
|
139
139
|
hex: this.hex,
|
|
140
140
|
};
|
|
@@ -160,6 +160,27 @@ export class Secp256k1SecretKey {
|
|
|
160
160
|
// Return true if the computed public key equals the provided public key
|
|
161
161
|
return true;
|
|
162
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* Produce a signature over arbitrary data using schnorr or ecdsa.
|
|
165
|
+
* @param {MessageBytes} data Data to be signed.
|
|
166
|
+
* @param {CryptoOptions} opts Options for signing.
|
|
167
|
+
* @param {('ecdsa' | 'schnorr')} opts.scheme The signature scheme to use. Default is 'schnorr'.
|
|
168
|
+
* @returns {SignatureBytes} Signature byte array.
|
|
169
|
+
* @throws {SecretKeyError} if no private key is provided.
|
|
170
|
+
*/
|
|
171
|
+
sign(data, opts) {
|
|
172
|
+
// Set default options if not provided
|
|
173
|
+
opts ??= { scheme: 'schnorr' };
|
|
174
|
+
// Sign ecdsa and return
|
|
175
|
+
if (opts.scheme === 'ecdsa') {
|
|
176
|
+
return tinysecp.sign(data, this.bytes);
|
|
177
|
+
}
|
|
178
|
+
// Sign schnorr and return
|
|
179
|
+
if (opts.scheme === 'schnorr') {
|
|
180
|
+
return tinysecp.signSchnorr(data, this.bytes, randomBytes(32));
|
|
181
|
+
}
|
|
182
|
+
throw new SecretKeyError(`Invalid scheme: ${opts.scheme}.`, 'SIGN_ERROR', opts);
|
|
183
|
+
}
|
|
163
184
|
/**
|
|
164
185
|
* Decodes the multibase string to the 34-byte secret key (2 byte prefix + 32 byte key).
|
|
165
186
|
* @param {string} multibase The multibase string to decode
|
package/dist/esm/secret.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secret.js","sourceRoot":"","sources":["../../src/secret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Q;QACpB,+BAA+B;QAC/B,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QAElC,4EAA4E;QAC5E,OAAO,IAAI,kBAAkB,CAAC,WAAW,CAAC,CAAC;IAC7C,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,YAAY,CAAC,KAAe;QACxC,4EAA4E;QAC5E,OAAO,IAAI,kBAAkB,CAAC,KAAK,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAC1D,CAAC;CACF"}
|
package/dist/types/pair.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Hex, KeyBytes, SchnorrKeyPairObject } from '@did-btcr2/common';
|
|
2
|
-
import { CompressedSecp256k1PublicKey } from './public.js';
|
|
3
|
-
import { Secp256k1SecretKey } from './secret.js';
|
|
1
|
+
import { Hex, HexString, KeyBytes, SchnorrKeyPairObject } from '@did-btcr2/common';
|
|
2
|
+
import { CompressedSecp256k1PublicKey, PublicKey } from './public.js';
|
|
3
|
+
import { Secp256k1SecretKey, SecretKey } from './secret.js';
|
|
4
4
|
import { HexSchnorrKeyPair, MultibaseKeys, RawSchnorrKeyPair, SchnorrKeyPairParams } from './types.js';
|
|
5
5
|
/**
|
|
6
6
|
* General KeyPair interface used by SchnorrKeyPair class.
|
|
@@ -9,19 +9,14 @@ import { HexSchnorrKeyPair, MultibaseKeys, RawSchnorrKeyPair, SchnorrKeyPairPara
|
|
|
9
9
|
*/
|
|
10
10
|
export interface KeyPair {
|
|
11
11
|
/**
|
|
12
|
-
* @type {
|
|
12
|
+
* @type {PublicKey} The public key associated with the SchnorrKeyPair (required).
|
|
13
13
|
*/
|
|
14
|
-
readonly publicKey:
|
|
14
|
+
readonly publicKey: PublicKey;
|
|
15
15
|
/**
|
|
16
|
-
* @type {
|
|
16
|
+
* @type {SecretKey} The secret key associated with the SchnorrKeyPair (optional).
|
|
17
17
|
* @throws {KeyPairError} If the secret key is not available.
|
|
18
18
|
*/
|
|
19
|
-
readonly secretKey?:
|
|
20
|
-
/**
|
|
21
|
-
* JSON representation of the SchnorrKeyPair object.
|
|
22
|
-
* @returns {SchnorrKeyPairObject} The SchnorrKeyPair as a JSON object.
|
|
23
|
-
*/
|
|
24
|
-
json(): SchnorrKeyPairObject;
|
|
19
|
+
readonly secretKey?: SecretKey;
|
|
25
20
|
}
|
|
26
21
|
/**
|
|
27
22
|
* Encapsulates a CompressedSecp256k1PublicKey and a Secp256k1SecretKey object as a single SchnorrKeyPair object.
|
|
@@ -29,13 +24,7 @@ export interface KeyPair {
|
|
|
29
24
|
* @type {SchnorrKeyPair}
|
|
30
25
|
*/
|
|
31
26
|
export declare class SchnorrKeyPair implements KeyPair {
|
|
32
|
-
|
|
33
|
-
private _secretKey?;
|
|
34
|
-
private _publicKey;
|
|
35
|
-
/** @type {string} The public key in multibase format */
|
|
36
|
-
private _publicKeyMultibase;
|
|
37
|
-
/** @type {string} The secret key in multibase format */
|
|
38
|
-
private _secretKeyMultibase;
|
|
27
|
+
#private;
|
|
39
28
|
/**
|
|
40
29
|
* Creates an instance of Keys. Must provide a at least a secret key.
|
|
41
30
|
* Can optionally provide both a secret and public key, but must be a valid pair.
|
|
@@ -94,7 +83,7 @@ export declare class SchnorrKeyPair implements KeyPair {
|
|
|
94
83
|
* @param {Secp256k1SecretKey | KeyBytes} data The secret key bytes
|
|
95
84
|
* @returns {SchnorrKeyPair} A new SchnorrKeyPair object
|
|
96
85
|
*/
|
|
97
|
-
static
|
|
86
|
+
static fromSecret(data: KeyBytes | HexString): SchnorrKeyPair;
|
|
98
87
|
/**
|
|
99
88
|
* Static method creates a new Keys (Secp256k1SecretKey/CompressedSecp256k1PublicKey) from bigint entropy.
|
|
100
89
|
* @param {bigint} entropy The entropy in bigint form
|
package/dist/types/pair.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pair.d.ts","sourceRoot":"","sources":["../../src/pair.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,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S,GAAG,cAAc;IAsBpE;;;;OAIG;WACW,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc;IAM1D;;;;OAIG;WACW,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,GAAG;IAI5C;;;;;OAKG;WACW,MAAM,CAAC,EAAE,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO;IAqB1E;;;OAGG;WACW,QAAQ,IAAI,cAAc;CAazC"}
|
package/dist/types/public.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import { Hex, KeyBytes, MultibaseObject, PublicKeyObject } from '@did-btcr2/common';
|
|
1
|
+
import { Bytes, Hex, KeyBytes, MultibaseObject, PublicKeyObject } from '@did-btcr2/common';
|
|
2
2
|
import { Secp256k1SecretKey } from './secret.js';
|
|
3
|
+
import { CryptoOptions } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Point Interface representing an (x, y) coordinate on the secp256k1 curve.
|
|
6
|
+
* @interface Point
|
|
7
|
+
* @type {Point}
|
|
8
|
+
*/
|
|
3
9
|
export interface Point {
|
|
4
10
|
x: KeyBytes;
|
|
5
11
|
y: KeyBytes;
|
|
@@ -90,16 +96,13 @@ export interface PublicKey {
|
|
|
90
96
|
* @type {CompressedSecp256k1PublicKey}
|
|
91
97
|
*/
|
|
92
98
|
export declare class CompressedSecp256k1PublicKey implements PublicKey {
|
|
93
|
-
|
|
94
|
-
private readonly _bytes;
|
|
95
|
-
/** @type {MultibaseObject} The public key as a MultibaseObject */
|
|
96
|
-
private _multibase;
|
|
99
|
+
#private;
|
|
97
100
|
/**
|
|
98
101
|
* Creates a CompressedSecp256k1PublicKey instance.
|
|
99
|
-
* @param {
|
|
102
|
+
* @param {Hex} initialBytes The public key byte array.
|
|
100
103
|
* @throws {PublicKeyError} if the byte length is not 32 (x-only) or 33 (compressed)
|
|
101
104
|
*/
|
|
102
|
-
constructor(
|
|
105
|
+
constructor(initialBytes: Hex);
|
|
103
106
|
/**
|
|
104
107
|
* Get the compressed public key.
|
|
105
108
|
* @returns {KeyBytes} The 33-byte compressed public key (0x02 or 0x03, x).
|
|
@@ -142,9 +145,9 @@ export declare class CompressedSecp256k1PublicKey implements PublicKey {
|
|
|
142
145
|
get multibase(): MultibaseObject;
|
|
143
146
|
/**
|
|
144
147
|
* Returns the raw public key as a hex string.
|
|
145
|
-
* @returns {
|
|
148
|
+
* @returns {string} The public key as a hex string.
|
|
146
149
|
*/
|
|
147
|
-
get hex():
|
|
150
|
+
get hex(): string;
|
|
148
151
|
/**
|
|
149
152
|
* Return the public key point.
|
|
150
153
|
* @returns {Point} The public key point.
|
|
@@ -155,13 +158,6 @@ export declare class CompressedSecp256k1PublicKey implements PublicKey {
|
|
|
155
158
|
* @returns {KeyBytes} The BIP-340 (x-only) representation of the public key.
|
|
156
159
|
*/
|
|
157
160
|
bip340(): KeyBytes;
|
|
158
|
-
/**
|
|
159
|
-
* Returns the point of the public key.
|
|
160
|
-
* @param {Hex} pk The public key in hex (Uint8Array or string) format.
|
|
161
|
-
* @returns {Point} The point of the public key.
|
|
162
|
-
* @throws {PublicKeyError} If the public key is not a valid hex string or byte array.
|
|
163
|
-
*/
|
|
164
|
-
static point(pk: Hex): Point;
|
|
165
161
|
/**
|
|
166
162
|
* Decodes the multibase string to the 35-byte corresponding public key (2 byte prefix + 32 byte public key).
|
|
167
163
|
* @returns {KeyBytes} The decoded public key: prefix and public key bytes
|
|
@@ -172,6 +168,15 @@ export declare class CompressedSecp256k1PublicKey implements PublicKey {
|
|
|
172
168
|
* @returns {string} The public key encoded in base-58-btc multibase format.
|
|
173
169
|
*/
|
|
174
170
|
encode(): string;
|
|
171
|
+
/**
|
|
172
|
+
* Verify a signature using schnorr or ecdsa.
|
|
173
|
+
* @param {SignatureBytes} signature Signature for verification.
|
|
174
|
+
* @param {string} data Data for verification.
|
|
175
|
+
* @param {CryptoOptions} opts Options for signing.
|
|
176
|
+
* @param {('ecdsa' | 'schnorr')} opts.scheme The signature scheme to use. Default is 'schnorr'.
|
|
177
|
+
* @returns {boolean} If the signature is valid against the public key.
|
|
178
|
+
*/
|
|
179
|
+
verify(signature: Bytes, data: Bytes, opts?: CryptoOptions): boolean;
|
|
175
180
|
/**
|
|
176
181
|
* Compares this public key to another public key.
|
|
177
182
|
* @param {CompressedSecp256k1PublicKey} other The other public key to compare
|
|
@@ -183,18 +188,6 @@ export declare class CompressedSecp256k1PublicKey implements PublicKey {
|
|
|
183
188
|
* @returns {PublicKeyObject} The CompressedSecp256k1PublicKey as a JSON object.
|
|
184
189
|
*/
|
|
185
190
|
json(): PublicKeyObject;
|
|
186
|
-
/**
|
|
187
|
-
* Creates a CompressedSecp256k1PublicKey object from a JSON representation.
|
|
188
|
-
* @param {PublicKeyObject} json The JSON object to initialize the CompressedSecp256k1PublicKey.
|
|
189
|
-
* @returns {CompressedSecp256k1PublicKey} The initialized CompressedSecp256k1PublicKey object.
|
|
190
|
-
*/
|
|
191
|
-
static fromJSON(json: PublicKeyObject): CompressedSecp256k1PublicKey;
|
|
192
|
-
/**
|
|
193
|
-
* Computes the deterministic public key for a given secret key.
|
|
194
|
-
* @param {Secp256k1SecretKey | KeyBytes} sk The Secp256k1SecretKey object or the secret key bytes
|
|
195
|
-
* @returns {CompressedSecp256k1PublicKey} A new CompressedSecp256k1PublicKey object
|
|
196
|
-
*/
|
|
197
|
-
static fromSecretKey(sk: Secp256k1SecretKey | KeyBytes): CompressedSecp256k1PublicKey;
|
|
198
191
|
/**
|
|
199
192
|
* Computes modular exponentiation: (base^exp) % mod.
|
|
200
193
|
* Used for computing modular square roots.
|
|
@@ -218,4 +211,29 @@ export declare class CompressedSecp256k1PublicKey implements PublicKey {
|
|
|
218
211
|
* @returns {Uint8Array} 65-byte uncompressed public key (starts with `0x04`)
|
|
219
212
|
*/
|
|
220
213
|
liftX(): Uint8Array;
|
|
214
|
+
/**
|
|
215
|
+
* Static method to validate a public key.
|
|
216
|
+
* @param {Hex} pk The public key in hex (Uint8Array or string) format.
|
|
217
|
+
* @returns {boolean} True if the public key is valid, false otherwise.
|
|
218
|
+
*/
|
|
219
|
+
static isValid(pk: Hex): boolean;
|
|
220
|
+
/**
|
|
221
|
+
* Returns the point of the public key.
|
|
222
|
+
* @param {Hex} pk The public key in hex (Uint8Array or string) format.
|
|
223
|
+
* @returns {Point} The point of the public key.
|
|
224
|
+
* @throws {PublicKeyError} If the public key is not a valid hex string or byte array.
|
|
225
|
+
*/
|
|
226
|
+
static point(pk: Hex): Point;
|
|
227
|
+
/**
|
|
228
|
+
* Creates a CompressedSecp256k1PublicKey object from a JSON representation.
|
|
229
|
+
* @param {PublicKeyObject} json The JSON object to initialize the CompressedSecp256k1PublicKey.
|
|
230
|
+
* @returns {CompressedSecp256k1PublicKey} The initialized CompressedSecp256k1PublicKey object.
|
|
231
|
+
*/
|
|
232
|
+
static fromJSON(json: PublicKeyObject): CompressedSecp256k1PublicKey;
|
|
233
|
+
/**
|
|
234
|
+
* Computes the deterministic public key for a given secret key.
|
|
235
|
+
* @param {Secp256k1SecretKey | KeyBytes} sk The Secp256k1SecretKey object or the secret key bytes
|
|
236
|
+
* @returns {CompressedSecp256k1PublicKey} A new CompressedSecp256k1PublicKey object
|
|
237
|
+
*/
|
|
238
|
+
static fromSecretKey(sk: Secp256k1SecretKey | KeyBytes): CompressedSecp256k1PublicKey;
|
|
221
239
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/public.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/public.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,EAEL,GAAG,EACH,QAAQ,EACR,eAAe,EAEf,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C;;;;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y, Hex, KeyBytes, SecretKeyObject, SignatureBytes } from '@did-btcr2/common';
|
|
2
2
|
import { SchnorrKeyPair } from './pair.js';
|
|
3
3
|
import { CompressedSecp256k1PublicKey } from './public.js';
|
|
4
|
+
import { CryptoOptions } from './types.js';
|
|
4
5
|
/**
|
|
5
6
|
* General SecretKey interface for the Secp256k1SecretKey class.
|
|
6
7
|
* @interface SecretKey
|
|
@@ -54,12 +55,7 @@ export interface SecretKey {
|
|
|
54
55
|
* @implements {SecretKey}
|
|
55
56
|
*/
|
|
56
57
|
export declare class Secp256k1SecretKey implements SecretKey {
|
|
57
|
-
|
|
58
|
-
private _bytes?;
|
|
59
|
-
/** @type {bigint} The entropy for the secret key as a bigint */
|
|
60
|
-
private _seed?;
|
|
61
|
-
/** @type {string} The secret key as a secretKeyMultibase */
|
|
62
|
-
private _multibase;
|
|
58
|
+
#private;
|
|
63
59
|
/**
|
|
64
60
|
* Instantiates an instance of Secp256k1SecretKey.
|
|
65
61
|
* @param {Entropy} entropy bytes (Uint8Array) or secret (bigint)
|
|
@@ -117,6 +113,15 @@ export declare class Secp256k1SecretKey implements SecretKey {
|
|
|
117
113
|
* @returns {boolean} True if the public key is valid, false otherwise
|
|
118
114
|
*/
|
|
119
115
|
hasValidPublicKey(): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Produce a signature over arbitrary data using schnorr or ecdsa.
|
|
118
|
+
* @param {MessageBytes} data Data to be signed.
|
|
119
|
+
* @param {CryptoOptions} opts Options for signing.
|
|
120
|
+
* @param {('ecdsa' | 'schnorr')} opts.scheme The signature scheme to use. Default is 'schnorr'.
|
|
121
|
+
* @returns {SignatureBytes} Signature byte array.
|
|
122
|
+
* @throws {SecretKeyError} if no private key is provided.
|
|
123
|
+
*/
|
|
124
|
+
sign(data: Bytes, opts?: CryptoOptions): SignatureBytes;
|
|
120
125
|
/**
|
|
121
126
|
* Decodes the multibase string to the 34-byte secret key (2 byte prefix + 32 byte key).
|
|
122
127
|
* @param {string} multibase The multibase string to decode
|
|
@@ -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,
|
|
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,EACf,cAAc,EACf,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB;;;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,kBAAkB,GAAG,OAAO,CAAC;IAE3C;;;OAGG;IACH,gBAAgB,IAAI,4BAA4B,CAAC;IAEjD;;;OAGG;IACH,OAAO,IAAI,OAAO,CAAC;IAEnB;;;OAGG;IACH,IAAI,IAAI,eAAe,CAAC;CACzB;AAED;;;;;;;GAOG;AACH,qBAAa,kBAAmB,YAAW,SAAS;;IAUlD;;;;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,MAAM;IAoBvB;;;;OAIG;IACI,MAAM,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO;IAKjD;;;OAGG;IACI,gBAAgB,IAAI,4BAA4B;IAuBvD;;;OAGG;IACI,IAAI,IAAI,eAAe;IAQ9B;;;OAGG;IACI,OAAO,IAAI,OAAO;IAIzB;;;OAGG;IACI,iBAAiB,IAAI,OAAO;IAanC;;;;;;;OAOG;IACI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,cAAc;IAiB9D;;;;OAIG;WACW,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,KAAK;IA8B9C;;;;OAIG;WACW,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,kBAAkB;IAIjE;;;;;OAKG;WACW,SAAS,CAAC,KAAK,EAAE,QAAQ,GAAG,cAAc;IAWxD;;;;OAIG;WACW,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM;IAI/C;;;;OAIG;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;IAQhC;;;OAGG;WACW,QAAQ,IAAI,kBAAkB;IAQ5C;;;;OAIG;WACW,YAAY,CAAC,KAAK,EAAE,QAAQ,GAAG,4BAA4B;CAI1E"}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Hex, KeyBytes } from '@did-btcr2/common';
|
|
2
2
|
import { CompressedSecp256k1PublicKey } from './public.js';
|
|
3
3
|
import { Secp256k1SecretKey } from './secret.js';
|
|
4
|
+
export type CryptoOptions = {
|
|
5
|
+
scheme: 'ecdsa' | 'schnorr';
|
|
6
|
+
};
|
|
4
7
|
export type RawSchnorrKeyPair = {
|
|
5
8
|
public: KeyBytes;
|
|
6
9
|
secret?: KeyBytes;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,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,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,GAAG,CAAC;IACZ,MAAM,CAAC,EAAE,GAAG,CAAA;CACb,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"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,MAAM,aAAa,GAAG;IAAE,MAAM,EAAE,OAAO,GAAG,SAAS,CAAA;CAAE,CAAA;AAE3D,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,QAAQ,CAAC;IACjB,MAAM,CAAC,EAAE,QAAQ,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,GAAG,CAAC;IACZ,MAAM,CAAC,EAAE,GAAG,CAAA;CACb,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.
|
|
3
|
+
"version": "0.8.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": "
|
|
65
|
+
"@did-btcr2/common": "3.1.0"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@eslint/js": "^9.20.0",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"@types/chai-as-promised": "^8.0.1",
|
|
71
71
|
"@types/eslint": "^9.6.1",
|
|
72
72
|
"@types/mocha": "^10.0.10",
|
|
73
|
-
"@types/node": "^22.
|
|
73
|
+
"@types/node": "^22.18.4",
|
|
74
74
|
"@typescript-eslint/eslint-plugin": "^8.24.1",
|
|
75
75
|
"@typescript-eslint/parser": "^8.24.1",
|
|
76
76
|
"c8": "^10.1.3",
|