@solana/web3.js 1.54.0 → 1.56.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.
@@ -2,18 +2,21 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var nacl = require('tweetnacl');
6
5
  var buffer = require('buffer');
6
+ var sha512 = require('@noble/hashes/sha512');
7
+ var ed25519 = require('@noble/ed25519');
7
8
  var BN = require('bn.js');
8
9
  var bs58 = require('bs58');
10
+ var sha256 = require('@noble/hashes/sha256');
9
11
  var borsh = require('borsh');
10
12
  var BufferLayout = require('@solana/buffer-layout');
11
13
  var bigintBuffer = require('bigint-buffer');
12
14
  var superstruct = require('superstruct');
13
15
  var rpcWebsockets = require('rpc-websockets');
14
16
  var RpcClient = require('jayson/lib/client/browser');
15
- var secp256k1 = require('secp256k1');
16
17
  var sha3 = require('js-sha3');
18
+ var hmac = require('@noble/hashes/hmac');
19
+ var secp256k1 = require('@noble/secp256k1');
17
20
 
18
21
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
19
22
 
@@ -35,1729 +38,58 @@ function _interopNamespace(e) {
35
38
  return Object.freeze(n);
36
39
  }
37
40
 
38
- var nacl__default = /*#__PURE__*/_interopDefaultLegacy(nacl);
41
+ var ed25519__namespace = /*#__PURE__*/_interopNamespace(ed25519);
39
42
  var BN__default = /*#__PURE__*/_interopDefaultLegacy(BN);
40
43
  var bs58__default = /*#__PURE__*/_interopDefaultLegacy(bs58);
41
44
  var BufferLayout__namespace = /*#__PURE__*/_interopNamespace(BufferLayout);
42
45
  var RpcClient__default = /*#__PURE__*/_interopDefaultLegacy(RpcClient);
43
- var secp256k1__default = /*#__PURE__*/_interopDefaultLegacy(secp256k1);
44
46
  var sha3__default = /*#__PURE__*/_interopDefaultLegacy(sha3);
47
+ var secp256k1__namespace = /*#__PURE__*/_interopNamespace(secp256k1);
45
48
 
46
- const toBuffer = arr => {
47
- if (buffer.Buffer.isBuffer(arr)) {
48
- return arr;
49
- } else if (arr instanceof Uint8Array) {
50
- return buffer.Buffer.from(arr.buffer, arr.byteOffset, arr.byteLength);
51
- } else {
52
- return buffer.Buffer.from(arr);
53
- }
54
- };
55
-
56
- var hash$1 = {};
57
-
58
- var utils$9 = {};
59
-
60
- var minimalisticAssert = assert$6;
61
-
62
- function assert$6(val, msg) {
63
- if (!val)
64
- throw new Error(msg || 'Assertion failed');
65
- }
49
+ /**
50
+ * A 64 byte secret key, the first 32 bytes of which is the
51
+ * private scalar and the last 32 bytes is the public key.
52
+ * Read more: https://blog.mozilla.org/warner/2011/11/29/ed25519-keys/
53
+ */
66
54
 
67
- assert$6.equal = function assertEqual(l, r, msg) {
68
- if (l != r)
69
- throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r));
70
- };
55
+ ed25519__namespace.utils.sha512Sync = (...m) => sha512.sha512(ed25519__namespace.utils.concatBytes(...m));
71
56
 
72
- var inherits_browser = {exports: {}};
73
-
74
- if (typeof Object.create === 'function') {
75
- // implementation from standard node.js 'util' module
76
- inherits_browser.exports = function inherits(ctor, superCtor) {
77
- if (superCtor) {
78
- ctor.super_ = superCtor;
79
- ctor.prototype = Object.create(superCtor.prototype, {
80
- constructor: {
81
- value: ctor,
82
- enumerable: false,
83
- writable: true,
84
- configurable: true
85
- }
86
- });
87
- }
88
- };
89
- } else {
90
- // old school shim for old browsers
91
- inherits_browser.exports = function inherits(ctor, superCtor) {
92
- if (superCtor) {
93
- ctor.super_ = superCtor;
94
- var TempCtor = function () {};
95
- TempCtor.prototype = superCtor.prototype;
96
- ctor.prototype = new TempCtor();
97
- ctor.prototype.constructor = ctor;
98
- }
57
+ const generatePrivateKey = ed25519__namespace.utils.randomPrivateKey;
58
+ const generateKeypair = () => {
59
+ const privateScalar = ed25519__namespace.utils.randomPrivateKey();
60
+ const publicKey = getPublicKey(privateScalar);
61
+ const secretKey = new Uint8Array(64);
62
+ secretKey.set(privateScalar);
63
+ secretKey.set(publicKey, 32);
64
+ return {
65
+ publicKey,
66
+ secretKey
99
67
  };
100
- }
101
-
102
- var assert$5 = minimalisticAssert;
103
- var inherits = inherits_browser.exports;
104
-
105
- utils$9.inherits = inherits;
106
-
107
- function isSurrogatePair(msg, i) {
108
- if ((msg.charCodeAt(i) & 0xFC00) !== 0xD800) {
109
- return false;
110
- }
111
- if (i < 0 || i + 1 >= msg.length) {
68
+ };
69
+ const getPublicKey = ed25519__namespace.sync.getPublicKey;
70
+ function isOnCurve(publicKey) {
71
+ try {
72
+ ed25519__namespace.Point.fromHex(publicKey, true
73
+ /* strict */
74
+ );
75
+ return true;
76
+ } catch {
112
77
  return false;
113
78
  }
114
- return (msg.charCodeAt(i + 1) & 0xFC00) === 0xDC00;
115
79
  }
80
+ const sign = (message, secretKey) => ed25519__namespace.sync.sign(message, secretKey.slice(0, 32));
81
+ const verify = ed25519__namespace.sync.verify;
116
82
 
117
- function toArray(msg, enc) {
118
- if (Array.isArray(msg))
119
- return msg.slice();
120
- if (!msg)
121
- return [];
122
- var res = [];
123
- if (typeof msg === 'string') {
124
- if (!enc) {
125
- // Inspired by stringToUtf8ByteArray() in closure-library by Google
126
- // https://github.com/google/closure-library/blob/8598d87242af59aac233270742c8984e2b2bdbe0/closure/goog/crypt/crypt.js#L117-L143
127
- // Apache License 2.0
128
- // https://github.com/google/closure-library/blob/master/LICENSE
129
- var p = 0;
130
- for (var i = 0; i < msg.length; i++) {
131
- var c = msg.charCodeAt(i);
132
- if (c < 128) {
133
- res[p++] = c;
134
- } else if (c < 2048) {
135
- res[p++] = (c >> 6) | 192;
136
- res[p++] = (c & 63) | 128;
137
- } else if (isSurrogatePair(msg, i)) {
138
- c = 0x10000 + ((c & 0x03FF) << 10) + (msg.charCodeAt(++i) & 0x03FF);
139
- res[p++] = (c >> 18) | 240;
140
- res[p++] = ((c >> 12) & 63) | 128;
141
- res[p++] = ((c >> 6) & 63) | 128;
142
- res[p++] = (c & 63) | 128;
143
- } else {
144
- res[p++] = (c >> 12) | 224;
145
- res[p++] = ((c >> 6) & 63) | 128;
146
- res[p++] = (c & 63) | 128;
147
- }
148
- }
149
- } else if (enc === 'hex') {
150
- msg = msg.replace(/[^a-z0-9]+/ig, '');
151
- if (msg.length % 2 !== 0)
152
- msg = '0' + msg;
153
- for (i = 0; i < msg.length; i += 2)
154
- res.push(parseInt(msg[i] + msg[i + 1], 16));
155
- }
156
- } else {
157
- for (i = 0; i < msg.length; i++)
158
- res[i] = msg[i] | 0;
159
- }
160
- return res;
161
- }
162
- utils$9.toArray = toArray;
163
-
164
- function toHex(msg) {
165
- var res = '';
166
- for (var i = 0; i < msg.length; i++)
167
- res += zero2(msg[i].toString(16));
168
- return res;
169
- }
170
- utils$9.toHex = toHex;
171
-
172
- function htonl(w) {
173
- var res = (w >>> 24) |
174
- ((w >>> 8) & 0xff00) |
175
- ((w << 8) & 0xff0000) |
176
- ((w & 0xff) << 24);
177
- return res >>> 0;
178
- }
179
- utils$9.htonl = htonl;
180
-
181
- function toHex32(msg, endian) {
182
- var res = '';
183
- for (var i = 0; i < msg.length; i++) {
184
- var w = msg[i];
185
- if (endian === 'little')
186
- w = htonl(w);
187
- res += zero8(w.toString(16));
188
- }
189
- return res;
190
- }
191
- utils$9.toHex32 = toHex32;
192
-
193
- function zero2(word) {
194
- if (word.length === 1)
195
- return '0' + word;
196
- else
197
- return word;
198
- }
199
- utils$9.zero2 = zero2;
200
-
201
- function zero8(word) {
202
- if (word.length === 7)
203
- return '0' + word;
204
- else if (word.length === 6)
205
- return '00' + word;
206
- else if (word.length === 5)
207
- return '000' + word;
208
- else if (word.length === 4)
209
- return '0000' + word;
210
- else if (word.length === 3)
211
- return '00000' + word;
212
- else if (word.length === 2)
213
- return '000000' + word;
214
- else if (word.length === 1)
215
- return '0000000' + word;
216
- else
217
- return word;
218
- }
219
- utils$9.zero8 = zero8;
220
-
221
- function join32(msg, start, end, endian) {
222
- var len = end - start;
223
- assert$5(len % 4 === 0);
224
- var res = new Array(len / 4);
225
- for (var i = 0, k = start; i < res.length; i++, k += 4) {
226
- var w;
227
- if (endian === 'big')
228
- w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3];
229
- else
230
- w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k];
231
- res[i] = w >>> 0;
232
- }
233
- return res;
234
- }
235
- utils$9.join32 = join32;
236
-
237
- function split32(msg, endian) {
238
- var res = new Array(msg.length * 4);
239
- for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
240
- var m = msg[i];
241
- if (endian === 'big') {
242
- res[k] = m >>> 24;
243
- res[k + 1] = (m >>> 16) & 0xff;
244
- res[k + 2] = (m >>> 8) & 0xff;
245
- res[k + 3] = m & 0xff;
246
- } else {
247
- res[k + 3] = m >>> 24;
248
- res[k + 2] = (m >>> 16) & 0xff;
249
- res[k + 1] = (m >>> 8) & 0xff;
250
- res[k] = m & 0xff;
251
- }
252
- }
253
- return res;
254
- }
255
- utils$9.split32 = split32;
256
-
257
- function rotr32$1(w, b) {
258
- return (w >>> b) | (w << (32 - b));
259
- }
260
- utils$9.rotr32 = rotr32$1;
261
-
262
- function rotl32$2(w, b) {
263
- return (w << b) | (w >>> (32 - b));
264
- }
265
- utils$9.rotl32 = rotl32$2;
266
-
267
- function sum32$3(a, b) {
268
- return (a + b) >>> 0;
269
- }
270
- utils$9.sum32 = sum32$3;
271
-
272
- function sum32_3$1(a, b, c) {
273
- return (a + b + c) >>> 0;
274
- }
275
- utils$9.sum32_3 = sum32_3$1;
276
-
277
- function sum32_4$2(a, b, c, d) {
278
- return (a + b + c + d) >>> 0;
279
- }
280
- utils$9.sum32_4 = sum32_4$2;
281
-
282
- function sum32_5$2(a, b, c, d, e) {
283
- return (a + b + c + d + e) >>> 0;
284
- }
285
- utils$9.sum32_5 = sum32_5$2;
286
-
287
- function sum64$1(buf, pos, ah, al) {
288
- var bh = buf[pos];
289
- var bl = buf[pos + 1];
290
-
291
- var lo = (al + bl) >>> 0;
292
- var hi = (lo < al ? 1 : 0) + ah + bh;
293
- buf[pos] = hi >>> 0;
294
- buf[pos + 1] = lo;
295
- }
296
- utils$9.sum64 = sum64$1;
297
-
298
- function sum64_hi$1(ah, al, bh, bl) {
299
- var lo = (al + bl) >>> 0;
300
- var hi = (lo < al ? 1 : 0) + ah + bh;
301
- return hi >>> 0;
302
- }
303
- utils$9.sum64_hi = sum64_hi$1;
304
-
305
- function sum64_lo$1(ah, al, bh, bl) {
306
- var lo = al + bl;
307
- return lo >>> 0;
308
- }
309
- utils$9.sum64_lo = sum64_lo$1;
310
-
311
- function sum64_4_hi$1(ah, al, bh, bl, ch, cl, dh, dl) {
312
- var carry = 0;
313
- var lo = al;
314
- lo = (lo + bl) >>> 0;
315
- carry += lo < al ? 1 : 0;
316
- lo = (lo + cl) >>> 0;
317
- carry += lo < cl ? 1 : 0;
318
- lo = (lo + dl) >>> 0;
319
- carry += lo < dl ? 1 : 0;
320
-
321
- var hi = ah + bh + ch + dh + carry;
322
- return hi >>> 0;
323
- }
324
- utils$9.sum64_4_hi = sum64_4_hi$1;
325
-
326
- function sum64_4_lo$1(ah, al, bh, bl, ch, cl, dh, dl) {
327
- var lo = al + bl + cl + dl;
328
- return lo >>> 0;
329
- }
330
- utils$9.sum64_4_lo = sum64_4_lo$1;
331
-
332
- function sum64_5_hi$1(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
333
- var carry = 0;
334
- var lo = al;
335
- lo = (lo + bl) >>> 0;
336
- carry += lo < al ? 1 : 0;
337
- lo = (lo + cl) >>> 0;
338
- carry += lo < cl ? 1 : 0;
339
- lo = (lo + dl) >>> 0;
340
- carry += lo < dl ? 1 : 0;
341
- lo = (lo + el) >>> 0;
342
- carry += lo < el ? 1 : 0;
343
-
344
- var hi = ah + bh + ch + dh + eh + carry;
345
- return hi >>> 0;
346
- }
347
- utils$9.sum64_5_hi = sum64_5_hi$1;
348
-
349
- function sum64_5_lo$1(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
350
- var lo = al + bl + cl + dl + el;
351
-
352
- return lo >>> 0;
353
- }
354
- utils$9.sum64_5_lo = sum64_5_lo$1;
355
-
356
- function rotr64_hi$1(ah, al, num) {
357
- var r = (al << (32 - num)) | (ah >>> num);
358
- return r >>> 0;
359
- }
360
- utils$9.rotr64_hi = rotr64_hi$1;
361
-
362
- function rotr64_lo$1(ah, al, num) {
363
- var r = (ah << (32 - num)) | (al >>> num);
364
- return r >>> 0;
365
- }
366
- utils$9.rotr64_lo = rotr64_lo$1;
367
-
368
- function shr64_hi$1(ah, al, num) {
369
- return ah >>> num;
370
- }
371
- utils$9.shr64_hi = shr64_hi$1;
372
-
373
- function shr64_lo$1(ah, al, num) {
374
- var r = (ah << (32 - num)) | (al >>> num);
375
- return r >>> 0;
376
- }
377
- utils$9.shr64_lo = shr64_lo$1;
378
-
379
- var common$5 = {};
380
-
381
- var utils$8 = utils$9;
382
- var assert$4 = minimalisticAssert;
383
-
384
- function BlockHash$4() {
385
- this.pending = null;
386
- this.pendingTotal = 0;
387
- this.blockSize = this.constructor.blockSize;
388
- this.outSize = this.constructor.outSize;
389
- this.hmacStrength = this.constructor.hmacStrength;
390
- this.padLength = this.constructor.padLength / 8;
391
- this.endian = 'big';
392
-
393
- this._delta8 = this.blockSize / 8;
394
- this._delta32 = this.blockSize / 32;
395
- }
396
- common$5.BlockHash = BlockHash$4;
397
-
398
- BlockHash$4.prototype.update = function update(msg, enc) {
399
- // Convert message to array, pad it, and join into 32bit blocks
400
- msg = utils$8.toArray(msg, enc);
401
- if (!this.pending)
402
- this.pending = msg;
403
- else
404
- this.pending = this.pending.concat(msg);
405
- this.pendingTotal += msg.length;
406
-
407
- // Enough data, try updating
408
- if (this.pending.length >= this._delta8) {
409
- msg = this.pending;
410
-
411
- // Process pending data in blocks
412
- var r = msg.length % this._delta8;
413
- this.pending = msg.slice(msg.length - r, msg.length);
414
- if (this.pending.length === 0)
415
- this.pending = null;
416
-
417
- msg = utils$8.join32(msg, 0, msg.length - r, this.endian);
418
- for (var i = 0; i < msg.length; i += this._delta32)
419
- this._update(msg, i, i + this._delta32);
420
- }
421
-
422
- return this;
423
- };
424
-
425
- BlockHash$4.prototype.digest = function digest(enc) {
426
- this.update(this._pad());
427
- assert$4(this.pending === null);
428
-
429
- return this._digest(enc);
430
- };
431
-
432
- BlockHash$4.prototype._pad = function pad() {
433
- var len = this.pendingTotal;
434
- var bytes = this._delta8;
435
- var k = bytes - ((len + this.padLength) % bytes);
436
- var res = new Array(k + this.padLength);
437
- res[0] = 0x80;
438
- for (var i = 1; i < k; i++)
439
- res[i] = 0;
440
-
441
- // Append length
442
- len <<= 3;
443
- if (this.endian === 'big') {
444
- for (var t = 8; t < this.padLength; t++)
445
- res[i++] = 0;
446
-
447
- res[i++] = 0;
448
- res[i++] = 0;
449
- res[i++] = 0;
450
- res[i++] = 0;
451
- res[i++] = (len >>> 24) & 0xff;
452
- res[i++] = (len >>> 16) & 0xff;
453
- res[i++] = (len >>> 8) & 0xff;
454
- res[i++] = len & 0xff;
83
+ const toBuffer = arr => {
84
+ if (buffer.Buffer.isBuffer(arr)) {
85
+ return arr;
86
+ } else if (arr instanceof Uint8Array) {
87
+ return buffer.Buffer.from(arr.buffer, arr.byteOffset, arr.byteLength);
455
88
  } else {
456
- res[i++] = len & 0xff;
457
- res[i++] = (len >>> 8) & 0xff;
458
- res[i++] = (len >>> 16) & 0xff;
459
- res[i++] = (len >>> 24) & 0xff;
460
- res[i++] = 0;
461
- res[i++] = 0;
462
- res[i++] = 0;
463
- res[i++] = 0;
464
-
465
- for (t = 8; t < this.padLength; t++)
466
- res[i++] = 0;
467
- }
468
-
469
- return res;
470
- };
471
-
472
- var sha = {};
473
-
474
- var common$4 = {};
475
-
476
- var utils$7 = utils$9;
477
- var rotr32 = utils$7.rotr32;
478
-
479
- function ft_1$1(s, x, y, z) {
480
- if (s === 0)
481
- return ch32$1(x, y, z);
482
- if (s === 1 || s === 3)
483
- return p32(x, y, z);
484
- if (s === 2)
485
- return maj32$1(x, y, z);
486
- }
487
- common$4.ft_1 = ft_1$1;
488
-
489
- function ch32$1(x, y, z) {
490
- return (x & y) ^ ((~x) & z);
491
- }
492
- common$4.ch32 = ch32$1;
493
-
494
- function maj32$1(x, y, z) {
495
- return (x & y) ^ (x & z) ^ (y & z);
496
- }
497
- common$4.maj32 = maj32$1;
498
-
499
- function p32(x, y, z) {
500
- return x ^ y ^ z;
501
- }
502
- common$4.p32 = p32;
503
-
504
- function s0_256$1(x) {
505
- return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22);
506
- }
507
- common$4.s0_256 = s0_256$1;
508
-
509
- function s1_256$1(x) {
510
- return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25);
511
- }
512
- common$4.s1_256 = s1_256$1;
513
-
514
- function g0_256$1(x) {
515
- return rotr32(x, 7) ^ rotr32(x, 18) ^ (x >>> 3);
516
- }
517
- common$4.g0_256 = g0_256$1;
518
-
519
- function g1_256$1(x) {
520
- return rotr32(x, 17) ^ rotr32(x, 19) ^ (x >>> 10);
521
- }
522
- common$4.g1_256 = g1_256$1;
523
-
524
- var utils$6 = utils$9;
525
- var common$3 = common$5;
526
- var shaCommon$1 = common$4;
527
-
528
- var rotl32$1 = utils$6.rotl32;
529
- var sum32$2 = utils$6.sum32;
530
- var sum32_5$1 = utils$6.sum32_5;
531
- var ft_1 = shaCommon$1.ft_1;
532
- var BlockHash$3 = common$3.BlockHash;
533
-
534
- var sha1_K = [
535
- 0x5A827999, 0x6ED9EBA1,
536
- 0x8F1BBCDC, 0xCA62C1D6
537
- ];
538
-
539
- function SHA1() {
540
- if (!(this instanceof SHA1))
541
- return new SHA1();
542
-
543
- BlockHash$3.call(this);
544
- this.h = [
545
- 0x67452301, 0xefcdab89, 0x98badcfe,
546
- 0x10325476, 0xc3d2e1f0 ];
547
- this.W = new Array(80);
548
- }
549
-
550
- utils$6.inherits(SHA1, BlockHash$3);
551
- var _1 = SHA1;
552
-
553
- SHA1.blockSize = 512;
554
- SHA1.outSize = 160;
555
- SHA1.hmacStrength = 80;
556
- SHA1.padLength = 64;
557
-
558
- SHA1.prototype._update = function _update(msg, start) {
559
- var W = this.W;
560
-
561
- for (var i = 0; i < 16; i++)
562
- W[i] = msg[start + i];
563
-
564
- for(; i < W.length; i++)
565
- W[i] = rotl32$1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1);
566
-
567
- var a = this.h[0];
568
- var b = this.h[1];
569
- var c = this.h[2];
570
- var d = this.h[3];
571
- var e = this.h[4];
572
-
573
- for (i = 0; i < W.length; i++) {
574
- var s = ~~(i / 20);
575
- var t = sum32_5$1(rotl32$1(a, 5), ft_1(s, b, c, d), e, W[i], sha1_K[s]);
576
- e = d;
577
- d = c;
578
- c = rotl32$1(b, 30);
579
- b = a;
580
- a = t;
581
- }
582
-
583
- this.h[0] = sum32$2(this.h[0], a);
584
- this.h[1] = sum32$2(this.h[1], b);
585
- this.h[2] = sum32$2(this.h[2], c);
586
- this.h[3] = sum32$2(this.h[3], d);
587
- this.h[4] = sum32$2(this.h[4], e);
588
- };
589
-
590
- SHA1.prototype._digest = function digest(enc) {
591
- if (enc === 'hex')
592
- return utils$6.toHex32(this.h, 'big');
593
- else
594
- return utils$6.split32(this.h, 'big');
595
- };
596
-
597
- var utils$5 = utils$9;
598
- var common$2 = common$5;
599
- var shaCommon = common$4;
600
- var assert$3 = minimalisticAssert;
601
-
602
- var sum32$1 = utils$5.sum32;
603
- var sum32_4$1 = utils$5.sum32_4;
604
- var sum32_5 = utils$5.sum32_5;
605
- var ch32 = shaCommon.ch32;
606
- var maj32 = shaCommon.maj32;
607
- var s0_256 = shaCommon.s0_256;
608
- var s1_256 = shaCommon.s1_256;
609
- var g0_256 = shaCommon.g0_256;
610
- var g1_256 = shaCommon.g1_256;
611
-
612
- var BlockHash$2 = common$2.BlockHash;
613
-
614
- var sha256_K = [
615
- 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
616
- 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
617
- 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
618
- 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
619
- 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
620
- 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
621
- 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
622
- 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
623
- 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
624
- 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
625
- 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
626
- 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
627
- 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
628
- 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
629
- 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
630
- 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
631
- ];
632
-
633
- function SHA256$1() {
634
- if (!(this instanceof SHA256$1))
635
- return new SHA256$1();
636
-
637
- BlockHash$2.call(this);
638
- this.h = [
639
- 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
640
- 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
641
- ];
642
- this.k = sha256_K;
643
- this.W = new Array(64);
644
- }
645
- utils$5.inherits(SHA256$1, BlockHash$2);
646
- var _256 = SHA256$1;
647
-
648
- SHA256$1.blockSize = 512;
649
- SHA256$1.outSize = 256;
650
- SHA256$1.hmacStrength = 192;
651
- SHA256$1.padLength = 64;
652
-
653
- SHA256$1.prototype._update = function _update(msg, start) {
654
- var W = this.W;
655
-
656
- for (var i = 0; i < 16; i++)
657
- W[i] = msg[start + i];
658
- for (; i < W.length; i++)
659
- W[i] = sum32_4$1(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]);
660
-
661
- var a = this.h[0];
662
- var b = this.h[1];
663
- var c = this.h[2];
664
- var d = this.h[3];
665
- var e = this.h[4];
666
- var f = this.h[5];
667
- var g = this.h[6];
668
- var h = this.h[7];
669
-
670
- assert$3(this.k.length === W.length);
671
- for (i = 0; i < W.length; i++) {
672
- var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]);
673
- var T2 = sum32$1(s0_256(a), maj32(a, b, c));
674
- h = g;
675
- g = f;
676
- f = e;
677
- e = sum32$1(d, T1);
678
- d = c;
679
- c = b;
680
- b = a;
681
- a = sum32$1(T1, T2);
682
- }
683
-
684
- this.h[0] = sum32$1(this.h[0], a);
685
- this.h[1] = sum32$1(this.h[1], b);
686
- this.h[2] = sum32$1(this.h[2], c);
687
- this.h[3] = sum32$1(this.h[3], d);
688
- this.h[4] = sum32$1(this.h[4], e);
689
- this.h[5] = sum32$1(this.h[5], f);
690
- this.h[6] = sum32$1(this.h[6], g);
691
- this.h[7] = sum32$1(this.h[7], h);
692
- };
693
-
694
- SHA256$1.prototype._digest = function digest(enc) {
695
- if (enc === 'hex')
696
- return utils$5.toHex32(this.h, 'big');
697
- else
698
- return utils$5.split32(this.h, 'big');
699
- };
700
-
701
- var utils$4 = utils$9;
702
- var SHA256 = _256;
703
-
704
- function SHA224() {
705
- if (!(this instanceof SHA224))
706
- return new SHA224();
707
-
708
- SHA256.call(this);
709
- this.h = [
710
- 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
711
- 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 ];
712
- }
713
- utils$4.inherits(SHA224, SHA256);
714
- var _224 = SHA224;
715
-
716
- SHA224.blockSize = 512;
717
- SHA224.outSize = 224;
718
- SHA224.hmacStrength = 192;
719
- SHA224.padLength = 64;
720
-
721
- SHA224.prototype._digest = function digest(enc) {
722
- // Just truncate output
723
- if (enc === 'hex')
724
- return utils$4.toHex32(this.h.slice(0, 7), 'big');
725
- else
726
- return utils$4.split32(this.h.slice(0, 7), 'big');
727
- };
728
-
729
- var utils$3 = utils$9;
730
- var common$1 = common$5;
731
- var assert$2 = minimalisticAssert;
732
-
733
- var rotr64_hi = utils$3.rotr64_hi;
734
- var rotr64_lo = utils$3.rotr64_lo;
735
- var shr64_hi = utils$3.shr64_hi;
736
- var shr64_lo = utils$3.shr64_lo;
737
- var sum64 = utils$3.sum64;
738
- var sum64_hi = utils$3.sum64_hi;
739
- var sum64_lo = utils$3.sum64_lo;
740
- var sum64_4_hi = utils$3.sum64_4_hi;
741
- var sum64_4_lo = utils$3.sum64_4_lo;
742
- var sum64_5_hi = utils$3.sum64_5_hi;
743
- var sum64_5_lo = utils$3.sum64_5_lo;
744
-
745
- var BlockHash$1 = common$1.BlockHash;
746
-
747
- var sha512_K = [
748
- 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
749
- 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
750
- 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
751
- 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
752
- 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
753
- 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
754
- 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
755
- 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
756
- 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
757
- 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
758
- 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
759
- 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
760
- 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
761
- 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
762
- 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
763
- 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
764
- 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
765
- 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
766
- 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
767
- 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
768
- 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
769
- 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
770
- 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
771
- 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
772
- 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
773
- 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
774
- 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
775
- 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
776
- 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
777
- 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
778
- 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
779
- 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
780
- 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
781
- 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
782
- 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
783
- 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
784
- 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
785
- 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
786
- 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
787
- 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
788
- ];
789
-
790
- function SHA512$1() {
791
- if (!(this instanceof SHA512$1))
792
- return new SHA512$1();
793
-
794
- BlockHash$1.call(this);
795
- this.h = [
796
- 0x6a09e667, 0xf3bcc908,
797
- 0xbb67ae85, 0x84caa73b,
798
- 0x3c6ef372, 0xfe94f82b,
799
- 0xa54ff53a, 0x5f1d36f1,
800
- 0x510e527f, 0xade682d1,
801
- 0x9b05688c, 0x2b3e6c1f,
802
- 0x1f83d9ab, 0xfb41bd6b,
803
- 0x5be0cd19, 0x137e2179 ];
804
- this.k = sha512_K;
805
- this.W = new Array(160);
806
- }
807
- utils$3.inherits(SHA512$1, BlockHash$1);
808
- var _512 = SHA512$1;
809
-
810
- SHA512$1.blockSize = 1024;
811
- SHA512$1.outSize = 512;
812
- SHA512$1.hmacStrength = 192;
813
- SHA512$1.padLength = 128;
814
-
815
- SHA512$1.prototype._prepareBlock = function _prepareBlock(msg, start) {
816
- var W = this.W;
817
-
818
- // 32 x 32bit words
819
- for (var i = 0; i < 32; i++)
820
- W[i] = msg[start + i];
821
- for (; i < W.length; i += 2) {
822
- var c0_hi = g1_512_hi(W[i - 4], W[i - 3]); // i - 2
823
- var c0_lo = g1_512_lo(W[i - 4], W[i - 3]);
824
- var c1_hi = W[i - 14]; // i - 7
825
- var c1_lo = W[i - 13];
826
- var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); // i - 15
827
- var c2_lo = g0_512_lo(W[i - 30], W[i - 29]);
828
- var c3_hi = W[i - 32]; // i - 16
829
- var c3_lo = W[i - 31];
830
-
831
- W[i] = sum64_4_hi(
832
- c0_hi, c0_lo,
833
- c1_hi, c1_lo,
834
- c2_hi, c2_lo,
835
- c3_hi, c3_lo);
836
- W[i + 1] = sum64_4_lo(
837
- c0_hi, c0_lo,
838
- c1_hi, c1_lo,
839
- c2_hi, c2_lo,
840
- c3_hi, c3_lo);
89
+ return buffer.Buffer.from(arr);
841
90
  }
842
91
  };
843
92
 
844
- SHA512$1.prototype._update = function _update(msg, start) {
845
- this._prepareBlock(msg, start);
846
-
847
- var W = this.W;
848
-
849
- var ah = this.h[0];
850
- var al = this.h[1];
851
- var bh = this.h[2];
852
- var bl = this.h[3];
853
- var ch = this.h[4];
854
- var cl = this.h[5];
855
- var dh = this.h[6];
856
- var dl = this.h[7];
857
- var eh = this.h[8];
858
- var el = this.h[9];
859
- var fh = this.h[10];
860
- var fl = this.h[11];
861
- var gh = this.h[12];
862
- var gl = this.h[13];
863
- var hh = this.h[14];
864
- var hl = this.h[15];
865
-
866
- assert$2(this.k.length === W.length);
867
- for (var i = 0; i < W.length; i += 2) {
868
- var c0_hi = hh;
869
- var c0_lo = hl;
870
- var c1_hi = s1_512_hi(eh, el);
871
- var c1_lo = s1_512_lo(eh, el);
872
- var c2_hi = ch64_hi(eh, el, fh, fl, gh);
873
- var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl);
874
- var c3_hi = this.k[i];
875
- var c3_lo = this.k[i + 1];
876
- var c4_hi = W[i];
877
- var c4_lo = W[i + 1];
878
-
879
- var T1_hi = sum64_5_hi(
880
- c0_hi, c0_lo,
881
- c1_hi, c1_lo,
882
- c2_hi, c2_lo,
883
- c3_hi, c3_lo,
884
- c4_hi, c4_lo);
885
- var T1_lo = sum64_5_lo(
886
- c0_hi, c0_lo,
887
- c1_hi, c1_lo,
888
- c2_hi, c2_lo,
889
- c3_hi, c3_lo,
890
- c4_hi, c4_lo);
891
-
892
- c0_hi = s0_512_hi(ah, al);
893
- c0_lo = s0_512_lo(ah, al);
894
- c1_hi = maj64_hi(ah, al, bh, bl, ch);
895
- c1_lo = maj64_lo(ah, al, bh, bl, ch, cl);
896
-
897
- var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo);
898
- var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo);
899
-
900
- hh = gh;
901
- hl = gl;
902
-
903
- gh = fh;
904
- gl = fl;
905
-
906
- fh = eh;
907
- fl = el;
908
-
909
- eh = sum64_hi(dh, dl, T1_hi, T1_lo);
910
- el = sum64_lo(dl, dl, T1_hi, T1_lo);
911
-
912
- dh = ch;
913
- dl = cl;
914
-
915
- ch = bh;
916
- cl = bl;
917
-
918
- bh = ah;
919
- bl = al;
920
-
921
- ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo);
922
- al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo);
923
- }
924
-
925
- sum64(this.h, 0, ah, al);
926
- sum64(this.h, 2, bh, bl);
927
- sum64(this.h, 4, ch, cl);
928
- sum64(this.h, 6, dh, dl);
929
- sum64(this.h, 8, eh, el);
930
- sum64(this.h, 10, fh, fl);
931
- sum64(this.h, 12, gh, gl);
932
- sum64(this.h, 14, hh, hl);
933
- };
934
-
935
- SHA512$1.prototype._digest = function digest(enc) {
936
- if (enc === 'hex')
937
- return utils$3.toHex32(this.h, 'big');
938
- else
939
- return utils$3.split32(this.h, 'big');
940
- };
941
-
942
- function ch64_hi(xh, xl, yh, yl, zh) {
943
- var r = (xh & yh) ^ ((~xh) & zh);
944
- if (r < 0)
945
- r += 0x100000000;
946
- return r;
947
- }
948
-
949
- function ch64_lo(xh, xl, yh, yl, zh, zl) {
950
- var r = (xl & yl) ^ ((~xl) & zl);
951
- if (r < 0)
952
- r += 0x100000000;
953
- return r;
954
- }
955
-
956
- function maj64_hi(xh, xl, yh, yl, zh) {
957
- var r = (xh & yh) ^ (xh & zh) ^ (yh & zh);
958
- if (r < 0)
959
- r += 0x100000000;
960
- return r;
961
- }
962
-
963
- function maj64_lo(xh, xl, yh, yl, zh, zl) {
964
- var r = (xl & yl) ^ (xl & zl) ^ (yl & zl);
965
- if (r < 0)
966
- r += 0x100000000;
967
- return r;
968
- }
969
-
970
- function s0_512_hi(xh, xl) {
971
- var c0_hi = rotr64_hi(xh, xl, 28);
972
- var c1_hi = rotr64_hi(xl, xh, 2); // 34
973
- var c2_hi = rotr64_hi(xl, xh, 7); // 39
974
-
975
- var r = c0_hi ^ c1_hi ^ c2_hi;
976
- if (r < 0)
977
- r += 0x100000000;
978
- return r;
979
- }
980
-
981
- function s0_512_lo(xh, xl) {
982
- var c0_lo = rotr64_lo(xh, xl, 28);
983
- var c1_lo = rotr64_lo(xl, xh, 2); // 34
984
- var c2_lo = rotr64_lo(xl, xh, 7); // 39
985
-
986
- var r = c0_lo ^ c1_lo ^ c2_lo;
987
- if (r < 0)
988
- r += 0x100000000;
989
- return r;
990
- }
991
-
992
- function s1_512_hi(xh, xl) {
993
- var c0_hi = rotr64_hi(xh, xl, 14);
994
- var c1_hi = rotr64_hi(xh, xl, 18);
995
- var c2_hi = rotr64_hi(xl, xh, 9); // 41
996
-
997
- var r = c0_hi ^ c1_hi ^ c2_hi;
998
- if (r < 0)
999
- r += 0x100000000;
1000
- return r;
1001
- }
1002
-
1003
- function s1_512_lo(xh, xl) {
1004
- var c0_lo = rotr64_lo(xh, xl, 14);
1005
- var c1_lo = rotr64_lo(xh, xl, 18);
1006
- var c2_lo = rotr64_lo(xl, xh, 9); // 41
1007
-
1008
- var r = c0_lo ^ c1_lo ^ c2_lo;
1009
- if (r < 0)
1010
- r += 0x100000000;
1011
- return r;
1012
- }
1013
-
1014
- function g0_512_hi(xh, xl) {
1015
- var c0_hi = rotr64_hi(xh, xl, 1);
1016
- var c1_hi = rotr64_hi(xh, xl, 8);
1017
- var c2_hi = shr64_hi(xh, xl, 7);
1018
-
1019
- var r = c0_hi ^ c1_hi ^ c2_hi;
1020
- if (r < 0)
1021
- r += 0x100000000;
1022
- return r;
1023
- }
1024
-
1025
- function g0_512_lo(xh, xl) {
1026
- var c0_lo = rotr64_lo(xh, xl, 1);
1027
- var c1_lo = rotr64_lo(xh, xl, 8);
1028
- var c2_lo = shr64_lo(xh, xl, 7);
1029
-
1030
- var r = c0_lo ^ c1_lo ^ c2_lo;
1031
- if (r < 0)
1032
- r += 0x100000000;
1033
- return r;
1034
- }
1035
-
1036
- function g1_512_hi(xh, xl) {
1037
- var c0_hi = rotr64_hi(xh, xl, 19);
1038
- var c1_hi = rotr64_hi(xl, xh, 29); // 61
1039
- var c2_hi = shr64_hi(xh, xl, 6);
1040
-
1041
- var r = c0_hi ^ c1_hi ^ c2_hi;
1042
- if (r < 0)
1043
- r += 0x100000000;
1044
- return r;
1045
- }
1046
-
1047
- function g1_512_lo(xh, xl) {
1048
- var c0_lo = rotr64_lo(xh, xl, 19);
1049
- var c1_lo = rotr64_lo(xl, xh, 29); // 61
1050
- var c2_lo = shr64_lo(xh, xl, 6);
1051
-
1052
- var r = c0_lo ^ c1_lo ^ c2_lo;
1053
- if (r < 0)
1054
- r += 0x100000000;
1055
- return r;
1056
- }
1057
-
1058
- var utils$2 = utils$9;
1059
-
1060
- var SHA512 = _512;
1061
-
1062
- function SHA384() {
1063
- if (!(this instanceof SHA384))
1064
- return new SHA384();
1065
-
1066
- SHA512.call(this);
1067
- this.h = [
1068
- 0xcbbb9d5d, 0xc1059ed8,
1069
- 0x629a292a, 0x367cd507,
1070
- 0x9159015a, 0x3070dd17,
1071
- 0x152fecd8, 0xf70e5939,
1072
- 0x67332667, 0xffc00b31,
1073
- 0x8eb44a87, 0x68581511,
1074
- 0xdb0c2e0d, 0x64f98fa7,
1075
- 0x47b5481d, 0xbefa4fa4 ];
1076
- }
1077
- utils$2.inherits(SHA384, SHA512);
1078
- var _384 = SHA384;
1079
-
1080
- SHA384.blockSize = 1024;
1081
- SHA384.outSize = 384;
1082
- SHA384.hmacStrength = 192;
1083
- SHA384.padLength = 128;
1084
-
1085
- SHA384.prototype._digest = function digest(enc) {
1086
- if (enc === 'hex')
1087
- return utils$2.toHex32(this.h.slice(0, 12), 'big');
1088
- else
1089
- return utils$2.split32(this.h.slice(0, 12), 'big');
1090
- };
1091
-
1092
- sha.sha1 = _1;
1093
- sha.sha224 = _224;
1094
- sha.sha256 = _256;
1095
- sha.sha384 = _384;
1096
- sha.sha512 = _512;
1097
-
1098
- var ripemd = {};
1099
-
1100
- var utils$1 = utils$9;
1101
- var common = common$5;
1102
-
1103
- var rotl32 = utils$1.rotl32;
1104
- var sum32 = utils$1.sum32;
1105
- var sum32_3 = utils$1.sum32_3;
1106
- var sum32_4 = utils$1.sum32_4;
1107
- var BlockHash = common.BlockHash;
1108
-
1109
- function RIPEMD160() {
1110
- if (!(this instanceof RIPEMD160))
1111
- return new RIPEMD160();
1112
-
1113
- BlockHash.call(this);
1114
-
1115
- this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ];
1116
- this.endian = 'little';
1117
- }
1118
- utils$1.inherits(RIPEMD160, BlockHash);
1119
- ripemd.ripemd160 = RIPEMD160;
1120
-
1121
- RIPEMD160.blockSize = 512;
1122
- RIPEMD160.outSize = 160;
1123
- RIPEMD160.hmacStrength = 192;
1124
- RIPEMD160.padLength = 64;
1125
-
1126
- RIPEMD160.prototype._update = function update(msg, start) {
1127
- var A = this.h[0];
1128
- var B = this.h[1];
1129
- var C = this.h[2];
1130
- var D = this.h[3];
1131
- var E = this.h[4];
1132
- var Ah = A;
1133
- var Bh = B;
1134
- var Ch = C;
1135
- var Dh = D;
1136
- var Eh = E;
1137
- for (var j = 0; j < 80; j++) {
1138
- var T = sum32(
1139
- rotl32(
1140
- sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)),
1141
- s[j]),
1142
- E);
1143
- A = E;
1144
- E = D;
1145
- D = rotl32(C, 10);
1146
- C = B;
1147
- B = T;
1148
- T = sum32(
1149
- rotl32(
1150
- sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)),
1151
- sh[j]),
1152
- Eh);
1153
- Ah = Eh;
1154
- Eh = Dh;
1155
- Dh = rotl32(Ch, 10);
1156
- Ch = Bh;
1157
- Bh = T;
1158
- }
1159
- T = sum32_3(this.h[1], C, Dh);
1160
- this.h[1] = sum32_3(this.h[2], D, Eh);
1161
- this.h[2] = sum32_3(this.h[3], E, Ah);
1162
- this.h[3] = sum32_3(this.h[4], A, Bh);
1163
- this.h[4] = sum32_3(this.h[0], B, Ch);
1164
- this.h[0] = T;
1165
- };
1166
-
1167
- RIPEMD160.prototype._digest = function digest(enc) {
1168
- if (enc === 'hex')
1169
- return utils$1.toHex32(this.h, 'little');
1170
- else
1171
- return utils$1.split32(this.h, 'little');
1172
- };
1173
-
1174
- function f(j, x, y, z) {
1175
- if (j <= 15)
1176
- return x ^ y ^ z;
1177
- else if (j <= 31)
1178
- return (x & y) | ((~x) & z);
1179
- else if (j <= 47)
1180
- return (x | (~y)) ^ z;
1181
- else if (j <= 63)
1182
- return (x & z) | (y & (~z));
1183
- else
1184
- return x ^ (y | (~z));
1185
- }
1186
-
1187
- function K(j) {
1188
- if (j <= 15)
1189
- return 0x00000000;
1190
- else if (j <= 31)
1191
- return 0x5a827999;
1192
- else if (j <= 47)
1193
- return 0x6ed9eba1;
1194
- else if (j <= 63)
1195
- return 0x8f1bbcdc;
1196
- else
1197
- return 0xa953fd4e;
1198
- }
1199
-
1200
- function Kh(j) {
1201
- if (j <= 15)
1202
- return 0x50a28be6;
1203
- else if (j <= 31)
1204
- return 0x5c4dd124;
1205
- else if (j <= 47)
1206
- return 0x6d703ef3;
1207
- else if (j <= 63)
1208
- return 0x7a6d76e9;
1209
- else
1210
- return 0x00000000;
1211
- }
1212
-
1213
- var r = [
1214
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
1215
- 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
1216
- 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
1217
- 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
1218
- 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
1219
- ];
1220
-
1221
- var rh = [
1222
- 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
1223
- 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
1224
- 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
1225
- 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
1226
- 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
1227
- ];
1228
-
1229
- var s = [
1230
- 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
1231
- 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
1232
- 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
1233
- 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
1234
- 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
1235
- ];
1236
-
1237
- var sh = [
1238
- 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
1239
- 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
1240
- 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
1241
- 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
1242
- 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
1243
- ];
1244
-
1245
- var utils = utils$9;
1246
- var assert$1 = minimalisticAssert;
1247
-
1248
- function Hmac(hash, key, enc) {
1249
- if (!(this instanceof Hmac))
1250
- return new Hmac(hash, key, enc);
1251
- this.Hash = hash;
1252
- this.blockSize = hash.blockSize / 8;
1253
- this.outSize = hash.outSize / 8;
1254
- this.inner = null;
1255
- this.outer = null;
1256
-
1257
- this._init(utils.toArray(key, enc));
1258
- }
1259
- var hmac = Hmac;
1260
-
1261
- Hmac.prototype._init = function init(key) {
1262
- // Shorten key, if needed
1263
- if (key.length > this.blockSize)
1264
- key = new this.Hash().update(key).digest();
1265
- assert$1(key.length <= this.blockSize);
1266
-
1267
- // Add padding to key
1268
- for (var i = key.length; i < this.blockSize; i++)
1269
- key.push(0);
1270
-
1271
- for (i = 0; i < key.length; i++)
1272
- key[i] ^= 0x36;
1273
- this.inner = new this.Hash().update(key);
1274
-
1275
- // 0x36 ^ 0x5c = 0x6a
1276
- for (i = 0; i < key.length; i++)
1277
- key[i] ^= 0x6a;
1278
- this.outer = new this.Hash().update(key);
1279
- };
1280
-
1281
- Hmac.prototype.update = function update(msg, enc) {
1282
- this.inner.update(msg, enc);
1283
- return this;
1284
- };
1285
-
1286
- Hmac.prototype.digest = function digest(enc) {
1287
- this.outer.update(this.inner.digest());
1288
- return this.outer.digest(enc);
1289
- };
1290
-
1291
- (function (exports) {
1292
- var hash = exports;
1293
-
1294
- hash.utils = utils$9;
1295
- hash.common = common$5;
1296
- hash.sha = sha;
1297
- hash.ripemd = ripemd;
1298
- hash.hmac = hmac;
1299
-
1300
- // Proxy hash functions to the main object
1301
- hash.sha1 = hash.sha.sha1;
1302
- hash.sha256 = hash.sha.sha256;
1303
- hash.sha224 = hash.sha.sha224;
1304
- hash.sha384 = hash.sha.sha384;
1305
- hash.sha512 = hash.sha.sha512;
1306
- hash.ripemd160 = hash.ripemd.ripemd160;
1307
- } (hash$1));
1308
-
1309
- var hash = hash$1;
1310
-
1311
- const version$2 = "logger/5.6.0";
1312
-
1313
- let _permanentCensorErrors = false;
1314
- let _censorErrors = false;
1315
- const LogLevels = { debug: 1, "default": 2, info: 2, warning: 3, error: 4, off: 5 };
1316
- let _logLevel = LogLevels["default"];
1317
- let _globalLogger = null;
1318
- function _checkNormalize() {
1319
- try {
1320
- const missing = [];
1321
- // Make sure all forms of normalization are supported
1322
- ["NFD", "NFC", "NFKD", "NFKC"].forEach((form) => {
1323
- try {
1324
- if ("test".normalize(form) !== "test") {
1325
- throw new Error("bad normalize");
1326
- }
1327
- ;
1328
- }
1329
- catch (error) {
1330
- missing.push(form);
1331
- }
1332
- });
1333
- if (missing.length) {
1334
- throw new Error("missing " + missing.join(", "));
1335
- }
1336
- if (String.fromCharCode(0xe9).normalize("NFD") !== String.fromCharCode(0x65, 0x0301)) {
1337
- throw new Error("broken implementation");
1338
- }
1339
- }
1340
- catch (error) {
1341
- return error.message;
1342
- }
1343
- return null;
1344
- }
1345
- const _normalizeError = _checkNormalize();
1346
- var LogLevel;
1347
- (function (LogLevel) {
1348
- LogLevel["DEBUG"] = "DEBUG";
1349
- LogLevel["INFO"] = "INFO";
1350
- LogLevel["WARNING"] = "WARNING";
1351
- LogLevel["ERROR"] = "ERROR";
1352
- LogLevel["OFF"] = "OFF";
1353
- })(LogLevel || (LogLevel = {}));
1354
- var ErrorCode;
1355
- (function (ErrorCode) {
1356
- ///////////////////
1357
- // Generic Errors
1358
- // Unknown Error
1359
- ErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
1360
- // Not Implemented
1361
- ErrorCode["NOT_IMPLEMENTED"] = "NOT_IMPLEMENTED";
1362
- // Unsupported Operation
1363
- // - operation
1364
- ErrorCode["UNSUPPORTED_OPERATION"] = "UNSUPPORTED_OPERATION";
1365
- // Network Error (i.e. Ethereum Network, such as an invalid chain ID)
1366
- // - event ("noNetwork" is not re-thrown in provider.ready; otherwise thrown)
1367
- ErrorCode["NETWORK_ERROR"] = "NETWORK_ERROR";
1368
- // Some sort of bad response from the server
1369
- ErrorCode["SERVER_ERROR"] = "SERVER_ERROR";
1370
- // Timeout
1371
- ErrorCode["TIMEOUT"] = "TIMEOUT";
1372
- ///////////////////
1373
- // Operational Errors
1374
- // Buffer Overrun
1375
- ErrorCode["BUFFER_OVERRUN"] = "BUFFER_OVERRUN";
1376
- // Numeric Fault
1377
- // - operation: the operation being executed
1378
- // - fault: the reason this faulted
1379
- ErrorCode["NUMERIC_FAULT"] = "NUMERIC_FAULT";
1380
- ///////////////////
1381
- // Argument Errors
1382
- // Missing new operator to an object
1383
- // - name: The name of the class
1384
- ErrorCode["MISSING_NEW"] = "MISSING_NEW";
1385
- // Invalid argument (e.g. value is incompatible with type) to a function:
1386
- // - argument: The argument name that was invalid
1387
- // - value: The value of the argument
1388
- ErrorCode["INVALID_ARGUMENT"] = "INVALID_ARGUMENT";
1389
- // Missing argument to a function:
1390
- // - count: The number of arguments received
1391
- // - expectedCount: The number of arguments expected
1392
- ErrorCode["MISSING_ARGUMENT"] = "MISSING_ARGUMENT";
1393
- // Too many arguments
1394
- // - count: The number of arguments received
1395
- // - expectedCount: The number of arguments expected
1396
- ErrorCode["UNEXPECTED_ARGUMENT"] = "UNEXPECTED_ARGUMENT";
1397
- ///////////////////
1398
- // Blockchain Errors
1399
- // Call exception
1400
- // - transaction: the transaction
1401
- // - address?: the contract address
1402
- // - args?: The arguments passed into the function
1403
- // - method?: The Solidity method signature
1404
- // - errorSignature?: The EIP848 error signature
1405
- // - errorArgs?: The EIP848 error parameters
1406
- // - reason: The reason (only for EIP848 "Error(string)")
1407
- ErrorCode["CALL_EXCEPTION"] = "CALL_EXCEPTION";
1408
- // Insufficient funds (< value + gasLimit * gasPrice)
1409
- // - transaction: the transaction attempted
1410
- ErrorCode["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS";
1411
- // Nonce has already been used
1412
- // - transaction: the transaction attempted
1413
- ErrorCode["NONCE_EXPIRED"] = "NONCE_EXPIRED";
1414
- // The replacement fee for the transaction is too low
1415
- // - transaction: the transaction attempted
1416
- ErrorCode["REPLACEMENT_UNDERPRICED"] = "REPLACEMENT_UNDERPRICED";
1417
- // The gas limit could not be estimated
1418
- // - transaction: the transaction passed to estimateGas
1419
- ErrorCode["UNPREDICTABLE_GAS_LIMIT"] = "UNPREDICTABLE_GAS_LIMIT";
1420
- // The transaction was replaced by one with a higher gas price
1421
- // - reason: "cancelled", "replaced" or "repriced"
1422
- // - cancelled: true if reason == "cancelled" or reason == "replaced")
1423
- // - hash: original transaction hash
1424
- // - replacement: the full TransactionsResponse for the replacement
1425
- // - receipt: the receipt of the replacement
1426
- ErrorCode["TRANSACTION_REPLACED"] = "TRANSACTION_REPLACED";
1427
- })(ErrorCode || (ErrorCode = {}));
1428
- const HEX = "0123456789abcdef";
1429
- class Logger {
1430
- constructor(version) {
1431
- Object.defineProperty(this, "version", {
1432
- enumerable: true,
1433
- value: version,
1434
- writable: false
1435
- });
1436
- }
1437
- _log(logLevel, args) {
1438
- const level = logLevel.toLowerCase();
1439
- if (LogLevels[level] == null) {
1440
- this.throwArgumentError("invalid log level name", "logLevel", logLevel);
1441
- }
1442
- if (_logLevel > LogLevels[level]) {
1443
- return;
1444
- }
1445
- console.log.apply(console, args);
1446
- }
1447
- debug(...args) {
1448
- this._log(Logger.levels.DEBUG, args);
1449
- }
1450
- info(...args) {
1451
- this._log(Logger.levels.INFO, args);
1452
- }
1453
- warn(...args) {
1454
- this._log(Logger.levels.WARNING, args);
1455
- }
1456
- makeError(message, code, params) {
1457
- // Errors are being censored
1458
- if (_censorErrors) {
1459
- return this.makeError("censored error", code, {});
1460
- }
1461
- if (!code) {
1462
- code = Logger.errors.UNKNOWN_ERROR;
1463
- }
1464
- if (!params) {
1465
- params = {};
1466
- }
1467
- const messageDetails = [];
1468
- Object.keys(params).forEach((key) => {
1469
- const value = params[key];
1470
- try {
1471
- if (value instanceof Uint8Array) {
1472
- let hex = "";
1473
- for (let i = 0; i < value.length; i++) {
1474
- hex += HEX[value[i] >> 4];
1475
- hex += HEX[value[i] & 0x0f];
1476
- }
1477
- messageDetails.push(key + "=Uint8Array(0x" + hex + ")");
1478
- }
1479
- else {
1480
- messageDetails.push(key + "=" + JSON.stringify(value));
1481
- }
1482
- }
1483
- catch (error) {
1484
- messageDetails.push(key + "=" + JSON.stringify(params[key].toString()));
1485
- }
1486
- });
1487
- messageDetails.push(`code=${code}`);
1488
- messageDetails.push(`version=${this.version}`);
1489
- const reason = message;
1490
- let url = "";
1491
- switch (code) {
1492
- case ErrorCode.NUMERIC_FAULT: {
1493
- url = "NUMERIC_FAULT";
1494
- const fault = message;
1495
- switch (fault) {
1496
- case "overflow":
1497
- case "underflow":
1498
- case "division-by-zero":
1499
- url += "-" + fault;
1500
- break;
1501
- case "negative-power":
1502
- case "negative-width":
1503
- url += "-unsupported";
1504
- break;
1505
- case "unbound-bitwise-result":
1506
- url += "-unbound-result";
1507
- break;
1508
- }
1509
- break;
1510
- }
1511
- case ErrorCode.CALL_EXCEPTION:
1512
- case ErrorCode.INSUFFICIENT_FUNDS:
1513
- case ErrorCode.MISSING_NEW:
1514
- case ErrorCode.NONCE_EXPIRED:
1515
- case ErrorCode.REPLACEMENT_UNDERPRICED:
1516
- case ErrorCode.TRANSACTION_REPLACED:
1517
- case ErrorCode.UNPREDICTABLE_GAS_LIMIT:
1518
- url = code;
1519
- break;
1520
- }
1521
- if (url) {
1522
- message += " [ See: https:/\/links.ethers.org/v5-errors-" + url + " ]";
1523
- }
1524
- if (messageDetails.length) {
1525
- message += " (" + messageDetails.join(", ") + ")";
1526
- }
1527
- // @TODO: Any??
1528
- const error = new Error(message);
1529
- error.reason = reason;
1530
- error.code = code;
1531
- Object.keys(params).forEach(function (key) {
1532
- error[key] = params[key];
1533
- });
1534
- return error;
1535
- }
1536
- throwError(message, code, params) {
1537
- throw this.makeError(message, code, params);
1538
- }
1539
- throwArgumentError(message, name, value) {
1540
- return this.throwError(message, Logger.errors.INVALID_ARGUMENT, {
1541
- argument: name,
1542
- value: value
1543
- });
1544
- }
1545
- assert(condition, message, code, params) {
1546
- if (!!condition) {
1547
- return;
1548
- }
1549
- this.throwError(message, code, params);
1550
- }
1551
- assertArgument(condition, message, name, value) {
1552
- if (!!condition) {
1553
- return;
1554
- }
1555
- this.throwArgumentError(message, name, value);
1556
- }
1557
- checkNormalize(message) {
1558
- if (_normalizeError) {
1559
- this.throwError("platform missing String.prototype.normalize", Logger.errors.UNSUPPORTED_OPERATION, {
1560
- operation: "String.prototype.normalize", form: _normalizeError
1561
- });
1562
- }
1563
- }
1564
- checkSafeUint53(value, message) {
1565
- if (typeof (value) !== "number") {
1566
- return;
1567
- }
1568
- if (message == null) {
1569
- message = "value not safe";
1570
- }
1571
- if (value < 0 || value >= 0x1fffffffffffff) {
1572
- this.throwError(message, Logger.errors.NUMERIC_FAULT, {
1573
- operation: "checkSafeInteger",
1574
- fault: "out-of-safe-range",
1575
- value: value
1576
- });
1577
- }
1578
- if (value % 1) {
1579
- this.throwError(message, Logger.errors.NUMERIC_FAULT, {
1580
- operation: "checkSafeInteger",
1581
- fault: "non-integer",
1582
- value: value
1583
- });
1584
- }
1585
- }
1586
- checkArgumentCount(count, expectedCount, message) {
1587
- if (message) {
1588
- message = ": " + message;
1589
- }
1590
- else {
1591
- message = "";
1592
- }
1593
- if (count < expectedCount) {
1594
- this.throwError("missing argument" + message, Logger.errors.MISSING_ARGUMENT, {
1595
- count: count,
1596
- expectedCount: expectedCount
1597
- });
1598
- }
1599
- if (count > expectedCount) {
1600
- this.throwError("too many arguments" + message, Logger.errors.UNEXPECTED_ARGUMENT, {
1601
- count: count,
1602
- expectedCount: expectedCount
1603
- });
1604
- }
1605
- }
1606
- checkNew(target, kind) {
1607
- if (target === Object || target == null) {
1608
- this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
1609
- }
1610
- }
1611
- checkAbstract(target, kind) {
1612
- if (target === kind) {
1613
- this.throwError("cannot instantiate abstract class " + JSON.stringify(kind.name) + " directly; use a sub-class", Logger.errors.UNSUPPORTED_OPERATION, { name: target.name, operation: "new" });
1614
- }
1615
- else if (target === Object || target == null) {
1616
- this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
1617
- }
1618
- }
1619
- static globalLogger() {
1620
- if (!_globalLogger) {
1621
- _globalLogger = new Logger(version$2);
1622
- }
1623
- return _globalLogger;
1624
- }
1625
- static setCensorship(censorship, permanent) {
1626
- if (!censorship && permanent) {
1627
- this.globalLogger().throwError("cannot permanently disable censorship", Logger.errors.UNSUPPORTED_OPERATION, {
1628
- operation: "setCensorship"
1629
- });
1630
- }
1631
- if (_permanentCensorErrors) {
1632
- if (!censorship) {
1633
- return;
1634
- }
1635
- this.globalLogger().throwError("error censorship permanent", Logger.errors.UNSUPPORTED_OPERATION, {
1636
- operation: "setCensorship"
1637
- });
1638
- }
1639
- _censorErrors = !!censorship;
1640
- _permanentCensorErrors = !!permanent;
1641
- }
1642
- static setLogLevel(logLevel) {
1643
- const level = LogLevels[logLevel.toLowerCase()];
1644
- if (level == null) {
1645
- Logger.globalLogger().warn("invalid log level - " + logLevel);
1646
- return;
1647
- }
1648
- _logLevel = level;
1649
- }
1650
- static from(version) {
1651
- return new Logger(version);
1652
- }
1653
- }
1654
- Logger.errors = ErrorCode;
1655
- Logger.levels = LogLevel;
1656
-
1657
- const version$1 = "bytes/5.6.0";
1658
-
1659
- const logger = new Logger(version$1);
1660
- ///////////////////////////////
1661
- function isHexable(value) {
1662
- return !!(value.toHexString);
1663
- }
1664
- function addSlice(array) {
1665
- if (array.slice) {
1666
- return array;
1667
- }
1668
- array.slice = function () {
1669
- const args = Array.prototype.slice.call(arguments);
1670
- return addSlice(new Uint8Array(Array.prototype.slice.apply(array, args)));
1671
- };
1672
- return array;
1673
- }
1674
- function isInteger(value) {
1675
- return (typeof (value) === "number" && value == value && (value % 1) === 0);
1676
- }
1677
- function isBytes(value) {
1678
- if (value == null) {
1679
- return false;
1680
- }
1681
- if (value.constructor === Uint8Array) {
1682
- return true;
1683
- }
1684
- if (typeof (value) === "string") {
1685
- return false;
1686
- }
1687
- if (!isInteger(value.length) || value.length < 0) {
1688
- return false;
1689
- }
1690
- for (let i = 0; i < value.length; i++) {
1691
- const v = value[i];
1692
- if (!isInteger(v) || v < 0 || v >= 256) {
1693
- return false;
1694
- }
1695
- }
1696
- return true;
1697
- }
1698
- function arrayify(value, options) {
1699
- if (!options) {
1700
- options = {};
1701
- }
1702
- if (typeof (value) === "number") {
1703
- logger.checkSafeUint53(value, "invalid arrayify value");
1704
- const result = [];
1705
- while (value) {
1706
- result.unshift(value & 0xff);
1707
- value = parseInt(String(value / 256));
1708
- }
1709
- if (result.length === 0) {
1710
- result.push(0);
1711
- }
1712
- return addSlice(new Uint8Array(result));
1713
- }
1714
- if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") {
1715
- value = "0x" + value;
1716
- }
1717
- if (isHexable(value)) {
1718
- value = value.toHexString();
1719
- }
1720
- if (isHexString(value)) {
1721
- let hex = value.substring(2);
1722
- if (hex.length % 2) {
1723
- if (options.hexPad === "left") {
1724
- hex = "0x0" + hex.substring(2);
1725
- }
1726
- else if (options.hexPad === "right") {
1727
- hex += "0";
1728
- }
1729
- else {
1730
- logger.throwArgumentError("hex data is odd-length", "value", value);
1731
- }
1732
- }
1733
- const result = [];
1734
- for (let i = 0; i < hex.length; i += 2) {
1735
- result.push(parseInt(hex.substring(i, i + 2), 16));
1736
- }
1737
- return addSlice(new Uint8Array(result));
1738
- }
1739
- if (isBytes(value)) {
1740
- return addSlice(new Uint8Array(value));
1741
- }
1742
- return logger.throwArgumentError("invalid arrayify value", "value", value);
1743
- }
1744
- function isHexString(value, length) {
1745
- if (typeof (value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) {
1746
- return false;
1747
- }
1748
- if (length && value.length !== 2 + 2 * length) {
1749
- return false;
1750
- }
1751
- return true;
1752
- }
1753
-
1754
- const version = "sha2/5.6.0";
1755
-
1756
- new Logger(version);
1757
- function sha256(data) {
1758
- return "0x" + (hash.sha256().update(arrayify(data)).digest("hex"));
1759
- }
1760
-
1761
93
  class Struct {
1762
94
  constructor(properties) {
1763
95
  Object.assign(this, properties);
@@ -1915,8 +247,8 @@ class PublicKey extends Struct {
1915
247
 
1916
248
  static async createWithSeed(fromPublicKey, seed, programId) {
1917
249
  const buffer$1 = buffer.Buffer.concat([fromPublicKey.toBuffer(), buffer.Buffer.from(seed), programId.toBuffer()]);
1918
- const hash = sha256(new Uint8Array(buffer$1)).slice(2);
1919
- return new PublicKey(buffer.Buffer.from(hash, 'hex'));
250
+ const publicKeyBytes = sha256.sha256(buffer$1);
251
+ return new PublicKey(publicKeyBytes);
1920
252
  }
1921
253
  /**
1922
254
  * Derive a program address from seeds and a program ID.
@@ -1935,10 +267,9 @@ class PublicKey extends Struct {
1935
267
  buffer$1 = buffer.Buffer.concat([buffer$1, toBuffer(seed)]);
1936
268
  });
1937
269
  buffer$1 = buffer.Buffer.concat([buffer$1, programId.toBuffer(), buffer.Buffer.from('ProgramDerivedAddress')]);
1938
- let hash = sha256(new Uint8Array(buffer$1)).slice(2);
1939
- let publicKeyBytes = new BN__default["default"](hash, 16).toArray(undefined, 32);
270
+ const publicKeyBytes = sha256.sha256(buffer$1);
1940
271
 
1941
- if (is_on_curve(publicKeyBytes)) {
272
+ if (isOnCurve(publicKeyBytes)) {
1942
273
  throw new Error(`Invalid seeds, address must fall off the curve`);
1943
274
  }
1944
275
 
@@ -2002,7 +333,7 @@ class PublicKey extends Struct {
2002
333
 
2003
334
  static isOnCurve(pubkeyData) {
2004
335
  const pubkey = new PublicKey(pubkeyData);
2005
- return is_on_curve(pubkey.toBytes()) == 1;
336
+ return isOnCurve(pubkey.toBytes());
2006
337
  }
2007
338
 
2008
339
  }
@@ -2010,56 +341,7 @@ PublicKey.default = new PublicKey('11111111111111111111111111111111');
2010
341
  SOLANA_SCHEMA.set(PublicKey, {
2011
342
  kind: 'struct',
2012
343
  fields: [['_bn', 'u256']]
2013
- }); // @ts-ignore
2014
-
2015
- let naclLowLevel = nacl__default["default"].lowlevel; // Check that a pubkey is on the curve.
2016
- // This function and its dependents were sourced from:
2017
- // https://github.com/dchest/tweetnacl-js/blob/f1ec050ceae0861f34280e62498b1d3ed9c350c6/nacl.js#L792
2018
-
2019
- function is_on_curve(p) {
2020
- var r = [naclLowLevel.gf(), naclLowLevel.gf(), naclLowLevel.gf(), naclLowLevel.gf()];
2021
- var t = naclLowLevel.gf(),
2022
- chk = naclLowLevel.gf(),
2023
- num = naclLowLevel.gf(),
2024
- den = naclLowLevel.gf(),
2025
- den2 = naclLowLevel.gf(),
2026
- den4 = naclLowLevel.gf(),
2027
- den6 = naclLowLevel.gf();
2028
- naclLowLevel.set25519(r[2], gf1);
2029
- naclLowLevel.unpack25519(r[1], p);
2030
- naclLowLevel.S(num, r[1]);
2031
- naclLowLevel.M(den, num, naclLowLevel.D);
2032
- naclLowLevel.Z(num, num, r[2]);
2033
- naclLowLevel.A(den, r[2], den);
2034
- naclLowLevel.S(den2, den);
2035
- naclLowLevel.S(den4, den2);
2036
- naclLowLevel.M(den6, den4, den2);
2037
- naclLowLevel.M(t, den6, num);
2038
- naclLowLevel.M(t, t, den);
2039
- naclLowLevel.pow2523(t, t);
2040
- naclLowLevel.M(t, t, num);
2041
- naclLowLevel.M(t, t, den);
2042
- naclLowLevel.M(t, t, den);
2043
- naclLowLevel.M(r[0], t, den);
2044
- naclLowLevel.S(chk, r[0]);
2045
- naclLowLevel.M(chk, chk, den);
2046
- if (neq25519(chk, num)) naclLowLevel.M(r[0], r[0], I);
2047
- naclLowLevel.S(chk, r[0]);
2048
- naclLowLevel.M(chk, chk, den);
2049
- if (neq25519(chk, num)) return 0;
2050
- return 1;
2051
- }
2052
-
2053
- let gf1 = naclLowLevel.gf([1]);
2054
- let I = naclLowLevel.gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);
2055
-
2056
- function neq25519(a, b) {
2057
- var c = new Uint8Array(32),
2058
- d = new Uint8Array(32);
2059
- naclLowLevel.pack25519(c, a);
2060
- naclLowLevel.pack25519(d, b);
2061
- return naclLowLevel.crypto_verify_32(c, 0, d, 0);
2062
- }
344
+ });
2063
345
 
2064
346
  /**
2065
347
  * An account key pair (public and secret keys).
@@ -2070,6 +352,8 @@ function neq25519(a, b) {
2070
352
  class Account {
2071
353
  /** @internal */
2072
354
 
355
+ /** @internal */
356
+
2073
357
  /**
2074
358
  * Create a new Account object
2075
359
  *
@@ -2079,12 +363,21 @@ class Account {
2079
363
  * @param secretKey Secret key for the account
2080
364
  */
2081
365
  constructor(secretKey) {
2082
- this._keypair = void 0;
366
+ this._publicKey = void 0;
367
+ this._secretKey = void 0;
2083
368
 
2084
369
  if (secretKey) {
2085
- this._keypair = nacl__default["default"].sign.keyPair.fromSecretKey(toBuffer(secretKey));
370
+ const secretKeyBuffer = toBuffer(secretKey);
371
+
372
+ if (secretKey.length !== 64) {
373
+ throw new Error('bad secret key size');
374
+ }
375
+
376
+ this._publicKey = secretKeyBuffer.slice(32, 64);
377
+ this._secretKey = secretKeyBuffer.slice(0, 32);
2086
378
  } else {
2087
- this._keypair = nacl__default["default"].sign.keyPair();
379
+ this._secretKey = toBuffer(generatePrivateKey());
380
+ this._publicKey = toBuffer(getPublicKey(this._secretKey));
2088
381
  }
2089
382
  }
2090
383
  /**
@@ -2093,15 +386,17 @@ class Account {
2093
386
 
2094
387
 
2095
388
  get publicKey() {
2096
- return new PublicKey(this._keypair.publicKey);
389
+ return new PublicKey(this._publicKey);
2097
390
  }
2098
391
  /**
2099
- * The **unencrypted** secret key for this account
392
+ * The **unencrypted** secret key for this account. The first 32 bytes
393
+ * is the private scalar and the last 32 bytes is the public key.
394
+ * Read more: https://blog.mozilla.org/warner/2011/11/29/ed25519-keys/
2100
395
  */
2101
396
 
2102
397
 
2103
398
  get secretKey() {
2104
- return toBuffer(this._keypair.secretKey);
399
+ return buffer.Buffer.concat([this._secretKey, this._publicKey], 64);
2105
400
  }
2106
401
 
2107
402
  }
@@ -2595,16 +890,24 @@ class MessageV0 {
2595
890
 
2596
891
  // eslint-disable-next-line no-redeclare
2597
892
  const VersionedMessage = {
2598
- deserialize: serializedMessage => {
893
+ deserializeMessageVersion(serializedMessage) {
2599
894
  const prefix = serializedMessage[0];
2600
895
  const maskedPrefix = prefix & VERSION_PREFIX_MASK; // if the highest bit of the prefix is not set, the message is not versioned
2601
896
 
2602
897
  if (maskedPrefix === prefix) {
2603
- return Message.from(serializedMessage);
898
+ return 'legacy';
2604
899
  } // the lower 7 bits of the prefix indicate the message version
2605
900
 
2606
901
 
2607
- const version = maskedPrefix;
902
+ return maskedPrefix;
903
+ },
904
+
905
+ deserialize: serializedMessage => {
906
+ const version = VersionedMessage.deserializeMessageVersion(serializedMessage);
907
+
908
+ if (version === 'legacy') {
909
+ return Message.from(serializedMessage);
910
+ }
2608
911
 
2609
912
  if (version === 0) {
2610
913
  return MessageV0.deserialize(serializedMessage);
@@ -2614,6 +917,10 @@ const VersionedMessage = {
2614
917
  }
2615
918
  };
2616
919
 
920
+ /**
921
+ * Transaction signature as base-58 encoded string
922
+ */
923
+
2617
924
  exports.TransactionStatus = void 0;
2618
925
  /**
2619
926
  * Default (empty) signature
@@ -3139,7 +1446,7 @@ class Transaction {
3139
1446
  _partialSign(message, ...signers) {
3140
1447
  const signData = message.serialize();
3141
1448
  signers.forEach(signer => {
3142
- const signature = nacl__default["default"].sign.detached(signData, signer.secretKey);
1449
+ const signature = sign(signData, signer.secretKey);
3143
1450
 
3144
1451
  this._addSignature(signer.publicKey, toBuffer(signature));
3145
1452
  });
@@ -3195,7 +1502,7 @@ class Transaction {
3195
1502
  return false;
3196
1503
  }
3197
1504
  } else {
3198
- if (!nacl__default["default"].sign.detached.verify(signData, signature, publicKey.toBuffer())) {
1505
+ if (!verify(signature, signData, publicKey.toBuffer())) {
3199
1506
  return false;
3200
1507
  }
3201
1508
  }
@@ -3400,7 +1707,7 @@ class VersionedTransaction {
3400
1707
  for (const signer of signers) {
3401
1708
  const signerIndex = signerPubkeys.findIndex(pubkey => pubkey.equals(signer.publicKey));
3402
1709
  assert(signerIndex >= 0, `Cannot sign with non signer key ${signer.publicKey.toBase58()}`);
3403
- this.signatures[signerIndex] = nacl__default["default"].sign.detached(messageData, signer.secretKey);
1710
+ this.signatures[signerIndex] = sign(messageData, signer.secretKey);
3404
1711
  }
3405
1712
  }
3406
1713
 
@@ -4932,6 +3239,28 @@ function notificationResultAndContext(value) {
4932
3239
  value
4933
3240
  });
4934
3241
  }
3242
+ /**
3243
+ * @internal
3244
+ */
3245
+
3246
+
3247
+ function versionedMessageFromResponse(version, response) {
3248
+ if (version === 0) {
3249
+ return new MessageV0({
3250
+ header: response.header,
3251
+ staticAccountKeys: response.accountKeys.map(accountKey => new PublicKey(accountKey)),
3252
+ recentBlockhash: response.recentBlockhash,
3253
+ compiledInstructions: response.instructions.map(ix => ({
3254
+ programIdIndex: ix.programIdIndex,
3255
+ accountKeyIndexes: ix.accounts,
3256
+ data: bs58__default["default"].decode(ix.data)
3257
+ })),
3258
+ addressTableLookups: response.addressTableLookups
3259
+ });
3260
+ } else {
3261
+ return new Message(response);
3262
+ }
3263
+ }
4935
3264
  /**
4936
3265
  * The level of commitment desired when querying state
4937
3266
  * <pre>
@@ -5487,6 +3816,11 @@ const GetSignatureStatusesRpcResult = jsonRpcResultAndContext(superstruct.array(
5487
3816
  */
5488
3817
 
5489
3818
  const GetMinimumBalanceForRentExemptionRpcResult = jsonRpcResult(superstruct.number());
3819
+ const AddressTableLookupStruct = superstruct.type({
3820
+ accountKey: PublicKeyFromString,
3821
+ writableIndexes: superstruct.array(superstruct.number()),
3822
+ readonlyIndexes: superstruct.array(superstruct.number())
3823
+ });
5490
3824
  const ConfirmedTransactionResult = superstruct.type({
5491
3825
  signatures: superstruct.array(superstruct.string()),
5492
3826
  message: superstruct.type({
@@ -5501,7 +3835,8 @@ const ConfirmedTransactionResult = superstruct.type({
5501
3835
  data: superstruct.string(),
5502
3836
  programIdIndex: superstruct.number()
5503
3837
  })),
5504
- recentBlockhash: superstruct.string()
3838
+ recentBlockhash: superstruct.string(),
3839
+ addressTableLookups: superstruct.optional(superstruct.array(AddressTableLookupStruct))
5505
3840
  })
5506
3841
  });
5507
3842
  const ParsedInstructionResult = superstruct.type({
@@ -5544,7 +3879,8 @@ const ParsedConfirmedTransactionResult = superstruct.type({
5544
3879
  writable: superstruct.boolean()
5545
3880
  })),
5546
3881
  instructions: superstruct.array(ParsedOrRawInstruction),
5547
- recentBlockhash: superstruct.string()
3882
+ recentBlockhash: superstruct.string(),
3883
+ addressTableLookups: superstruct.optional(superstruct.nullable(superstruct.array(AddressTableLookupStruct)))
5548
3884
  })
5549
3885
  });
5550
3886
  const TokenBalanceResult = superstruct.type({
@@ -5597,6 +3933,7 @@ const ParsedConfirmedTransactionMetaResult = superstruct.type({
5597
3933
  postTokenBalances: superstruct.optional(superstruct.nullable(superstruct.array(TokenBalanceResult))),
5598
3934
  loadedAddresses: superstruct.optional(LoadedAddressesResult)
5599
3935
  });
3936
+ const TransactionVersionStruct = superstruct.union([superstruct.literal(0), superstruct.literal('legacy')]);
5600
3937
  /**
5601
3938
  * Expected JSON RPC response for the "getBlock" message
5602
3939
  */
@@ -5607,7 +3944,8 @@ const GetBlockRpcResult = jsonRpcResult(superstruct.nullable(superstruct.type({
5607
3944
  parentSlot: superstruct.number(),
5608
3945
  transactions: superstruct.array(superstruct.type({
5609
3946
  transaction: ConfirmedTransactionResult,
5610
- meta: superstruct.nullable(ConfirmedTransactionMetaResult)
3947
+ meta: superstruct.nullable(ConfirmedTransactionMetaResult),
3948
+ version: superstruct.optional(TransactionVersionStruct)
5611
3949
  })),
5612
3950
  rewards: superstruct.optional(superstruct.array(superstruct.type({
5613
3951
  pubkey: superstruct.string(),
@@ -5659,7 +3997,8 @@ const GetTransactionRpcResult = jsonRpcResult(superstruct.nullable(superstruct.t
5659
3997
  slot: superstruct.number(),
5660
3998
  meta: ConfirmedTransactionMetaResult,
5661
3999
  blockTime: superstruct.optional(superstruct.nullable(superstruct.number())),
5662
- transaction: ConfirmedTransactionResult
4000
+ transaction: ConfirmedTransactionResult,
4001
+ version: superstruct.optional(TransactionVersionStruct)
5663
4002
  })));
5664
4003
  /**
5665
4004
  * Expected parsed JSON RPC response for the "getTransaction" message
@@ -5669,7 +4008,8 @@ const GetParsedTransactionRpcResult = jsonRpcResult(superstruct.nullable(superst
5669
4008
  slot: superstruct.number(),
5670
4009
  transaction: ParsedConfirmedTransactionResult,
5671
4010
  meta: superstruct.nullable(ParsedConfirmedTransactionMetaResult),
5672
- blockTime: superstruct.optional(superstruct.nullable(superstruct.number()))
4011
+ blockTime: superstruct.optional(superstruct.nullable(superstruct.number())),
4012
+ version: superstruct.optional(TransactionVersionStruct)
5673
4013
  })));
5674
4014
  /**
5675
4015
  * Expected JSON RPC response for the "getRecentBlockhash" message
@@ -6912,9 +5252,16 @@ class Connection {
6912
5252
  }
6913
5253
  /**
6914
5254
  * Fetch a processed block from the cluster.
5255
+ *
5256
+ * @deprecated Instead, call `getBlock` using a `GetVersionedBlockConfig` by
5257
+ * setting the `maxSupportedTransactionVersion` property.
6915
5258
  */
6916
5259
 
6917
5260
 
5261
+ /**
5262
+ * Fetch a processed block from the cluster.
5263
+ */
5264
+ // eslint-disable-next-line no-dupe-class-members
6918
5265
  async getBlock(slot, rawConfig) {
6919
5266
  const {
6920
5267
  commitment,
@@ -6937,16 +5284,15 @@ class Connection {
6937
5284
  return { ...result,
6938
5285
  transactions: result.transactions.map(({
6939
5286
  transaction,
6940
- meta
6941
- }) => {
6942
- const message = new Message(transaction.message);
6943
- return {
6944
- meta,
6945
- transaction: { ...transaction,
6946
- message
6947
- }
6948
- };
6949
- })
5287
+ meta,
5288
+ version
5289
+ }) => ({
5290
+ meta,
5291
+ transaction: { ...transaction,
5292
+ message: versionedMessageFromResponse(version, transaction.message)
5293
+ },
5294
+ version
5295
+ }))
6950
5296
  };
6951
5297
  }
6952
5298
  /*
@@ -7006,9 +5352,17 @@ class Connection {
7006
5352
  }
7007
5353
  /**
7008
5354
  * Fetch a confirmed or finalized transaction from the cluster.
5355
+ *
5356
+ * @deprecated Instead, call `getTransaction` using a
5357
+ * `GetVersionedTransactionConfig` by setting the
5358
+ * `maxSupportedTransactionVersion` property.
7009
5359
  */
7010
5360
 
7011
5361
 
5362
+ /**
5363
+ * Fetch a confirmed or finalized transaction from the cluster.
5364
+ */
5365
+ // eslint-disable-next-line no-dupe-class-members
7012
5366
  async getTransaction(signature, rawConfig) {
7013
5367
  const {
7014
5368
  commitment,
@@ -7030,7 +5384,7 @@ class Connection {
7030
5384
  if (!result) return result;
7031
5385
  return { ...result,
7032
5386
  transaction: { ...result.transaction,
7033
- message: new Message(result.transaction.message)
5387
+ message: versionedMessageFromResponse(result.version, result.transaction.message)
7034
5388
  }
7035
5389
  };
7036
5390
  }
@@ -7089,9 +5443,19 @@ class Connection {
7089
5443
  /**
7090
5444
  * Fetch transaction details for a batch of confirmed transactions.
7091
5445
  * Similar to {@link getParsedTransactions} but returns a {@link TransactionResponse}.
5446
+ *
5447
+ * @deprecated Instead, call `getTransactions` using a
5448
+ * `GetVersionedTransactionConfig` by setting the
5449
+ * `maxSupportedTransactionVersion` property.
7092
5450
  */
7093
5451
 
7094
5452
 
5453
+ /**
5454
+ * Fetch transaction details for a batch of confirmed transactions.
5455
+ * Similar to {@link getParsedTransactions} but returns a {@link
5456
+ * VersionedTransactionResponse}.
5457
+ */
5458
+ // eslint-disable-next-line no-dupe-class-members
7095
5459
  async getTransactions(signatures, commitmentOrConfig) {
7096
5460
  const {
7097
5461
  commitment,
@@ -7119,7 +5483,7 @@ class Connection {
7119
5483
  if (!result) return result;
7120
5484
  return { ...result,
7121
5485
  transaction: { ...result.transaction,
7122
- message: new Message(result.transaction.message)
5486
+ message: versionedMessageFromResponse(result.version, result.transaction.message)
7123
5487
  }
7124
5488
  };
7125
5489
  });
@@ -8546,12 +6910,7 @@ class Keypair {
8546
6910
  */
8547
6911
  constructor(keypair) {
8548
6912
  this._keypair = void 0;
8549
-
8550
- if (keypair) {
8551
- this._keypair = keypair;
8552
- } else {
8553
- this._keypair = nacl__default["default"].sign.keyPair();
8554
- }
6913
+ this._keypair = keypair !== null && keypair !== void 0 ? keypair : generateKeypair();
8555
6914
  }
8556
6915
  /**
8557
6916
  * Generate a new random keypair
@@ -8559,7 +6918,7 @@ class Keypair {
8559
6918
 
8560
6919
 
8561
6920
  static generate() {
8562
- return new Keypair(nacl__default["default"].sign.keyPair());
6921
+ return new Keypair(generateKeypair());
8563
6922
  }
8564
6923
  /**
8565
6924
  * Create a keypair from a raw secret key byte array.
@@ -8576,19 +6935,27 @@ class Keypair {
8576
6935
 
8577
6936
 
8578
6937
  static fromSecretKey(secretKey, options) {
8579
- const keypair = nacl__default["default"].sign.keyPair.fromSecretKey(secretKey);
6938
+ if (secretKey.byteLength !== 64) {
6939
+ throw new Error('bad secret key size');
6940
+ }
6941
+
6942
+ const publicKey = secretKey.slice(32, 64);
8580
6943
 
8581
6944
  if (!options || !options.skipValidation) {
8582
- const encoder = new TextEncoder();
8583
- const signData = encoder.encode('@solana/web3.js-validation-v1');
8584
- const signature = nacl__default["default"].sign.detached(signData, keypair.secretKey);
6945
+ const privateScalar = secretKey.slice(0, 32);
6946
+ const computedPublicKey = getPublicKey(privateScalar);
8585
6947
 
8586
- if (!nacl__default["default"].sign.detached.verify(signData, signature, keypair.publicKey)) {
8587
- throw new Error('provided secretKey is invalid');
6948
+ for (let ii = 0; ii < 32; ii++) {
6949
+ if (publicKey[ii] !== computedPublicKey[ii]) {
6950
+ throw new Error('provided secretKey is invalid');
6951
+ }
8588
6952
  }
8589
6953
  }
8590
6954
 
8591
- return new Keypair(keypair);
6955
+ return new Keypair({
6956
+ publicKey,
6957
+ secretKey
6958
+ });
8592
6959
  }
8593
6960
  /**
8594
6961
  * Generate a keypair from a 32 byte seed.
@@ -8598,7 +6965,14 @@ class Keypair {
8598
6965
 
8599
6966
 
8600
6967
  static fromSeed(seed) {
8601
- return new Keypair(nacl__default["default"].sign.keyPair.fromSeed(seed));
6968
+ const publicKey = getPublicKey(seed);
6969
+ const secretKey = new Uint8Array(64);
6970
+ secretKey.set(seed);
6971
+ secretKey.set(publicKey, 32);
6972
+ return new Keypair({
6973
+ publicKey,
6974
+ secretKey
6975
+ });
8602
6976
  }
8603
6977
  /**
8604
6978
  * The public key for this keypair
@@ -9150,7 +7524,7 @@ class Ed25519Program {
9150
7524
  try {
9151
7525
  const keypair = Keypair.fromSecretKey(privateKey);
9152
7526
  const publicKey = keypair.publicKey.toBytes();
9153
- const signature = nacl__default["default"].sign.detached(message, keypair.secretKey);
7527
+ const signature = sign(message, keypair.secretKey);
9154
7528
  return this.createInstructionWithPublicKey({
9155
7529
  publicKey,
9156
7530
  message,
@@ -9165,10 +7539,21 @@ class Ed25519Program {
9165
7539
  }
9166
7540
  Ed25519Program.programId = new PublicKey('Ed25519SigVerify111111111111111111111111111');
9167
7541
 
9168
- const {
9169
- publicKeyCreate,
9170
- ecdsaSign
9171
- } = secp256k1__default["default"];
7542
+ // library interoperable with the synchronous APIs in web3.js.
7543
+
7544
+ secp256k1__namespace.utils.hmacSha256Sync = (key, ...msgs) => {
7545
+ const h = hmac.hmac.create(sha256.sha256, key);
7546
+ msgs.forEach(msg => h.update(msg));
7547
+ return h.digest();
7548
+ };
7549
+
7550
+ const ecdsaSign = (msgHash, privKey) => secp256k1__namespace.signSync(msgHash, privKey, {
7551
+ der: false,
7552
+ recovered: true
7553
+ });
7554
+ secp256k1__namespace.utils.isValidPrivateKey;
7555
+ const publicKeyCreate = secp256k1__namespace.getPublicKey;
7556
+
9172
7557
  const PRIVATE_KEY_BYTES = 32;
9173
7558
  const ETHEREUM_ADDRESS_BYTES = 20;
9174
7559
  const PUBLIC_KEY_BYTES = 64;
@@ -9292,13 +7677,12 @@ class Secp256k1Program {
9292
7677
 
9293
7678
  try {
9294
7679
  const privateKey = toBuffer(pkey);
9295
- const publicKey = publicKeyCreate(privateKey, false).slice(1); // throw away leading byte
7680
+ const publicKey = publicKeyCreate(privateKey, false
7681
+ /* isCompressed */
7682
+ ).slice(1); // throw away leading byte
9296
7683
 
9297
7684
  const messageHash = buffer.Buffer.from(sha3__default["default"].keccak_256.update(toBuffer(message)).digest());
9298
- const {
9299
- signature,
9300
- recid: recoveryId
9301
- } = ecdsaSign(messageHash, privateKey);
7685
+ const [signature, recoveryId] = ecdsaSign(messageHash, privateKey);
9302
7686
  return this.createInstructionWithPublicKey({
9303
7687
  publicKey,
9304
7688
  message,