@did-btcr2/keypair 0.5.1 → 0.7.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/README.md +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/pair.js +76 -65
- package/dist/cjs/pair.js.map +1 -1
- package/dist/cjs/public.js +64 -47
- package/dist/cjs/public.js.map +1 -1
- package/dist/cjs/secret.js +35 -33
- package/dist/cjs/secret.js.map +1 -1
- package/dist/cjs/types.js +2 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/pair.js +76 -65
- package/dist/esm/pair.js.map +1 -1
- package/dist/esm/public.js +64 -47
- package/dist/esm/public.js.map +1 -1
- package/dist/esm/secret.js +35 -33
- package/dist/esm/secret.js.map +1 -1
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/pair.d.ts +42 -51
- package/dist/types/pair.d.ts.map +1 -1
- package/dist/types/public.d.ts +68 -44
- package/dist/types/public.d.ts.map +1 -1
- package/dist/types/secret.d.ts +35 -36
- package/dist/types/secret.d.ts.map +1 -1
- package/dist/types/types.d.ts +16 -0
- package/dist/types/types.d.ts.map +1 -0
- package/package.json +3 -4
- package/src/index.ts +2 -1
- package/src/pair.ts +89 -93
- package/src/public.ts +115 -72
- package/src/secret.ts +51 -49
- package/src/types.ts +19 -0
package/dist/cjs/secret.js
CHANGED
|
@@ -4,15 +4,16 @@ import { getRandomValues } 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';
|
|
7
|
+
import { CompressedSecp256k1PublicKey } from './public.js';
|
|
7
8
|
/**
|
|
8
9
|
* Encapsulates a secp256k1 secret key
|
|
9
10
|
* Provides get methods for different formats (raw, secret, point).
|
|
10
11
|
* Provides helpers methods for comparison, serialization and publicKey generation.
|
|
11
|
-
* @class
|
|
12
|
-
* @type {
|
|
13
|
-
*
|
|
12
|
+
* @class Secp256k1SecretKey
|
|
13
|
+
* @type {Secp256k1SecretKey}
|
|
14
|
+
* @implements {SecretKey}
|
|
14
15
|
*/
|
|
15
|
-
export class
|
|
16
|
+
export class Secp256k1SecretKey {
|
|
16
17
|
/** @type {KeyBytes} The entropy for the secret key as a byte array */
|
|
17
18
|
_bytes;
|
|
18
19
|
/** @type {bigint} The entropy for the secret key as a bigint */
|
|
@@ -20,7 +21,7 @@ export class SecretKey {
|
|
|
20
21
|
/** @type {string} The secret key as a secretKeyMultibase */
|
|
21
22
|
_multibase;
|
|
22
23
|
/**
|
|
23
|
-
* Instantiates an instance of
|
|
24
|
+
* Instantiates an instance of Secp256k1SecretKey.
|
|
24
25
|
* @param {Entropy} entropy bytes (Uint8Array) or secret (bigint)
|
|
25
26
|
* @throws {SecretKeyError} If entropy is not provided, not a valid 32-byte secret key or not a valid bigint seed
|
|
26
27
|
*/
|
|
@@ -34,11 +35,11 @@ export class SecretKey {
|
|
|
34
35
|
// If bytes and bytes are not length 32
|
|
35
36
|
if (isBytes && entropy.length === 32) {
|
|
36
37
|
this._bytes = entropy;
|
|
37
|
-
this._seed =
|
|
38
|
+
this._seed = Secp256k1SecretKey.toSecret(entropy);
|
|
38
39
|
}
|
|
39
40
|
// If secret and secret is not a valid bigint, throw error
|
|
40
41
|
if (isSecret && !(entropy < 1n || entropy >= CURVE.n)) {
|
|
41
|
-
this._bytes =
|
|
42
|
+
this._bytes = Secp256k1SecretKey.toBytes(entropy);
|
|
42
43
|
this._seed = entropy;
|
|
43
44
|
}
|
|
44
45
|
if (!this._bytes || this._bytes.length !== 32) {
|
|
@@ -103,7 +104,7 @@ export class SecretKey {
|
|
|
103
104
|
}
|
|
104
105
|
/**
|
|
105
106
|
* Checks if this secret key is equal to another.
|
|
106
|
-
* @param {
|
|
107
|
+
* @param {Secp256k1SecretKey} other The other secret key
|
|
107
108
|
* @returns {boolean} True if the private keys are equal, false otherwise
|
|
108
109
|
*/
|
|
109
110
|
equals(other) {
|
|
@@ -112,7 +113,7 @@ export class SecretKey {
|
|
|
112
113
|
}
|
|
113
114
|
/**
|
|
114
115
|
* Computes the public key from the secret key bytes.
|
|
115
|
-
* @returns {
|
|
116
|
+
* @returns {CompressedSecp256k1PublicKey} The computed public key
|
|
116
117
|
*/
|
|
117
118
|
computePublicKey() {
|
|
118
119
|
// Derive the public key from the secret key
|
|
@@ -125,7 +126,7 @@ export class SecretKey {
|
|
|
125
126
|
if (publicKeyBytes.length !== 33) {
|
|
126
127
|
throw new SecretKeyError('Invalid compute: public key not compressed format', 'COMPUTE_PUBLIC_KEY_ERROR');
|
|
127
128
|
}
|
|
128
|
-
return publicKeyBytes;
|
|
129
|
+
return new CompressedSecp256k1PublicKey(publicKeyBytes);
|
|
129
130
|
}
|
|
130
131
|
/**
|
|
131
132
|
* Converts the secret key to a JSON object.
|
|
@@ -147,15 +148,16 @@ export class SecretKey {
|
|
|
147
148
|
}
|
|
148
149
|
/**
|
|
149
150
|
* Checks if the public key is a valid secp256k1 point.
|
|
150
|
-
* @param {PublicKey} pk The public key to validate
|
|
151
151
|
* @returns {boolean} True if the public key is valid, false otherwise
|
|
152
152
|
*/
|
|
153
|
-
|
|
153
|
+
hasValidPublicKey() {
|
|
154
|
+
// Compute the public key from the secret key and compress it
|
|
155
|
+
const pk = this.computePublicKey();
|
|
154
156
|
// If the public key is not valid, return false
|
|
155
157
|
if (!tinysecp.isPoint(pk.compressed)) {
|
|
156
158
|
return false;
|
|
157
159
|
}
|
|
158
|
-
//
|
|
160
|
+
// Return true if the computed public key equals the provided public key
|
|
159
161
|
return true;
|
|
160
162
|
}
|
|
161
163
|
/**
|
|
@@ -182,22 +184,22 @@ export class SecretKey {
|
|
|
182
184
|
return decoded;
|
|
183
185
|
}
|
|
184
186
|
/**
|
|
185
|
-
* Creates a
|
|
187
|
+
* Creates a Secp256k1SecretKey object from a JSON object.
|
|
186
188
|
* @param {SecretKeyObject} json The JSON object containing the secret key bytes
|
|
187
|
-
* @returns {
|
|
189
|
+
* @returns {Secp256k1SecretKey} A new Secp256k1SecretKey object
|
|
188
190
|
*/
|
|
189
191
|
static fromJSON(json) {
|
|
190
|
-
return new
|
|
192
|
+
return new Secp256k1SecretKey(new Uint8Array(json.bytes));
|
|
191
193
|
}
|
|
192
194
|
/**
|
|
193
|
-
* Converts a
|
|
194
|
-
* @param {KeyBytes} bytes
|
|
195
|
+
* Converts a Secp256k1SecretKey or KeyBytes to a SchnorrKeyPair.
|
|
196
|
+
* @param {KeyBytes} bytes The secret key bytes
|
|
195
197
|
* @returns {SchnorrKeyPair} The SchnorrKeyPair object containing the public and private keys
|
|
196
198
|
* @throws {SecretKeyError} If the secret key is not valid
|
|
197
199
|
*/
|
|
198
200
|
static toKeyPair(bytes) {
|
|
199
|
-
// Create a new
|
|
200
|
-
const secretKey = new
|
|
201
|
+
// Create a new Secp256k1SecretKey from the bytes
|
|
202
|
+
const secretKey = new Secp256k1SecretKey(bytes);
|
|
201
203
|
// Compute the public key from the secret key
|
|
202
204
|
const publicKey = secretKey.computePublicKey();
|
|
203
205
|
// Create a new Pair from the public key and secret key
|
|
@@ -226,17 +228,17 @@ export class SecretKey {
|
|
|
226
228
|
return new Uint8Array(bytes);
|
|
227
229
|
}
|
|
228
230
|
/**
|
|
229
|
-
* Creates a new
|
|
230
|
-
* @param {bigint}
|
|
231
|
-
* @returns {
|
|
231
|
+
* Creates a new Secp256k1SecretKey object from a bigint secret.
|
|
232
|
+
* @param {bigint} entropy The secret bigint
|
|
233
|
+
* @returns {Secp256k1SecretKey} A new Secp256k1SecretKey object
|
|
232
234
|
*/
|
|
233
|
-
static
|
|
235
|
+
static fromEntropy(entropy) {
|
|
234
236
|
// Convert the secret bigint to a hex string
|
|
235
|
-
const hexsecret =
|
|
237
|
+
const hexsecret = entropy.toString(16).padStart(64, '0');
|
|
236
238
|
// Convert the hex string to a Uint8Array
|
|
237
239
|
const privateKeyBytes = new Uint8Array(hexsecret.match(/.{2}/g).map(byte => parseInt(byte, 16)));
|
|
238
|
-
// Return a new
|
|
239
|
-
return new
|
|
240
|
+
// Return a new Secp256k1SecretKey object
|
|
241
|
+
return new Secp256k1SecretKey(privateKeyBytes);
|
|
240
242
|
}
|
|
241
243
|
/**
|
|
242
244
|
* Generates random secret key bytes.
|
|
@@ -249,23 +251,23 @@ export class SecretKey {
|
|
|
249
251
|
return getRandomValues(byteArray);
|
|
250
252
|
}
|
|
251
253
|
/**
|
|
252
|
-
* Creates a new
|
|
253
|
-
* @returns {
|
|
254
|
+
* Creates a new Secp256k1SecretKey from random secret key bytes.
|
|
255
|
+
* @returns {Secp256k1SecretKey} A new Secp256k1SecretKey object
|
|
254
256
|
*/
|
|
255
257
|
static generate() {
|
|
256
258
|
// Generate empty 32-byte array
|
|
257
259
|
const randomBytes = this.random();
|
|
258
260
|
// Use the getRandomValues function to fill the byteArray with random values
|
|
259
|
-
return new
|
|
261
|
+
return new Secp256k1SecretKey(randomBytes);
|
|
260
262
|
}
|
|
261
263
|
/**
|
|
262
264
|
* Generates a public key from the given secret key bytes.
|
|
263
265
|
* @param {KeyBytes} bytes The secret key bytes
|
|
264
|
-
* @returns {
|
|
266
|
+
* @returns {CompressedSecp256k1PublicKey} The computed public key bytes
|
|
265
267
|
*/
|
|
266
268
|
static getPublicKey(bytes) {
|
|
267
|
-
// Create a new
|
|
268
|
-
return new
|
|
269
|
+
// Create a new Secp256k1SecretKey from the bytes and compute the public key
|
|
270
|
+
return new Secp256k1SecretKey(bytes).computePublicKey();
|
|
269
271
|
}
|
|
270
272
|
}
|
|
271
273
|
//# sourceMappingURL=secret.js.map
|
package/dist/cjs/secret.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secret.js","sourceRoot":"","sources":["../../src/secret.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"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
package/dist/esm/index.js
CHANGED
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
package/dist/esm/pair.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { KeyPairError } from '@did-btcr2/common';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { CompressedSecp256k1PublicKey } from './public.js';
|
|
3
|
+
import { Secp256k1SecretKey } from './secret.js';
|
|
4
4
|
/**
|
|
5
|
-
* Encapsulates a
|
|
5
|
+
* Encapsulates a CompressedSecp256k1PublicKey and a Secp256k1SecretKey object as a single SchnorrKeyPair object.
|
|
6
6
|
* @class SchnorrKeyPair
|
|
7
7
|
* @type {SchnorrKeyPair}
|
|
8
8
|
*/
|
|
9
9
|
export class SchnorrKeyPair {
|
|
10
|
-
/** @type {
|
|
10
|
+
/** @type {Secp256k1SecretKey} The secret key object */
|
|
11
11
|
_secretKey;
|
|
12
|
-
/** @type {
|
|
12
|
+
/** @type {CompressedSecp256k1PublicKey} The public key object */ ;
|
|
13
13
|
_publicKey;
|
|
14
14
|
/** @type {string} The public key in multibase format */
|
|
15
15
|
_publicKeyMultibase;
|
|
@@ -17,37 +17,41 @@ export class SchnorrKeyPair {
|
|
|
17
17
|
_secretKeyMultibase;
|
|
18
18
|
/**
|
|
19
19
|
* Creates an instance of Keys. Must provide a at least a secret key.
|
|
20
|
-
* Can optionally provide both a
|
|
21
|
-
* @param {
|
|
20
|
+
* Can optionally provide both a secret and public key, but must be a valid pair.
|
|
21
|
+
* @param {SchnorrKeyPairParams} params The parameters to initialize the Keys object.
|
|
22
|
+
* @param {CompressedSecp256k1PublicKey | KeyBytes} params.publicKey The public key object or bytes
|
|
23
|
+
* @param {Secp256k1SecretKey | KeyBytes} [params.secret] The secret key object or bytes
|
|
24
|
+
* @throws {KeyPairError} If neither a public key or secret key is provided.
|
|
25
|
+
* @throws {KeyPairError} If the public key is not a valid pair with the secret key.
|
|
22
26
|
*/
|
|
23
|
-
constructor(
|
|
27
|
+
constructor(params = {}) {
|
|
24
28
|
// If no secret key or public key, throw an error
|
|
25
|
-
if (!publicKey && !secretKey) {
|
|
29
|
+
if (!params.publicKey && !params.secretKey) {
|
|
26
30
|
throw new KeyPairError('Argument missing: must at least provide a publicKey', 'CONSTRUCTOR_ERROR');
|
|
27
31
|
}
|
|
28
|
-
// Set the
|
|
29
|
-
if (secretKey instanceof Uint8Array) {
|
|
30
|
-
this._secretKey = new
|
|
32
|
+
// Set the secretKey
|
|
33
|
+
if (params.secretKey instanceof Uint8Array) {
|
|
34
|
+
this._secretKey = new Secp256k1SecretKey(params.secretKey);
|
|
31
35
|
}
|
|
32
|
-
else if (secretKey instanceof
|
|
33
|
-
this._secretKey = secretKey;
|
|
36
|
+
else if (params.secretKey instanceof Secp256k1SecretKey) {
|
|
37
|
+
this._secretKey = params.secretKey;
|
|
34
38
|
}
|
|
35
|
-
// Set the
|
|
36
|
-
if (publicKey instanceof
|
|
37
|
-
this._publicKey = publicKey;
|
|
39
|
+
// Set the publicKey
|
|
40
|
+
if (params.publicKey instanceof CompressedSecp256k1PublicKey) {
|
|
41
|
+
this._publicKey = params.publicKey;
|
|
38
42
|
}
|
|
39
|
-
else if (publicKey instanceof Uint8Array) {
|
|
40
|
-
this._publicKey = new
|
|
43
|
+
else if (params.publicKey instanceof Uint8Array) {
|
|
44
|
+
this._publicKey = new CompressedSecp256k1PublicKey(params.publicKey);
|
|
41
45
|
}
|
|
42
46
|
else {
|
|
43
|
-
this._publicKey =
|
|
47
|
+
this._publicKey = this._secretKey.computePublicKey();
|
|
44
48
|
}
|
|
45
|
-
this._publicKeyMultibase = this._publicKey.multibase.
|
|
49
|
+
this._publicKeyMultibase = this._publicKey.multibase.encoded;
|
|
46
50
|
this._secretKeyMultibase = this._secretKey ? this._secretKey.multibase : '';
|
|
47
51
|
}
|
|
48
52
|
/**
|
|
49
|
-
* Get the
|
|
50
|
-
* @returns {
|
|
53
|
+
* Get the Secp256k1SecretKey.
|
|
54
|
+
* @returns {Secp256k1SecretKey} The Secp256k1SecretKey object
|
|
51
55
|
* @throws {KeyPairError} If the secret key is not available
|
|
52
56
|
*/
|
|
53
57
|
get secretKey() {
|
|
@@ -60,34 +64,39 @@ export class SchnorrKeyPair {
|
|
|
60
64
|
throw new KeyPairError('Secret key is not valid', 'SECRET_KEY_ERROR');
|
|
61
65
|
}
|
|
62
66
|
// Return a copy of the secret key
|
|
63
|
-
const
|
|
64
|
-
return
|
|
67
|
+
const secret = this._secretKey;
|
|
68
|
+
return secret;
|
|
65
69
|
}
|
|
66
70
|
/**
|
|
67
|
-
* Set the
|
|
68
|
-
* @param {
|
|
71
|
+
* Set the CompressedSecp256k1PublicKey.
|
|
72
|
+
* @param {CompressedSecp256k1PublicKey} publicKey The CompressedSecp256k1PublicKey object
|
|
69
73
|
* @throws {KeyPairError} If the public key is not a valid pair with the secret key.
|
|
70
74
|
*/
|
|
71
75
|
set publicKey(publicKey) {
|
|
72
76
|
// If the public key is not a valid pair with the secret key, throw an error
|
|
73
|
-
if (this.secretKey
|
|
74
|
-
|
|
77
|
+
if (this.secretKey) {
|
|
78
|
+
if (!this.secretKey.hasValidPublicKey()) {
|
|
79
|
+
throw new KeyPairError('Secret key is not valid', 'SECRET_KEY_ERROR');
|
|
80
|
+
}
|
|
81
|
+
const cPk = this.secretKey.computePublicKey();
|
|
82
|
+
if (!publicKey.equals(cPk))
|
|
83
|
+
throw new KeyPairError('Public key is not a valid pair with the secret key', 'PUBLIC_KEY_ERROR');
|
|
75
84
|
}
|
|
76
85
|
this._publicKey = publicKey;
|
|
77
|
-
this._publicKeyMultibase = publicKey.multibase.
|
|
86
|
+
this._publicKeyMultibase = publicKey.multibase.encoded;
|
|
78
87
|
this._secretKeyMultibase = this._secretKey ? this._secretKey.multibase : '';
|
|
79
88
|
}
|
|
80
89
|
/**
|
|
81
|
-
* Get the
|
|
82
|
-
* @returns {
|
|
90
|
+
* Get the CompressedSecp256k1PublicKey.
|
|
91
|
+
* @returns {CompressedSecp256k1PublicKey} The CompressedSecp256k1PublicKey object
|
|
83
92
|
*/
|
|
84
93
|
get publicKey() {
|
|
85
94
|
const publicKey = this._publicKey;
|
|
86
95
|
return publicKey;
|
|
87
96
|
}
|
|
88
97
|
/**
|
|
89
|
-
* Get the
|
|
90
|
-
* @returns {
|
|
98
|
+
* Get the raw bytes of each key in the SchnorrKeyPair.
|
|
99
|
+
* @returns {RawSchnorrKeyPair} JSON object with the SchnorrKeyPair raw bytes.
|
|
91
100
|
*/
|
|
92
101
|
get raw() {
|
|
93
102
|
return {
|
|
@@ -97,7 +106,7 @@ export class SchnorrKeyPair {
|
|
|
97
106
|
}
|
|
98
107
|
/**
|
|
99
108
|
* Get the Keys in multibase format.
|
|
100
|
-
* @returns {MultibaseKeys} The
|
|
109
|
+
* @returns {MultibaseKeys} The Secp256k1SecretKey in multibase format
|
|
101
110
|
*/
|
|
102
111
|
get multibase() {
|
|
103
112
|
return {
|
|
@@ -121,42 +130,44 @@ export class SchnorrKeyPair {
|
|
|
121
130
|
* @returns {SchnorrKeyPair} The initialized Keys object.
|
|
122
131
|
*/
|
|
123
132
|
static fromJSON(keys) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
133
|
+
return new SchnorrKeyPair({
|
|
134
|
+
secretKey: Secp256k1SecretKey.fromJSON(keys.secretKey),
|
|
135
|
+
publicKey: CompressedSecp256k1PublicKey.fromJSON(keys.publicKey)
|
|
136
|
+
});
|
|
127
137
|
}
|
|
128
138
|
/**
|
|
129
|
-
* Static method creates a new SchnorrKeyPair from a
|
|
130
|
-
* @param {
|
|
139
|
+
* Static method creates a new SchnorrKeyPair from a Secp256k1SecretKey object or secret key bytes.
|
|
140
|
+
* @param {Secp256k1SecretKey | KeyBytes} data The secret key bytes
|
|
131
141
|
* @returns {SchnorrKeyPair} A new SchnorrKeyPair object
|
|
132
142
|
*/
|
|
133
143
|
static fromPrivateKey(data) {
|
|
134
|
-
// If the secret key is a
|
|
135
|
-
const bytes = data instanceof
|
|
144
|
+
// If the secret key is a Secp256k1SecretKey object, get the raw bytes else use the bytes
|
|
145
|
+
const bytes = data instanceof Secp256k1SecretKey ? data.bytes : data;
|
|
136
146
|
// Throw error if the secret key is not 32 bytes
|
|
137
147
|
if (bytes.length !== 32) {
|
|
138
148
|
throw new KeyPairError('Invalid arg: must be 32 byte secret key', 'FROM_PRIVATE_KEY_ERROR');
|
|
139
149
|
}
|
|
140
|
-
// If pk Uint8Array, construct
|
|
141
|
-
const
|
|
142
|
-
// Compute the public key from the secret key
|
|
143
|
-
const publicKey = secretKey.computePublicKey();
|
|
150
|
+
// If pk Uint8Array, construct Secp256k1SecretKey object else use the object
|
|
151
|
+
const secret = data instanceof Uint8Array ? new Secp256k1SecretKey(data) : data;
|
|
144
152
|
// Return a new Keys object
|
|
145
|
-
return new SchnorrKeyPair({
|
|
153
|
+
return new SchnorrKeyPair({
|
|
154
|
+
secretKey: data instanceof Uint8Array ? new Secp256k1SecretKey(data) : data,
|
|
155
|
+
publicKey: secret.computePublicKey()
|
|
156
|
+
});
|
|
146
157
|
}
|
|
147
158
|
/**
|
|
148
|
-
* Static method creates a new Keys (
|
|
149
|
-
* @param {bigint}
|
|
150
|
-
* @returns {
|
|
159
|
+
* Static method creates a new Keys (Secp256k1SecretKey/CompressedSecp256k1PublicKey) from bigint entropy.
|
|
160
|
+
* @param {bigint} entropy The entropy in bigint form
|
|
161
|
+
* @returns {SchnorrKeyPair} A new SchnorrKeyPair object
|
|
151
162
|
*/
|
|
152
|
-
static
|
|
153
|
-
const secretKey =
|
|
163
|
+
static fromEntropy(entropy) {
|
|
164
|
+
const secretKey = Secp256k1SecretKey.fromEntropy(entropy);
|
|
154
165
|
const publicKey = secretKey.computePublicKey();
|
|
155
166
|
return new SchnorrKeyPair({ secretKey, publicKey });
|
|
156
167
|
}
|
|
157
168
|
/**
|
|
158
169
|
* Converts key bytes to a hex string.
|
|
159
|
-
* @param {KeyBytes} keyBytes The key bytes (
|
|
170
|
+
* @param {KeyBytes} keyBytes The key bytes (secret or public).
|
|
160
171
|
* @returns {Hex} The key bytes as a hex string.
|
|
161
172
|
*/
|
|
162
173
|
static toHex(keyBytes) {
|
|
@@ -164,21 +175,21 @@ export class SchnorrKeyPair {
|
|
|
164
175
|
}
|
|
165
176
|
/**
|
|
166
177
|
* Compares two Keys objects for equality.
|
|
167
|
-
* @param {SchnorrKeyPair}
|
|
168
|
-
* @param {SchnorrKeyPair}
|
|
178
|
+
* @param {SchnorrKeyPair} kp The main keys.
|
|
179
|
+
* @param {SchnorrKeyPair} otherKp The other keys to compare.
|
|
169
180
|
* @returns {boolean} True if the public key and secret key are equal, false otherwise.
|
|
170
181
|
*/
|
|
171
|
-
static equals(
|
|
182
|
+
static equals(kp, otherKp) {
|
|
172
183
|
// Deconstruct the public keys from the key pairs
|
|
173
|
-
const pk =
|
|
174
|
-
const otherPk =
|
|
184
|
+
const pk = kp.publicKey;
|
|
185
|
+
const otherPk = otherKp.publicKey;
|
|
175
186
|
// If publicKeys present, use to compare as hex strings.
|
|
176
187
|
if (pk && otherPk) {
|
|
177
188
|
return pk.hex === otherPk.hex;
|
|
178
189
|
}
|
|
179
|
-
// Deconstruct the
|
|
180
|
-
const sk =
|
|
181
|
-
const otherSk =
|
|
190
|
+
// Deconstruct the secret keys from the key pairs
|
|
191
|
+
const sk = kp.secretKey;
|
|
192
|
+
const otherSk = otherKp.secretKey;
|
|
182
193
|
if (sk && otherSk) {
|
|
183
194
|
// Get the public key hex strings for both key pair publicKeys
|
|
184
195
|
return sk.hex === otherSk.hex;
|
|
@@ -187,13 +198,13 @@ export class SchnorrKeyPair {
|
|
|
187
198
|
}
|
|
188
199
|
/**
|
|
189
200
|
* Static method to generate a new random SchnorrKeyPair instance.
|
|
190
|
-
* @returns {SchnorrKeyPair} A new
|
|
201
|
+
* @returns {SchnorrKeyPair} A new Secp256k1SecretKey object.
|
|
191
202
|
*/
|
|
192
203
|
static generate() {
|
|
193
204
|
// Generate random secret key bytes
|
|
194
|
-
const
|
|
195
|
-
// Construct a new
|
|
196
|
-
const secretKey = new
|
|
205
|
+
const sk = Secp256k1SecretKey.random();
|
|
206
|
+
// Construct a new Secp256k1SecretKey object
|
|
207
|
+
const secretKey = new Secp256k1SecretKey(sk);
|
|
197
208
|
// Compute the public key from the secret key
|
|
198
209
|
const publicKey = secretKey.computePublicKey();
|
|
199
210
|
// Return a new Keys object
|
package/dist/esm/pair.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pair.js","sourceRoot":"","sources":["../../src/pair.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EAEb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"pair.js","sourceRoot":"","sources":["../../src/pair.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EAEb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AA2BjD;;;;GAIG;AACH,MAAM,OAAO,cAAc;IACzB,uDAAuD;IAC/C,UAAU,CAAsB;IAExC,iEAAiE,CAAA,CAAC;IAC1D,UAAU,CAA+B;IAEjD,wDAAwD;IAChD,mBAAmB,CAAS;IAEpC,wDAAwD;IAChD,mBAAmB,CAAS;IAEpC;;;;;;;;OAQG;IACH,YAAY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