@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/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
# Keypair
|
|
2
2
|
|
|
3
3
|
TypeScript implementation of secp256k1 public/private key pairs with [BIP340](https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki) schnorr signatures.
|
|
4
|
-
Designed for use by [@did-
|
|
4
|
+
Designed for use by [@did-btcr2/cryptosuite](../cryptosuite/README.md) and [@did-btcr2/method](../method/README.md).
|
package/dist/cjs/index.js
CHANGED
package/dist/cjs/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/cjs/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/cjs/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,SAA+B,EAAE;QAC3C,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A4C;QAC5C,MAAM,SAAS,GAAG,IAAI,kBAAkB,CAAC,EAAE,CAAC,CAAC;QAE7C,6CAA6C;QAC7C,MAAM,SAAS,GAAG,SAAS,CAAC,gBAAgB,EAAE,CAAC;QAE/C,2BAA2B;QAC3B,OAAO,IAAI,cAAc,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC;IACtD,CAAC;CACF"}
|
package/dist/cjs/public.js
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import { BIP340_PUBLIC_KEY_MULTIBASE_PREFIX, BIP340_PUBLIC_KEY_MULTIBASE_PREFIX_HASH, CURVE, PublicKeyError } from '@did-btcr2/common';
|
|
2
2
|
import { sha256 } from '@noble/hashes/sha2';
|
|
3
3
|
import { base58btc } from 'multiformats/bases/base58';
|
|
4
|
-
import
|
|
4
|
+
import * as tinysecp from 'tiny-secp256k1';
|
|
5
|
+
import { Secp256k1SecretKey } from './secret.js';
|
|
5
6
|
/**
|
|
6
7
|
* Encapsulates a secp256k1 public key compliant to BIP-340 BIP schnorr signature scheme.
|
|
7
8
|
* Provides get methods for different formats (compressed, x-only, multibase).
|
|
8
9
|
* Provides helpers methods for comparison and serialization.
|
|
9
|
-
* @class
|
|
10
|
-
* @type {
|
|
10
|
+
* @class CompressedSecp256k1PublicKey
|
|
11
|
+
* @type {CompressedSecp256k1PublicKey}
|
|
11
12
|
*/
|
|
12
|
-
export class
|
|
13
|
+
export class CompressedSecp256k1PublicKey {
|
|
13
14
|
/** @type {KeyBytes} The public key bytes */
|
|
14
15
|
_bytes;
|
|
15
16
|
/** @type {MultibaseObject} The public key as a MultibaseObject */
|
|
16
17
|
_multibase = {
|
|
17
18
|
prefix: BIP340_PUBLIC_KEY_MULTIBASE_PREFIX,
|
|
18
19
|
key: [],
|
|
19
|
-
|
|
20
|
+
encoded: ''
|
|
20
21
|
};
|
|
21
22
|
/**
|
|
22
|
-
* Creates a
|
|
23
|
+
* Creates a CompressedSecp256k1PublicKey instance.
|
|
23
24
|
* @param {KeyBytes} bytes The public key byte array.
|
|
24
25
|
* @throws {PublicKeyError} if the byte length is not 32 (x-only) or 33 (compressed)
|
|
25
26
|
*/
|
|
@@ -28,10 +29,14 @@ export class PublicKey {
|
|
|
28
29
|
if (bytes.length !== 33) {
|
|
29
30
|
throw new PublicKeyError('Invalid argument: byte length must be 33 (compressed)', 'CONSTRUCTOR_ERROR', { bytes });
|
|
30
31
|
}
|
|
32
|
+
// Validate the point is on curve and in compressed form
|
|
33
|
+
if (!tinysecp.isPoint(bytes)) {
|
|
34
|
+
throw new PublicKeyError('Invalid argument: bytes are not a valid secp256k1 compressed point', 'CONSTRUCTOR_ERROR', { bytes });
|
|
35
|
+
}
|
|
31
36
|
// Set the bytes
|
|
32
37
|
this._bytes = bytes;
|
|
33
38
|
// Set multibase
|
|
34
|
-
this._multibase.
|
|
39
|
+
this._multibase.encoded = this.encode();
|
|
35
40
|
this._multibase.key = [...this._multibase.prefix, ...this.compressed];
|
|
36
41
|
}
|
|
37
42
|
/**
|
|
@@ -52,13 +57,30 @@ export class PublicKey {
|
|
|
52
57
|
return uncompressed;
|
|
53
58
|
}
|
|
54
59
|
/**
|
|
55
|
-
*
|
|
56
|
-
|
|
60
|
+
* X-only (32-byte) view of the public key per BIP-340.
|
|
61
|
+
*/
|
|
62
|
+
get xOnly() {
|
|
63
|
+
return this._bytes.slice(1);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Parity of the SEC compressed public key.
|
|
67
|
+
* @returns {0x02 | 0x03} The parity byte (0x02 if even, 0x03 if odd).
|
|
68
|
+
* @throws {PublicKeyError} If the parity byte is not 0x02 or 0x03.
|
|
57
69
|
*/
|
|
58
70
|
get parity() {
|
|
59
|
-
const parity = this.
|
|
71
|
+
const parity = this._bytes[0];
|
|
72
|
+
if (![0x02, 0x03].includes(parity)) {
|
|
73
|
+
throw new PublicKeyError('Invalid state: parity byte must be 2 or 3', 'PARITY_ERROR', { parity });
|
|
74
|
+
}
|
|
60
75
|
return parity;
|
|
61
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Whether the SEC compressed public key has even Y.
|
|
79
|
+
* @returns {boolean} True if the public key has even Y.
|
|
80
|
+
*/
|
|
81
|
+
get isEven() {
|
|
82
|
+
return this._bytes[0] === 0x02;
|
|
83
|
+
}
|
|
62
84
|
/**
|
|
63
85
|
* Get the x-coordinate of the public key.
|
|
64
86
|
* @returns {Uint8Array} The 32-byte x-coordinate of the public key.
|
|
@@ -101,6 +123,13 @@ export class PublicKey {
|
|
|
101
123
|
y: this.y
|
|
102
124
|
};
|
|
103
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Returns the BIP-340 (x-only) representation of this key.
|
|
128
|
+
* @returns {KeyBytes} The BIP-340 (x-only) representation of the public key.
|
|
129
|
+
*/
|
|
130
|
+
bip340() {
|
|
131
|
+
return this.xOnly;
|
|
132
|
+
}
|
|
104
133
|
/**
|
|
105
134
|
* Returns the point of the public key.
|
|
106
135
|
* @param {Hex} pk The public key in hex (Uint8Array or string) format.
|
|
@@ -108,14 +137,14 @@ export class PublicKey {
|
|
|
108
137
|
* @throws {PublicKeyError} If the public key is not a valid hex string or byte array.
|
|
109
138
|
*/
|
|
110
139
|
static point(pk) {
|
|
111
|
-
// If the public key is a hex string, convert it to a
|
|
140
|
+
// If the public key is a hex string, convert it to a CompressedSecp256k1PublicKey object and return the point
|
|
112
141
|
if (typeof pk === 'string' && /^[0-9a-fA-F]+$/.test(pk)) {
|
|
113
|
-
const publicKey = new
|
|
142
|
+
const publicKey = new CompressedSecp256k1PublicKey(Buffer.fromHex(pk));
|
|
114
143
|
return publicKey.point;
|
|
115
144
|
}
|
|
116
|
-
// If the public key is a byte array or ArrayBuffer, convert it to a
|
|
145
|
+
// If the public key is a byte array or ArrayBuffer, convert it to a CompressedSecp256k1PublicKey object and return the point
|
|
117
146
|
if (pk instanceof Uint8Array || ArrayBuffer.isView(pk)) {
|
|
118
|
-
const publicKey = new
|
|
147
|
+
const publicKey = new CompressedSecp256k1PublicKey(pk);
|
|
119
148
|
return publicKey.point;
|
|
120
149
|
}
|
|
121
150
|
// If the public key is neither a hex string nor a byte array, throw an error
|
|
@@ -127,7 +156,7 @@ export class PublicKey {
|
|
|
127
156
|
*/
|
|
128
157
|
decode() {
|
|
129
158
|
// Decode the public key multibase string
|
|
130
|
-
const decoded = base58btc.decode(this.multibase.
|
|
159
|
+
const decoded = base58btc.decode(this.multibase.encoded);
|
|
131
160
|
// If the public key bytes are not 35 bytes, throw an error
|
|
132
161
|
if (decoded.length !== 35) {
|
|
133
162
|
throw new PublicKeyError('Invalid argument: must be 35 byte publicKeyMultibase', 'DECODE_MULTIBASE_ERROR');
|
|
@@ -163,15 +192,15 @@ export class PublicKey {
|
|
|
163
192
|
}
|
|
164
193
|
/**
|
|
165
194
|
* Compares this public key to another public key.
|
|
166
|
-
* @param {
|
|
195
|
+
* @param {CompressedSecp256k1PublicKey} other The other public key to compare
|
|
167
196
|
* @returns {boolean} True if the public keys are equal, false otherwise.
|
|
168
197
|
*/
|
|
169
198
|
equals(other) {
|
|
170
199
|
return this.hex === other.hex;
|
|
171
200
|
}
|
|
172
201
|
/**
|
|
173
|
-
* JSON representation of a
|
|
174
|
-
* @returns {PublicKeyObject} The
|
|
202
|
+
* JSON representation of a CompressedSecp256k1PublicKey object.
|
|
203
|
+
* @returns {PublicKeyObject} The CompressedSecp256k1PublicKey as a JSON object.
|
|
175
204
|
*/
|
|
176
205
|
json() {
|
|
177
206
|
return {
|
|
@@ -185,30 +214,32 @@ export class PublicKey {
|
|
|
185
214
|
};
|
|
186
215
|
}
|
|
187
216
|
/**
|
|
188
|
-
* Creates a
|
|
189
|
-
* @param {PublicKeyObject} json The JSON object to initialize the
|
|
190
|
-
* @returns {
|
|
217
|
+
* Creates a CompressedSecp256k1PublicKey object from a JSON representation.
|
|
218
|
+
* @param {PublicKeyObject} json The JSON object to initialize the CompressedSecp256k1PublicKey.
|
|
219
|
+
* @returns {CompressedSecp256k1PublicKey} The initialized CompressedSecp256k1PublicKey object.
|
|
191
220
|
*/
|
|
192
221
|
static fromJSON(json) {
|
|
193
222
|
json.x.unshift(json.parity);
|
|
194
|
-
return new
|
|
223
|
+
return new CompressedSecp256k1PublicKey(json.x.toUint8Array());
|
|
195
224
|
}
|
|
196
225
|
/**
|
|
197
|
-
* Computes the deterministic public key for a given
|
|
198
|
-
* @param {
|
|
199
|
-
* @returns {
|
|
226
|
+
* Computes the deterministic public key for a given secret key.
|
|
227
|
+
* @param {Secp256k1SecretKey | KeyBytes} sk The Secp256k1SecretKey object or the secret key bytes
|
|
228
|
+
* @returns {CompressedSecp256k1PublicKey} A new CompressedSecp256k1PublicKey object
|
|
200
229
|
*/
|
|
201
230
|
static fromSecretKey(sk) {
|
|
202
|
-
// If the
|
|
203
|
-
const bytes = sk instanceof
|
|
204
|
-
// Throw error if the
|
|
231
|
+
// If the secret key is a Secp256k1SecretKey object, get the raw bytes else use the bytes
|
|
232
|
+
const bytes = sk instanceof Secp256k1SecretKey ? sk.bytes : sk;
|
|
233
|
+
// Throw error if the secret key is not 32 bytes
|
|
205
234
|
if (bytes.length !== 32) {
|
|
206
|
-
throw new PublicKeyError('Invalid arg: must be 32 byte
|
|
235
|
+
throw new PublicKeyError('Invalid arg: must be 32 byte secret key', 'FROM_SECRET_KEY_ERROR');
|
|
207
236
|
}
|
|
208
|
-
// Compute the public key from the
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
237
|
+
// Compute the public key from the secret key
|
|
238
|
+
const secret = sk instanceof Secp256k1SecretKey
|
|
239
|
+
? sk
|
|
240
|
+
: new Secp256k1SecretKey(sk);
|
|
241
|
+
// Return a new CompressedSecp256k1PublicKey object
|
|
242
|
+
return secret.computePublicKey();
|
|
212
243
|
}
|
|
213
244
|
/**
|
|
214
245
|
* Computes modular exponentiation: (base^exp) % mod.
|
|
@@ -265,19 +296,5 @@ export class PublicKey {
|
|
|
265
296
|
return new Uint8Array(Buffer.concat([Buffer.from([0x04]), Buffer.from(this.x), yBytes]));
|
|
266
297
|
}
|
|
267
298
|
;
|
|
268
|
-
/**
|
|
269
|
-
* Static version of liftX method.
|
|
270
|
-
* @param {KeyBytes} x The 32-byte x-coordinate to lift.
|
|
271
|
-
* @returns {Uint8Array} The 65-byte uncompressed public key (0x04, x, y).
|
|
272
|
-
*/
|
|
273
|
-
static xOnly(x) {
|
|
274
|
-
// Ensure x-coordinate is 32 bytes
|
|
275
|
-
if (x.length !== 32) {
|
|
276
|
-
throw new PublicKeyError('Invalid argument: x-coordinate length must be 32 bytes', 'LIFT_X_ERROR');
|
|
277
|
-
}
|
|
278
|
-
// Create a PublicKey instance and lift the x-coordinate
|
|
279
|
-
const publicKey = new PublicKey(x);
|
|
280
|
-
return publicKey.x;
|
|
281
|
-
}
|
|
282
299
|
}
|
|
283
300
|
//# sourceMappingURL=public.js.map
|
package/dist/cjs/public.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.js","sourceRoot":"","sources":["../../src/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kCAAkC,EAClC,uCAAuC,EACvC,KAAK,EAKL,cAAc,EAEf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"public.js","sourceRoot":"","sources":["../../src/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kCAAkC,EAClC,uCAAuC,EACvC,KAAK,EAKL,cAAc,EAEf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AA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