@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.
- 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 +70 -64
- package/dist/cjs/pair.js.map +1 -1
- package/dist/cjs/public.js +58 -48
- package/dist/cjs/public.js.map +1 -1
- package/dist/cjs/secret.js +34 -31
- 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 +70 -64
- package/dist/esm/pair.js.map +1 -1
- package/dist/esm/public.js +58 -48
- package/dist/esm/public.js.map +1 -1
- package/dist/esm/secret.js +34 -31
- 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 +67 -44
- package/dist/types/public.d.ts.map +1 -1
- package/dist/types/secret.d.ts +31 -31
- 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 +83 -92
- package/src/public.ts +105 -72
- package/src/secret.ts +47 -44
- 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 = new
|
|
47
|
+
this._publicKey = new CompressedSecp256k1PublicKey(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,34 @@ 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 && !this.secretKey.
|
|
77
|
+
if (this.secretKey && !this.secretKey.hasValidPublicKey(publicKey)) {
|
|
74
78
|
throw new KeyPairError('Public key is not a valid pair with the secret key', 'PUBLIC_KEY_ERROR');
|
|
75
79
|
}
|
|
76
80
|
this._publicKey = publicKey;
|
|
77
|
-
this._publicKeyMultibase = publicKey.multibase.
|
|
81
|
+
this._publicKeyMultibase = publicKey.multibase.encoded;
|
|
78
82
|
this._secretKeyMultibase = this._secretKey ? this._secretKey.multibase : '';
|
|
79
83
|
}
|
|
80
84
|
/**
|
|
81
|
-
* Get the
|
|
82
|
-
* @returns {
|
|
85
|
+
* Get the CompressedSecp256k1PublicKey.
|
|
86
|
+
* @returns {CompressedSecp256k1PublicKey} The CompressedSecp256k1PublicKey object
|
|
83
87
|
*/
|
|
84
88
|
get publicKey() {
|
|
85
89
|
const publicKey = this._publicKey;
|
|
86
90
|
return publicKey;
|
|
87
91
|
}
|
|
88
92
|
/**
|
|
89
|
-
* Get the
|
|
90
|
-
* @returns {
|
|
93
|
+
* Get the raw bytes of each key in the SchnorrKeyPair.
|
|
94
|
+
* @returns {RawSchnorrKeyPair} JSON object with the SchnorrKeyPair raw bytes.
|
|
91
95
|
*/
|
|
92
96
|
get raw() {
|
|
93
97
|
return {
|
|
@@ -97,7 +101,7 @@ export class SchnorrKeyPair {
|
|
|
97
101
|
}
|
|
98
102
|
/**
|
|
99
103
|
* Get the Keys in multibase format.
|
|
100
|
-
* @returns {MultibaseKeys} The
|
|
104
|
+
* @returns {MultibaseKeys} The Secp256k1SecretKey in multibase format
|
|
101
105
|
*/
|
|
102
106
|
get multibase() {
|
|
103
107
|
return {
|
|
@@ -121,42 +125,44 @@ export class SchnorrKeyPair {
|
|
|
121
125
|
* @returns {SchnorrKeyPair} The initialized Keys object.
|
|
122
126
|
*/
|
|
123
127
|
static fromJSON(keys) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
128
|
+
return new SchnorrKeyPair({
|
|
129
|
+
secretKey: Secp256k1SecretKey.fromJSON(keys.secretKey),
|
|
130
|
+
publicKey: CompressedSecp256k1PublicKey.fromJSON(keys.publicKey)
|
|
131
|
+
});
|
|
127
132
|
}
|
|
128
133
|
/**
|
|
129
|
-
* Static method creates a new SchnorrKeyPair from a
|
|
130
|
-
* @param {
|
|
134
|
+
* Static method creates a new SchnorrKeyPair from a Secp256k1SecretKey object or secret key bytes.
|
|
135
|
+
* @param {Secp256k1SecretKey | KeyBytes} data The secret key bytes
|
|
131
136
|
* @returns {SchnorrKeyPair} A new SchnorrKeyPair object
|
|
132
137
|
*/
|
|
133
138
|
static fromPrivateKey(data) {
|
|
134
|
-
// If the secret key is a
|
|
135
|
-
const bytes = data instanceof
|
|
139
|
+
// If the secret key is a Secp256k1SecretKey object, get the raw bytes else use the bytes
|
|
140
|
+
const bytes = data instanceof Secp256k1SecretKey ? data.bytes : data;
|
|
136
141
|
// Throw error if the secret key is not 32 bytes
|
|
137
142
|
if (bytes.length !== 32) {
|
|
138
143
|
throw new KeyPairError('Invalid arg: must be 32 byte secret key', 'FROM_PRIVATE_KEY_ERROR');
|
|
139
144
|
}
|
|
140
|
-
// If pk Uint8Array, construct
|
|
141
|
-
const
|
|
142
|
-
// Compute the public key from the secret key
|
|
143
|
-
const publicKey = secretKey.computePublicKey();
|
|
145
|
+
// If pk Uint8Array, construct Secp256k1SecretKey object else use the object
|
|
146
|
+
const secret = data instanceof Uint8Array ? new Secp256k1SecretKey(data) : data;
|
|
144
147
|
// Return a new Keys object
|
|
145
|
-
return new SchnorrKeyPair({
|
|
148
|
+
return new SchnorrKeyPair({
|
|
149
|
+
secretKey: data instanceof Uint8Array ? new Secp256k1SecretKey(data) : data,
|
|
150
|
+
publicKey: secret.computePublicKey()
|
|
151
|
+
});
|
|
146
152
|
}
|
|
147
153
|
/**
|
|
148
|
-
* Static method creates a new Keys (
|
|
149
|
-
* @param {bigint}
|
|
150
|
-
* @returns {
|
|
154
|
+
* Static method creates a new Keys (Secp256k1SecretKey/CompressedSecp256k1PublicKey) from bigint entropy.
|
|
155
|
+
* @param {bigint} entropy The entropy in bigint form
|
|
156
|
+
* @returns {SchnorrKeyPair} A new SchnorrKeyPair object
|
|
151
157
|
*/
|
|
152
|
-
static
|
|
153
|
-
const secretKey =
|
|
158
|
+
static fromEntropy(entropy) {
|
|
159
|
+
const secretKey = Secp256k1SecretKey.fromEntropy(entropy);
|
|
154
160
|
const publicKey = secretKey.computePublicKey();
|
|
155
161
|
return new SchnorrKeyPair({ secretKey, publicKey });
|
|
156
162
|
}
|
|
157
163
|
/**
|
|
158
164
|
* Converts key bytes to a hex string.
|
|
159
|
-
* @param {KeyBytes} keyBytes The key bytes (
|
|
165
|
+
* @param {KeyBytes} keyBytes The key bytes (secret or public).
|
|
160
166
|
* @returns {Hex} The key bytes as a hex string.
|
|
161
167
|
*/
|
|
162
168
|
static toHex(keyBytes) {
|
|
@@ -164,21 +170,21 @@ export class SchnorrKeyPair {
|
|
|
164
170
|
}
|
|
165
171
|
/**
|
|
166
172
|
* Compares two Keys objects for equality.
|
|
167
|
-
* @param {SchnorrKeyPair}
|
|
168
|
-
* @param {SchnorrKeyPair}
|
|
173
|
+
* @param {SchnorrKeyPair} kp The main keys.
|
|
174
|
+
* @param {SchnorrKeyPair} otherKp The other keys to compare.
|
|
169
175
|
* @returns {boolean} True if the public key and secret key are equal, false otherwise.
|
|
170
176
|
*/
|
|
171
|
-
static equals(
|
|
177
|
+
static equals(kp, otherKp) {
|
|
172
178
|
// Deconstruct the public keys from the key pairs
|
|
173
|
-
const pk =
|
|
174
|
-
const otherPk =
|
|
179
|
+
const pk = kp.publicKey;
|
|
180
|
+
const otherPk = otherKp.publicKey;
|
|
175
181
|
// If publicKeys present, use to compare as hex strings.
|
|
176
182
|
if (pk && otherPk) {
|
|
177
183
|
return pk.hex === otherPk.hex;
|
|
178
184
|
}
|
|
179
|
-
// Deconstruct the
|
|
180
|
-
const sk =
|
|
181
|
-
const otherSk =
|
|
185
|
+
// Deconstruct the secret keys from the key pairs
|
|
186
|
+
const sk = kp.secretKey;
|
|
187
|
+
const otherSk = otherKp.secretKey;
|
|
182
188
|
if (sk && otherSk) {
|
|
183
189
|
// Get the public key hex strings for both key pair publicKeys
|
|
184
190
|
return sk.hex === otherSk.hex;
|
|
@@ -187,13 +193,13 @@ export class SchnorrKeyPair {
|
|
|
187
193
|
}
|
|
188
194
|
/**
|
|
189
195
|
* Static method to generate a new random SchnorrKeyPair instance.
|
|
190
|
-
* @returns {SchnorrKeyPair} A new
|
|
196
|
+
* @returns {SchnorrKeyPair} A new Secp256k1SecretKey object.
|
|
191
197
|
*/
|
|
192
198
|
static generate() {
|
|
193
199
|
// Generate random secret key bytes
|
|
194
|
-
const
|
|
195
|
-
// Construct a new
|
|
196
|
-
const secretKey = new
|
|
200
|
+
const sk = Secp256k1SecretKey.random();
|
|
201
|
+
// Construct a new Secp256k1SecretKey object
|
|
202
|
+
const secretKey = new Secp256k1SecretKey(sk);
|
|
197
203
|
// Compute the public key from the secret key
|
|
198
204
|
const publicKey = secretKey.computePublicKey();
|
|
199
205
|
// 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,iDAAiD;QACjD,IAAI,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;YAC3C,MAAM,IAAI,YAAY,CAAC,qDAAqD,E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
|
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,12 +57,24 @@ 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 {0 | 1} The parity of the public key. 0 = even (0x02), 1 = odd (0x03).
|
|
57
68
|
*/
|
|
58
69
|
get parity() {
|
|
59
|
-
|
|
60
|
-
|
|
70
|
+
return (this._bytes[0] & 1);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Whether the SEC compressed public key has even Y.
|
|
74
|
+
* @returns {boolean} True if the public key has even Y.
|
|
75
|
+
*/
|
|
76
|
+
get isEven() {
|
|
77
|
+
return this._bytes[0] === 0x02;
|
|
61
78
|
}
|
|
62
79
|
/**
|
|
63
80
|
* Get the x-coordinate of the public key.
|
|
@@ -101,6 +118,13 @@ export class PublicKey {
|
|
|
101
118
|
y: this.y
|
|
102
119
|
};
|
|
103
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* Returns the BIP-340 (x-only) representation of this key.
|
|
123
|
+
* @returns {KeyBytes} The BIP-340 (x-only) representation of the public key.
|
|
124
|
+
*/
|
|
125
|
+
bip340() {
|
|
126
|
+
return this.xOnly;
|
|
127
|
+
}
|
|
104
128
|
/**
|
|
105
129
|
* Returns the point of the public key.
|
|
106
130
|
* @param {Hex} pk The public key in hex (Uint8Array or string) format.
|
|
@@ -108,14 +132,14 @@ export class PublicKey {
|
|
|
108
132
|
* @throws {PublicKeyError} If the public key is not a valid hex string or byte array.
|
|
109
133
|
*/
|
|
110
134
|
static point(pk) {
|
|
111
|
-
// If the public key is a hex string, convert it to a
|
|
135
|
+
// If the public key is a hex string, convert it to a CompressedSecp256k1PublicKey object and return the point
|
|
112
136
|
if (typeof pk === 'string' && /^[0-9a-fA-F]+$/.test(pk)) {
|
|
113
|
-
const publicKey = new
|
|
137
|
+
const publicKey = new CompressedSecp256k1PublicKey(Buffer.fromHex(pk));
|
|
114
138
|
return publicKey.point;
|
|
115
139
|
}
|
|
116
|
-
// If the public key is a byte array or ArrayBuffer, convert it to a
|
|
140
|
+
// If the public key is a byte array or ArrayBuffer, convert it to a CompressedSecp256k1PublicKey object and return the point
|
|
117
141
|
if (pk instanceof Uint8Array || ArrayBuffer.isView(pk)) {
|
|
118
|
-
const publicKey = new
|
|
142
|
+
const publicKey = new CompressedSecp256k1PublicKey(pk);
|
|
119
143
|
return publicKey.point;
|
|
120
144
|
}
|
|
121
145
|
// If the public key is neither a hex string nor a byte array, throw an error
|
|
@@ -127,7 +151,7 @@ export class PublicKey {
|
|
|
127
151
|
*/
|
|
128
152
|
decode() {
|
|
129
153
|
// Decode the public key multibase string
|
|
130
|
-
const decoded = base58btc.decode(this.multibase.
|
|
154
|
+
const decoded = base58btc.decode(this.multibase.encoded);
|
|
131
155
|
// If the public key bytes are not 35 bytes, throw an error
|
|
132
156
|
if (decoded.length !== 35) {
|
|
133
157
|
throw new PublicKeyError('Invalid argument: must be 35 byte publicKeyMultibase', 'DECODE_MULTIBASE_ERROR');
|
|
@@ -163,15 +187,15 @@ export class PublicKey {
|
|
|
163
187
|
}
|
|
164
188
|
/**
|
|
165
189
|
* Compares this public key to another public key.
|
|
166
|
-
* @param {
|
|
190
|
+
* @param {CompressedSecp256k1PublicKey} other The other public key to compare
|
|
167
191
|
* @returns {boolean} True if the public keys are equal, false otherwise.
|
|
168
192
|
*/
|
|
169
193
|
equals(other) {
|
|
170
194
|
return this.hex === other.hex;
|
|
171
195
|
}
|
|
172
196
|
/**
|
|
173
|
-
* JSON representation of a
|
|
174
|
-
* @returns {PublicKeyObject} The
|
|
197
|
+
* JSON representation of a CompressedSecp256k1PublicKey object.
|
|
198
|
+
* @returns {PublicKeyObject} The CompressedSecp256k1PublicKey as a JSON object.
|
|
175
199
|
*/
|
|
176
200
|
json() {
|
|
177
201
|
return {
|
|
@@ -185,30 +209,30 @@ export class PublicKey {
|
|
|
185
209
|
};
|
|
186
210
|
}
|
|
187
211
|
/**
|
|
188
|
-
* Creates a
|
|
189
|
-
* @param {PublicKeyObject} json The JSON object to initialize the
|
|
190
|
-
* @returns {
|
|
212
|
+
* Creates a CompressedSecp256k1PublicKey object from a JSON representation.
|
|
213
|
+
* @param {PublicKeyObject} json The JSON object to initialize the CompressedSecp256k1PublicKey.
|
|
214
|
+
* @returns {CompressedSecp256k1PublicKey} The initialized CompressedSecp256k1PublicKey object.
|
|
191
215
|
*/
|
|
192
216
|
static fromJSON(json) {
|
|
193
217
|
json.x.unshift(json.parity);
|
|
194
|
-
return new
|
|
218
|
+
return new CompressedSecp256k1PublicKey(json.x.toUint8Array());
|
|
195
219
|
}
|
|
196
220
|
/**
|
|
197
|
-
* Computes the deterministic public key for a given
|
|
198
|
-
* @param {
|
|
199
|
-
* @returns {
|
|
221
|
+
* Computes the deterministic public key for a given secret key.
|
|
222
|
+
* @param {Secp256k1SecretKey | KeyBytes} sk The Secp256k1SecretKey object or the secret key bytes
|
|
223
|
+
* @returns {CompressedSecp256k1PublicKey} A new CompressedSecp256k1PublicKey object
|
|
200
224
|
*/
|
|
201
225
|
static fromSecretKey(sk) {
|
|
202
|
-
// If the
|
|
203
|
-
const bytes = sk instanceof
|
|
204
|
-
// Throw error if the
|
|
226
|
+
// If the secret key is a Secp256k1SecretKey object, get the raw bytes else use the bytes
|
|
227
|
+
const bytes = sk instanceof Secp256k1SecretKey ? sk.bytes : sk;
|
|
228
|
+
// Throw error if the secret key is not 32 bytes
|
|
205
229
|
if (bytes.length !== 32) {
|
|
206
|
-
throw new PublicKeyError('Invalid arg: must be 32 byte
|
|
230
|
+
throw new PublicKeyError('Invalid arg: must be 32 byte secret key', 'FROM_SECRET_KEY_ERROR');
|
|
207
231
|
}
|
|
208
|
-
// Compute the public key from the
|
|
209
|
-
const
|
|
210
|
-
// Return a new
|
|
211
|
-
return new
|
|
232
|
+
// Compute the public key from the secret key
|
|
233
|
+
const secret = sk instanceof Secp256k1SecretKey ? sk : new Secp256k1SecretKey(sk);
|
|
234
|
+
// Return a new CompressedSecp256k1PublicKey object
|
|
235
|
+
return new CompressedSecp256k1PublicKey(secret.computePublicKey());
|
|
212
236
|
}
|
|
213
237
|
/**
|
|
214
238
|
* Computes modular exponentiation: (base^exp) % mod.
|
|
@@ -265,19 +289,5 @@ export class PublicKey {
|
|
|
265
289
|
return new Uint8Array(Buffer.concat([Buffer.from([0x04]), Buffer.from(this.x), yBytes]));
|
|
266
290
|
}
|
|
267
291
|
;
|
|
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
292
|
}
|
|
283
293
|
//# 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;AAmGjD;;;;;;GAMG;AACH,MAAM,OAAO,4BAA4B;IACvC,4CAA4C;IAC3B,MAAM,CAAW;IAElC,kEAAkE;IAC1D,UAAU,GAAoB;QACpC,MAAM,EAAI,kCAAkC;QAC5C,GAAG,EAAO,EAAE;QACZ,OAAO,EAAG,EAAE;KACb,CAAC;IAEF;;;;OAIG;IACH,YAAY,KAAe;QACzB,+CAA+C;QAC/C,IAAG,KAAK,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;YACvB,MAAM,IAAI,cAAc,CACtB,uDAAuD,EACvD,mBAAmB,EAAE,EAAE,KAAK,EAAE,CAC/B,CAAC;QACJ,CAAC;QAED,wDAAwD;QACxD,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,cAAc,CACtB,oEAAoE,EACpE,m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