@taquito/signer 23.0.0-beta.1 → 23.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,15 @@
1
1
  import { openSecretBox } from '@stablelib/nacl';
2
- import { b58DecodeAndCheckPrefix, PrefixV2, b58Encode, BLS12_381_DST, POP_DST, hex2buf, mergebuf, buf2hex } from '@taquito/utils';
2
+ import { b58DecodeAndCheckPrefix, PrefixV2, b58Encode, compareArrays, InvalidPublicKeyError, BLS12_381_DST, POP_DST, hex2buf, mergebuf, buf2hex } from '@taquito/utils';
3
3
  import toBuffer from 'typedarray-to-buffer';
4
4
  import { hash } from '@stablelib/blake2b';
5
5
  import { generateKeyPairFromSeed, sign } from '@stablelib/ed25519';
6
6
  import elliptic, { ec } from 'elliptic';
7
+ import KeyPair from 'elliptic/lib/elliptic/ec/key';
8
+ import { ParameterValidationError, UnsupportedActionError, InvalidHexStringError, InvalidKeyError, InvalidDerivationPathError, ProhibitedActionError } from '@taquito/core';
7
9
  import pbkdf2 from 'pbkdf2';
8
10
  import * as Bip39 from 'bip39';
9
11
  import { HMAC } from '@stablelib/hmac';
10
12
  import { SHA512 } from '@stablelib/sha512';
11
- import { InvalidHexStringError, ParameterValidationError, UnsupportedActionError, InvalidKeyError, InvalidDerivationPathError, ProhibitedActionError } from '@taquito/core';
12
13
  import BN from 'bn.js';
13
14
  import { bls12_381 } from '@noble/curves/bls12-381';
14
15
 
@@ -57,7 +58,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
57
58
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
58
59
  };
59
60
 
60
- var _EdKey_secretKey, _EdKey_publicKey;
61
+ var _EdKey_keyPair, _EdPublicKey_key;
61
62
  /**
62
63
  * @description Provide signing logic for ed25519 curve based key (tz1)
63
64
  */
@@ -70,8 +71,7 @@ class EdKey {
70
71
  * @throws {@link InvalidKeyError}
71
72
  */
72
73
  constructor(key, decrypt) {
73
- _EdKey_secretKey.set(this, void 0);
74
- _EdKey_publicKey.set(this, void 0);
74
+ _EdKey_keyPair.set(this, void 0);
75
75
  const tmp = b58DecodeAndCheckPrefix(key, [
76
76
  PrefixV2.Ed25519SecretKey,
77
77
  PrefixV2.Ed25519EncryptedSeed,
@@ -80,8 +80,10 @@ class EdKey {
80
80
  let [keyData] = tmp;
81
81
  const [, prefix] = tmp;
82
82
  if (prefix === PrefixV2.Ed25519SecretKey) {
83
- __classPrivateFieldSet(this, _EdKey_secretKey, keyData, "f");
84
- __classPrivateFieldSet(this, _EdKey_publicKey, keyData.slice(32), "f");
83
+ __classPrivateFieldSet(this, _EdKey_keyPair, {
84
+ secretKey: keyData,
85
+ publicKey: keyData.slice(32),
86
+ }, "f");
85
87
  }
86
88
  else {
87
89
  if (prefix === PrefixV2.Ed25519EncryptedSeed) {
@@ -92,9 +94,7 @@ class EdKey {
92
94
  throw new Error('decryption function is not provided');
93
95
  }
94
96
  }
95
- const { publicKey, secretKey } = generateKeyPairFromSeed(keyData);
96
- __classPrivateFieldSet(this, _EdKey_publicKey, publicKey, "f");
97
- __classPrivateFieldSet(this, _EdKey_secretKey, secretKey, "f");
97
+ __classPrivateFieldSet(this, _EdKey_keyPair, generateKeyPairFromSeed(keyData), "f");
98
98
  }
99
99
  }
100
100
  /**
@@ -103,154 +103,64 @@ class EdKey {
103
103
  * @param bytesHash Blake2b hash of the bytes to sign
104
104
  */
105
105
  sign(bytes) {
106
- return __awaiter(this, void 0, void 0, function* () {
107
- const hash$1 = hash(bytes, 32);
108
- const signature = sign(__classPrivateFieldGet(this, _EdKey_secretKey, "f"), hash$1);
109
- return Promise.resolve({
110
- rawSignature: signature,
111
- sig: b58Encode(signature, PrefixV2.GenericSignature),
112
- prefixSig: b58Encode(signature, PrefixV2.Ed25519Signature),
113
- });
114
- });
106
+ const hash$1 = hash(bytes, 32);
107
+ const signature = sign(__classPrivateFieldGet(this, _EdKey_keyPair, "f").secretKey, hash$1);
108
+ return {
109
+ rawSignature: signature,
110
+ sig: b58Encode(signature, PrefixV2.GenericSignature),
111
+ prefixSig: b58Encode(signature, PrefixV2.Ed25519Signature),
112
+ };
115
113
  }
116
114
  /**
117
115
  * @returns Encoded public key
118
116
  */
119
117
  publicKey() {
120
- return Promise.resolve(b58Encode(__classPrivateFieldGet(this, _EdKey_publicKey, "f"), PrefixV2.Ed25519PublicKey));
121
- }
122
- /**
123
- * @returns Encoded public key hash
124
- */
125
- publicKeyHash() {
126
- return Promise.resolve(b58Encode(hash(__classPrivateFieldGet(this, _EdKey_publicKey, "f"), 20), PrefixV2.Ed25519PublicKeyHash));
118
+ return new EdPublicKey(__classPrivateFieldGet(this, _EdKey_keyPair, "f").publicKey);
127
119
  }
128
120
  /**
129
121
  * @returns Encoded private key
130
122
  */
131
123
  secretKey() {
132
- return Promise.resolve(b58Encode(__classPrivateFieldGet(this, _EdKey_secretKey, "f"), PrefixV2.Ed25519SecretKey));
124
+ return b58Encode(__classPrivateFieldGet(this, _EdKey_keyPair, "f").secretKey, PrefixV2.Ed25519SecretKey);
133
125
  }
134
126
  }
135
- _EdKey_secretKey = new WeakMap(), _EdKey_publicKey = new WeakMap();
136
-
137
- var _ECKey_key, _ECKey_publicKey, _ECKey_curve;
138
- const pref = {
139
- p256: {
140
- pk: PrefixV2.P256PublicKey,
141
- sk: PrefixV2.P256SecretKey,
142
- pkh: PrefixV2.P256PublicKeyHash,
143
- sig: PrefixV2.P256Signature,
144
- },
145
- secp256k1: {
146
- pk: PrefixV2.Secp256k1PublicKey,
147
- sk: PrefixV2.Secp256k1SecretKey,
148
- pkh: PrefixV2.Secp256k1PublicKeyHash,
149
- sig: PrefixV2.Secp256k1Signature,
150
- },
151
- };
152
- /**
153
- * @description Provide signing logic for elliptic curve based key (tz2, tz3)
154
- */
155
- class ECKey {
156
- /**
157
- *
158
- * @param key Encoded private key
159
- * @param decrypt Decrypt function
160
- * @throws {@link InvalidKeyError}
161
- */
162
- constructor(key, decrypt) {
163
- var _a;
164
- _ECKey_key.set(this, void 0);
165
- _ECKey_publicKey.set(this, void 0);
166
- _ECKey_curve.set(this, void 0);
167
- const tmp = b58DecodeAndCheckPrefix(key, [
168
- PrefixV2.Secp256k1EncryptedSecretKey,
169
- PrefixV2.P256EncryptedSecretKey,
170
- PrefixV2.Secp256k1SecretKey,
171
- PrefixV2.P256SecretKey,
172
- ]);
173
- _a = this, [({ set value(_b) { __classPrivateFieldSet(_a, _ECKey_key, _b, "f"); } }).value] = tmp;
174
- const [, prefix] = tmp;
175
- switch (prefix) {
176
- case PrefixV2.Secp256k1EncryptedSecretKey:
177
- case PrefixV2.P256EncryptedSecretKey:
178
- if (decrypt !== undefined) {
179
- __classPrivateFieldSet(this, _ECKey_key, decrypt(__classPrivateFieldGet(this, _ECKey_key, "f")), "f");
180
- }
181
- else {
182
- throw new Error('decryption function is not provided');
183
- }
184
- if (prefix === PrefixV2.Secp256k1EncryptedSecretKey) {
185
- __classPrivateFieldSet(this, _ECKey_curve, 'secp256k1', "f");
186
- }
187
- else {
188
- __classPrivateFieldSet(this, _ECKey_curve, 'p256', "f");
189
- }
190
- break;
191
- case PrefixV2.Secp256k1SecretKey:
192
- __classPrivateFieldSet(this, _ECKey_curve, 'secp256k1', "f");
193
- break;
194
- default:
195
- __classPrivateFieldSet(this, _ECKey_curve, 'p256', "f");
196
- break;
127
+ _EdKey_keyPair = new WeakMap();
128
+ class EdPublicKey {
129
+ constructor(src) {
130
+ _EdPublicKey_key.set(this, void 0);
131
+ if (typeof src === 'string') {
132
+ const [key, _] = b58DecodeAndCheckPrefix(src, [PrefixV2.Ed25519PublicKey]);
133
+ __classPrivateFieldSet(this, _EdPublicKey_key, key, "f");
134
+ }
135
+ else {
136
+ __classPrivateFieldSet(this, _EdPublicKey_key, src, "f");
197
137
  }
198
- const keyPair = new elliptic.ec(__classPrivateFieldGet(this, _ECKey_curve, "f")).keyFromPrivate(__classPrivateFieldGet(this, _ECKey_key, "f"));
199
- __classPrivateFieldSet(this, _ECKey_publicKey, new Uint8Array(keyPair.getPublic(true, 'array')), "f"); // compress
200
138
  }
201
- /**
202
- *
203
- * @param bytes Bytes to sign
204
- * @param bytesHash Blake2b hash of the bytes to sign
205
- */
206
- sign(bytes) {
207
- const hash$1 = hash(bytes, 32);
208
- const key = new elliptic.ec(__classPrivateFieldGet(this, _ECKey_curve, "f")).keyFromPrivate(__classPrivateFieldGet(this, _ECKey_key, "f"));
209
- const sig = key.sign(hash$1, { canonical: true });
210
- const signature = new Uint8Array(64);
211
- const r = sig.r.toArray();
212
- const s = sig.s.toArray();
213
- signature.set(r, 32 - r.length);
214
- signature.set(s, 64 - s.length);
215
- return Promise.resolve({
216
- rawSignature: signature,
217
- sig: b58Encode(signature, PrefixV2.GenericSignature),
218
- prefixSig: b58Encode(signature, pref[__classPrivateFieldGet(this, _ECKey_curve, "f")].sig),
219
- });
139
+ compare(other) {
140
+ if (other instanceof EdPublicKey) {
141
+ return compareArrays(this.bytes(), other.bytes());
142
+ }
143
+ else {
144
+ throw new InvalidPublicKeyError('EdDSA key expected');
145
+ }
220
146
  }
221
- /**
222
- * @returns Encoded public key
223
- */
224
- publicKey() {
225
- return Promise.resolve(b58Encode(__classPrivateFieldGet(this, _ECKey_publicKey, "f"), pref[__classPrivateFieldGet(this, _ECKey_curve, "f")].pk));
147
+ hash() {
148
+ return b58Encode(hash(__classPrivateFieldGet(this, _EdPublicKey_key, "f"), 20), PrefixV2.Ed25519PublicKeyHash);
226
149
  }
227
- /**
228
- * @returns Encoded public key hash
229
- */
230
- publicKeyHash() {
231
- return Promise.resolve(b58Encode(hash(new Uint8Array(__classPrivateFieldGet(this, _ECKey_publicKey, "f")), 20), pref[__classPrivateFieldGet(this, _ECKey_curve, "f")].pkh));
150
+ bytes() {
151
+ return __classPrivateFieldGet(this, _EdPublicKey_key, "f");
232
152
  }
233
- /**
234
- * @returns Encoded private key
235
- */
236
- secretKey() {
237
- return Promise.resolve(b58Encode(__classPrivateFieldGet(this, _ECKey_key, "f"), pref[__classPrivateFieldGet(this, _ECKey_curve, "f")].sk));
153
+ toProtocol() {
154
+ const res = new Uint8Array(__classPrivateFieldGet(this, _EdPublicKey_key, "f").length + 1);
155
+ res[0] = 0;
156
+ res.set(__classPrivateFieldGet(this, _EdPublicKey_key, "f"), 1);
157
+ return res;
238
158
  }
239
- }
240
- _ECKey_key = new WeakMap(), _ECKey_publicKey = new WeakMap(), _ECKey_curve = new WeakMap();
241
-
242
- function parseHex(s) {
243
- const res = [];
244
- for (let i = 0; i < s.length; i += 2) {
245
- const ss = s.slice(i, i + 2);
246
- const x = parseInt(ss, 16);
247
- if (Number.isNaN(x)) {
248
- throw new InvalidHexStringError(ss);
249
- }
250
- res.push(x);
159
+ toString() {
160
+ return b58Encode(__classPrivateFieldGet(this, _EdPublicKey_key, "f"), PrefixV2.Ed25519PublicKey);
251
161
  }
252
- return new Uint8Array(res);
253
162
  }
163
+ _EdPublicKey_key = new WeakMap();
254
164
 
255
165
  /**
256
166
  * @category Error
@@ -321,6 +231,189 @@ class InvalidPassphraseError extends ParameterValidationError {
321
231
  }
322
232
  }
323
233
 
234
+ const pref = {
235
+ p256: {
236
+ pk: PrefixV2.P256PublicKey,
237
+ sk: PrefixV2.P256SecretKey,
238
+ pkh: PrefixV2.P256PublicKeyHash,
239
+ sig: PrefixV2.P256Signature,
240
+ tag: 2,
241
+ },
242
+ secp256k1: {
243
+ pk: PrefixV2.Secp256k1PublicKey,
244
+ sk: PrefixV2.Secp256k1SecretKey,
245
+ pkh: PrefixV2.Secp256k1PublicKeyHash,
246
+ sig: PrefixV2.Secp256k1Signature,
247
+ tag: 1,
248
+ },
249
+ };
250
+ class ECKeyBase {
251
+ constructor(keyPair) {
252
+ this.keyPair = keyPair;
253
+ }
254
+ curve() {
255
+ switch (this.keyPair.ec.curve) {
256
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
257
+ case elliptic.curves.secp256k1.curve:
258
+ return 'secp256k1';
259
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
260
+ case elliptic.curves.p256.curve:
261
+ return 'p256';
262
+ default:
263
+ throw new InvalidCurveError('unknown curve');
264
+ }
265
+ }
266
+ }
267
+ /**
268
+ * @description Provide signing logic for elliptic curve based key (tz2, tz3)
269
+ */
270
+ class ECKey extends ECKeyBase {
271
+ /**
272
+ *
273
+ * @param key Encoded private key
274
+ * @param decrypt Decrypt function
275
+ * @throws {@link InvalidKeyError}
276
+ */
277
+ constructor(key, decrypt) {
278
+ const [keyData, prefix] = b58DecodeAndCheckPrefix(key, [
279
+ PrefixV2.Secp256k1EncryptedSecretKey,
280
+ PrefixV2.P256EncryptedSecretKey,
281
+ PrefixV2.Secp256k1SecretKey,
282
+ PrefixV2.P256SecretKey,
283
+ ]);
284
+ const [decKey, curve] = (() => {
285
+ switch (prefix) {
286
+ case PrefixV2.Secp256k1EncryptedSecretKey:
287
+ case PrefixV2.P256EncryptedSecretKey:
288
+ if (decrypt === undefined) {
289
+ throw new Error('decryption function is not provided');
290
+ }
291
+ else {
292
+ return [
293
+ decrypt(keyData),
294
+ prefix === PrefixV2.Secp256k1EncryptedSecretKey ? 'secp256k1' : 'p256',
295
+ ];
296
+ }
297
+ case PrefixV2.Secp256k1SecretKey:
298
+ return [keyData, 'secp256k1'];
299
+ default:
300
+ return [keyData, 'p256'];
301
+ }
302
+ })();
303
+ super(new elliptic.ec(curve).keyFromPrivate(decKey));
304
+ }
305
+ /**
306
+ *
307
+ * @param bytes Bytes to sign
308
+ * @param bytesHash Blake2b hash of the bytes to sign
309
+ */
310
+ sign(bytes) {
311
+ const hash$1 = hash(bytes, 32);
312
+ const sig = this.keyPair.sign(hash$1, { canonical: true });
313
+ const signature = new Uint8Array(64);
314
+ const r = sig.r.toArray();
315
+ const s = sig.s.toArray();
316
+ signature.set(r, 32 - r.length);
317
+ signature.set(s, 64 - s.length);
318
+ return {
319
+ rawSignature: signature,
320
+ sig: b58Encode(signature, PrefixV2.GenericSignature),
321
+ prefixSig: b58Encode(signature, pref[this.curve()].sig),
322
+ };
323
+ }
324
+ /**
325
+ * @returns Encoded public key
326
+ */
327
+ publicKey() {
328
+ return new ECPublicKey(this.keyPair.ec.keyFromPublic(this.keyPair));
329
+ }
330
+ /**
331
+ * @returns Encoded private key
332
+ */
333
+ secretKey() {
334
+ return b58Encode(new Uint8Array(this.keyPair.getPrivate().toArray()), pref[this.curve()].sk);
335
+ }
336
+ }
337
+ function isKeyPair(src) {
338
+ return src instanceof KeyPair;
339
+ }
340
+ class ECPublicKey extends ECKeyBase {
341
+ constructor(src, curve) {
342
+ const key = (() => {
343
+ if (isKeyPair(src)) {
344
+ return src;
345
+ }
346
+ else {
347
+ const [key, crv] = (() => {
348
+ if (typeof src === 'string') {
349
+ const [key, pre] = b58DecodeAndCheckPrefix(src, [
350
+ PrefixV2.Secp256k1PublicKey,
351
+ PrefixV2.P256PublicKey,
352
+ ]);
353
+ return [key, pre === PrefixV2.Secp256k1PublicKey ? 'secp256k1' : 'p256'];
354
+ }
355
+ else if (curve !== undefined) {
356
+ return [src, curve];
357
+ }
358
+ else {
359
+ throw new InvalidCurveError('missing curve type');
360
+ }
361
+ })();
362
+ return new elliptic.ec(crv).keyFromPublic(key);
363
+ }
364
+ })();
365
+ super(key);
366
+ }
367
+ compare(other) {
368
+ if (other instanceof ECPublicKey) {
369
+ if (this.curve() === other.curve()) {
370
+ const compress = this.curve() === 'secp256k1';
371
+ return compareArrays(this.bytes(compress), other.bytes(compress));
372
+ }
373
+ else if (this.curve() === 'secp256k1') {
374
+ return -1;
375
+ }
376
+ else {
377
+ return 1;
378
+ }
379
+ }
380
+ else {
381
+ throw new InvalidPublicKeyError('ECDSA key expected');
382
+ }
383
+ }
384
+ hash() {
385
+ const key = this.bytes();
386
+ return b58Encode(hash(key, 20), pref[this.curve()].pkh);
387
+ }
388
+ bytes(compress = true) {
389
+ return new Uint8Array(this.keyPair.getPublic(compress, 'array'));
390
+ }
391
+ toProtocol() {
392
+ const key = this.bytes();
393
+ const res = new Uint8Array(key.length + 1);
394
+ res[0] = pref[this.curve()].tag;
395
+ res.set(key, 1);
396
+ return res;
397
+ }
398
+ toString() {
399
+ const key = this.bytes();
400
+ return b58Encode(key, pref[this.curve()].pk);
401
+ }
402
+ }
403
+
404
+ function parseHex(s) {
405
+ const res = [];
406
+ for (let i = 0; i < s.length; i += 2) {
407
+ const ss = s.slice(i, i + 2);
408
+ const x = parseInt(ss, 16);
409
+ if (Number.isNaN(x)) {
410
+ throw new InvalidHexStringError(ss);
411
+ }
412
+ res.push(x);
413
+ }
414
+ return new Uint8Array(res);
415
+ }
416
+
324
417
  /* eslint-disable @typescript-eslint/no-this-alias */
325
418
  const seedKey = {
326
419
  p256: 'Nist256p1 seed',
@@ -593,7 +686,7 @@ function isPOP(k) {
593
686
  return 'provePossession' in k;
594
687
  }
595
688
 
596
- var _BLSKey_key, _BLSKey_publicKey;
689
+ var _BLSKey_key, _BLSKey_publicKey, _BLSPublicKey_key;
597
690
  const bls = bls12_381.longSignatures; // AKA MinPK
598
691
  class BLSKey {
599
692
  constructor(key, decrypt) {
@@ -622,11 +715,11 @@ class BLSKey {
622
715
  signDst(message, dst) {
623
716
  const point = bls.hash(message, dst);
624
717
  const sig = bls.sign(point, this.sk()).toBytes();
625
- return Promise.resolve({
718
+ return {
626
719
  rawSignature: sig,
627
720
  sig: b58Encode(sig, PrefixV2.GenericSignature),
628
721
  prefixSig: b58Encode(sig, PrefixV2.BLS12_381Signature),
629
- });
722
+ };
630
723
  }
631
724
  sign(message) {
632
725
  return this.signDst(message, BLS12_381_DST);
@@ -635,19 +728,49 @@ class BLSKey {
635
728
  return this.signDst(__classPrivateFieldGet(this, _BLSKey_publicKey, "f"), POP_DST);
636
729
  }
637
730
  publicKey() {
638
- const res = b58Encode(__classPrivateFieldGet(this, _BLSKey_publicKey, "f"), PrefixV2.BLS12_381PublicKey);
639
- return Promise.resolve(res);
640
- }
641
- publicKeyHash() {
642
- const res = b58Encode(hash(__classPrivateFieldGet(this, _BLSKey_publicKey, "f"), 20), PrefixV2.BLS12_381PublicKeyHash);
643
- return Promise.resolve(res);
731
+ return new BLSPublicKey(__classPrivateFieldGet(this, _BLSKey_publicKey, "f"));
644
732
  }
645
733
  secretKey() {
646
- const res = b58Encode(__classPrivateFieldGet(this, _BLSKey_key, "f"), PrefixV2.BLS12_381SecretKey);
647
- return Promise.resolve(res);
734
+ return b58Encode(__classPrivateFieldGet(this, _BLSKey_key, "f"), PrefixV2.BLS12_381SecretKey);
648
735
  }
649
736
  }
650
737
  _BLSKey_key = new WeakMap(), _BLSKey_publicKey = new WeakMap();
738
+ class BLSPublicKey {
739
+ constructor(src) {
740
+ _BLSPublicKey_key.set(this, void 0);
741
+ if (typeof src === 'string') {
742
+ const [key, _] = b58DecodeAndCheckPrefix(src, [PrefixV2.BLS12_381PublicKey]);
743
+ __classPrivateFieldSet(this, _BLSPublicKey_key, key, "f");
744
+ }
745
+ else {
746
+ __classPrivateFieldSet(this, _BLSPublicKey_key, src, "f");
747
+ }
748
+ }
749
+ compare(other) {
750
+ if (other instanceof BLSPublicKey) {
751
+ return compareArrays(this.bytes(), other.bytes());
752
+ }
753
+ else {
754
+ throw new InvalidPublicKeyError('BLS key expected');
755
+ }
756
+ }
757
+ hash() {
758
+ return b58Encode(hash(__classPrivateFieldGet(this, _BLSPublicKey_key, "f"), 20), PrefixV2.BLS12_381PublicKeyHash);
759
+ }
760
+ bytes() {
761
+ return __classPrivateFieldGet(this, _BLSPublicKey_key, "f");
762
+ }
763
+ toProtocol() {
764
+ const res = new Uint8Array(__classPrivateFieldGet(this, _BLSPublicKey_key, "f").length + 1);
765
+ res[0] = 3;
766
+ res.set(__classPrivateFieldGet(this, _BLSPublicKey_key, "f"), 1);
767
+ return res;
768
+ }
769
+ toString() {
770
+ return b58Encode(__classPrivateFieldGet(this, _BLSPublicKey_key, "f"), PrefixV2.BLS12_381PublicKey);
771
+ }
772
+ }
773
+ _BLSPublicKey_key = new WeakMap();
651
774
 
652
775
  /**
653
776
  *
@@ -690,8 +813,8 @@ function importKey(toolkit, privateKeyOrEmail, passphrase, mnemonic, secret) {
690
813
 
691
814
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
692
815
  const VERSION = {
693
- "commitHash": "10b3de10de15ae68d47b1fca922d3129d2f79641",
694
- "version": "23.0.0-beta.1"
816
+ "commitHash": "c26a3d67ae3694c157f4f56fb5bf85ca3c495a9b",
817
+ "version": "23.0.1"
695
818
  };
696
819
 
697
820
  var _InMemorySigner_key;
@@ -839,22 +962,40 @@ class InMemorySigner {
839
962
  * @returns Encoded public key
840
963
  */
841
964
  publicKey() {
842
- return __classPrivateFieldGet(this, _InMemorySigner_key, "f").publicKey();
965
+ return Promise.resolve(String(__classPrivateFieldGet(this, _InMemorySigner_key, "f").publicKey()));
843
966
  }
844
967
  /**
845
968
  * @returns Encoded public key hash
846
969
  */
847
970
  publicKeyHash() {
848
- return __classPrivateFieldGet(this, _InMemorySigner_key, "f").publicKeyHash();
971
+ return Promise.resolve(__classPrivateFieldGet(this, _InMemorySigner_key, "f").publicKey().hash());
849
972
  }
850
973
  /**
851
974
  * @returns Encoded private key
852
975
  */
853
976
  secretKey() {
854
- return __classPrivateFieldGet(this, _InMemorySigner_key, "f").secretKey();
977
+ return Promise.resolve(__classPrivateFieldGet(this, _InMemorySigner_key, "f").secretKey());
855
978
  }
856
979
  }
857
980
  _InMemorySigner_key = new WeakMap();
981
+ function publicKeyFromString(src) {
982
+ const [keyData, pre] = b58DecodeAndCheckPrefix(src, [
983
+ PrefixV2.Ed25519PublicKey,
984
+ PrefixV2.Secp256k1PublicKey,
985
+ PrefixV2.P256PublicKey,
986
+ PrefixV2.BLS12_381PublicKey,
987
+ ]);
988
+ switch (pre) {
989
+ case PrefixV2.Ed25519PublicKey:
990
+ return new EdPublicKey(keyData);
991
+ case PrefixV2.Secp256k1PublicKey:
992
+ return new ECPublicKey(keyData, 'secp256k1');
993
+ case PrefixV2.P256PublicKey:
994
+ return new ECPublicKey(keyData, 'p256');
995
+ case PrefixV2.BLS12_381PublicKey:
996
+ return new BLSPublicKey(keyData);
997
+ }
998
+ }
858
999
 
859
- export { ecdsa as ECDSA, ed25519 as Ed25519, Hard, InMemorySigner, InvalidPassphraseError, Path, VERSION, generateSecretKey, importKey };
1000
+ export { ecdsa as ECDSA, ed25519 as Ed25519, Hard, InMemorySigner, InvalidPassphraseError, Path, VERSION, generateSecretKey, importKey, publicKeyFromString };
860
1001
  //# sourceMappingURL=taquito-signer.es6.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"taquito-signer.es6.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"taquito-signer.es6.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}