@pooflabs/web 0.0.20 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +697 -691
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +696 -690
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import globalAxios from 'axios';
|
|
2
|
-
import {
|
|
2
|
+
import { PublicKey, SystemProgram, TransactionInstruction, ComputeBudgetProgram, VersionedTransaction, TransactionMessage, Keypair, Transaction as Transaction$1, Connection } from '@solana/web3.js';
|
|
3
3
|
import * as anchor from '@coral-xyz/anchor';
|
|
4
4
|
import { Program } from '@coral-xyz/anchor';
|
|
5
5
|
import * as React$1 from 'react';
|
|
6
6
|
import { createContext } from 'react';
|
|
7
|
-
import '@solana-program/memo';
|
|
8
7
|
import 'react/jsx-runtime';
|
|
9
8
|
|
|
10
9
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
@@ -4831,176 +4830,6 @@ function requireNaclFast () {
|
|
|
4831
4830
|
var naclFastExports = requireNaclFast();
|
|
4832
4831
|
var nacl = /*@__PURE__*/getDefaultExportFromCjs$1(naclFastExports);
|
|
4833
4832
|
|
|
4834
|
-
// base-x encoding / decoding
|
|
4835
|
-
// Copyright (c) 2018 base-x contributors
|
|
4836
|
-
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
|
4837
|
-
// Distributed under the MIT software license, see the accompanying
|
|
4838
|
-
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
|
4839
|
-
function base$1 (ALPHABET) {
|
|
4840
|
-
if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
|
|
4841
|
-
const BASE_MAP = new Uint8Array(256);
|
|
4842
|
-
for (let j = 0; j < BASE_MAP.length; j++) {
|
|
4843
|
-
BASE_MAP[j] = 255;
|
|
4844
|
-
}
|
|
4845
|
-
for (let i = 0; i < ALPHABET.length; i++) {
|
|
4846
|
-
const x = ALPHABET.charAt(i);
|
|
4847
|
-
const xc = x.charCodeAt(0);
|
|
4848
|
-
if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
|
|
4849
|
-
BASE_MAP[xc] = i;
|
|
4850
|
-
}
|
|
4851
|
-
const BASE = ALPHABET.length;
|
|
4852
|
-
const LEADER = ALPHABET.charAt(0);
|
|
4853
|
-
const FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
|
|
4854
|
-
const iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
|
|
4855
|
-
function encode (source) {
|
|
4856
|
-
// eslint-disable-next-line no-empty
|
|
4857
|
-
if (source instanceof Uint8Array) ; else if (ArrayBuffer.isView(source)) {
|
|
4858
|
-
source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
4859
|
-
} else if (Array.isArray(source)) {
|
|
4860
|
-
source = Uint8Array.from(source);
|
|
4861
|
-
}
|
|
4862
|
-
if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') }
|
|
4863
|
-
if (source.length === 0) { return '' }
|
|
4864
|
-
// Skip & count leading zeroes.
|
|
4865
|
-
let zeroes = 0;
|
|
4866
|
-
let length = 0;
|
|
4867
|
-
let pbegin = 0;
|
|
4868
|
-
const pend = source.length;
|
|
4869
|
-
while (pbegin !== pend && source[pbegin] === 0) {
|
|
4870
|
-
pbegin++;
|
|
4871
|
-
zeroes++;
|
|
4872
|
-
}
|
|
4873
|
-
// Allocate enough space in big-endian base58 representation.
|
|
4874
|
-
const size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
|
|
4875
|
-
const b58 = new Uint8Array(size);
|
|
4876
|
-
// Process the bytes.
|
|
4877
|
-
while (pbegin !== pend) {
|
|
4878
|
-
let carry = source[pbegin];
|
|
4879
|
-
// Apply "b58 = b58 * 256 + ch".
|
|
4880
|
-
let i = 0;
|
|
4881
|
-
for (let it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
|
|
4882
|
-
carry += (256 * b58[it1]) >>> 0;
|
|
4883
|
-
b58[it1] = (carry % BASE) >>> 0;
|
|
4884
|
-
carry = (carry / BASE) >>> 0;
|
|
4885
|
-
}
|
|
4886
|
-
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
4887
|
-
length = i;
|
|
4888
|
-
pbegin++;
|
|
4889
|
-
}
|
|
4890
|
-
// Skip leading zeroes in base58 result.
|
|
4891
|
-
let it2 = size - length;
|
|
4892
|
-
while (it2 !== size && b58[it2] === 0) {
|
|
4893
|
-
it2++;
|
|
4894
|
-
}
|
|
4895
|
-
// Translate the result into a string.
|
|
4896
|
-
let str = LEADER.repeat(zeroes);
|
|
4897
|
-
for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }
|
|
4898
|
-
return str
|
|
4899
|
-
}
|
|
4900
|
-
function decodeUnsafe (source) {
|
|
4901
|
-
if (typeof source !== 'string') { throw new TypeError('Expected String') }
|
|
4902
|
-
if (source.length === 0) { return new Uint8Array() }
|
|
4903
|
-
let psz = 0;
|
|
4904
|
-
// Skip and count leading '1's.
|
|
4905
|
-
let zeroes = 0;
|
|
4906
|
-
let length = 0;
|
|
4907
|
-
while (source[psz] === LEADER) {
|
|
4908
|
-
zeroes++;
|
|
4909
|
-
psz++;
|
|
4910
|
-
}
|
|
4911
|
-
// Allocate enough space in big-endian base256 representation.
|
|
4912
|
-
const size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
|
|
4913
|
-
const b256 = new Uint8Array(size);
|
|
4914
|
-
// Process the characters.
|
|
4915
|
-
while (psz < source.length) {
|
|
4916
|
-
// Find code of next character
|
|
4917
|
-
const charCode = source.charCodeAt(psz);
|
|
4918
|
-
// Base map can not be indexed using char code
|
|
4919
|
-
if (charCode > 255) { return }
|
|
4920
|
-
// Decode character
|
|
4921
|
-
let carry = BASE_MAP[charCode];
|
|
4922
|
-
// Invalid character
|
|
4923
|
-
if (carry === 255) { return }
|
|
4924
|
-
let i = 0;
|
|
4925
|
-
for (let it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
|
|
4926
|
-
carry += (BASE * b256[it3]) >>> 0;
|
|
4927
|
-
b256[it3] = (carry % 256) >>> 0;
|
|
4928
|
-
carry = (carry / 256) >>> 0;
|
|
4929
|
-
}
|
|
4930
|
-
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
4931
|
-
length = i;
|
|
4932
|
-
psz++;
|
|
4933
|
-
}
|
|
4934
|
-
// Skip leading zeroes in b256.
|
|
4935
|
-
let it4 = size - length;
|
|
4936
|
-
while (it4 !== size && b256[it4] === 0) {
|
|
4937
|
-
it4++;
|
|
4938
|
-
}
|
|
4939
|
-
const vch = new Uint8Array(zeroes + (size - it4));
|
|
4940
|
-
let j = zeroes;
|
|
4941
|
-
while (it4 !== size) {
|
|
4942
|
-
vch[j++] = b256[it4++];
|
|
4943
|
-
}
|
|
4944
|
-
return vch
|
|
4945
|
-
}
|
|
4946
|
-
function decode (string) {
|
|
4947
|
-
const buffer = decodeUnsafe(string);
|
|
4948
|
-
if (buffer) { return buffer }
|
|
4949
|
-
throw new Error('Non-base' + BASE + ' character')
|
|
4950
|
-
}
|
|
4951
|
-
return {
|
|
4952
|
-
encode,
|
|
4953
|
-
decodeUnsafe,
|
|
4954
|
-
decode
|
|
4955
|
-
}
|
|
4956
|
-
}
|
|
4957
|
-
|
|
4958
|
-
var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
4959
|
-
var ue$3 = base$1(ALPHABET);
|
|
4960
|
-
|
|
4961
|
-
/**
|
|
4962
|
-
* Check if a given instruction is a SetComputeUnitLimit instruction
|
|
4963
|
-
* See https://github.com/solana-program/compute-budget/blob/main/clients/js/src/generated/programs/computeBudget.ts#L29
|
|
4964
|
-
*/
|
|
4965
|
-
function isSetComputeLimitInstruction(ix) {
|
|
4966
|
-
return (ix.programId.equals(ComputeBudgetProgram.programId) && ix.data[0] === 2 // opcode for setComputeUnitLimit is 2
|
|
4967
|
-
);
|
|
4968
|
-
}
|
|
4969
|
-
// Was getSimulationUnits
|
|
4970
|
-
// Credit https://twitter.com/stegabob, originally from
|
|
4971
|
-
// https://x.com/stegaBOB/status/1766662289392889920
|
|
4972
|
-
const getSimulationComputeUnits = async (connection, instructions, payer, lookupTables, commitment = "confirmed") => {
|
|
4973
|
-
const simulationInstructions = [...instructions];
|
|
4974
|
-
// Replace or add compute limit instruction
|
|
4975
|
-
const computeLimitIndex = simulationInstructions.findIndex(isSetComputeLimitInstruction);
|
|
4976
|
-
const simulationLimitIx = ComputeBudgetProgram.setComputeUnitLimit({
|
|
4977
|
-
units: 1_400_000,
|
|
4978
|
-
});
|
|
4979
|
-
if (computeLimitIndex >= 0) {
|
|
4980
|
-
simulationInstructions[computeLimitIndex] = simulationLimitIx;
|
|
4981
|
-
}
|
|
4982
|
-
else {
|
|
4983
|
-
simulationInstructions.unshift(simulationLimitIx);
|
|
4984
|
-
}
|
|
4985
|
-
const testTransaction = new VersionedTransaction(new TransactionMessage({
|
|
4986
|
-
instructions: simulationInstructions,
|
|
4987
|
-
payerKey: payer,
|
|
4988
|
-
// RecentBlockhash can by any public key during simulation
|
|
4989
|
-
// since 'replaceRecentBlockhash' is set to 'true' below
|
|
4990
|
-
recentBlockhash: PublicKey.default.toString(),
|
|
4991
|
-
}).compileToV0Message(lookupTables));
|
|
4992
|
-
const rpcResponse = await connection.simulateTransaction(testTransaction, {
|
|
4993
|
-
replaceRecentBlockhash: true,
|
|
4994
|
-
sigVerify: false,
|
|
4995
|
-
commitment,
|
|
4996
|
-
});
|
|
4997
|
-
if (rpcResponse?.value?.err) {
|
|
4998
|
-
const logs = rpcResponse.value.logs?.join("\n • ") || "No logs available";
|
|
4999
|
-
throw new Error(`Transaction simulation failed:\n •${logs}` + JSON.stringify(rpcResponse?.value?.err));
|
|
5000
|
-
}
|
|
5001
|
-
return rpcResponse.value.unitsConsumed || null;
|
|
5002
|
-
};
|
|
5003
|
-
|
|
5004
4833
|
var bn$3 = {exports: {}};
|
|
5005
4834
|
|
|
5006
4835
|
var bn$2 = bn$3.exports;
|
|
@@ -8367,431 +8196,6 @@ function requireBn () {
|
|
|
8367
8196
|
var bnExports = requireBn();
|
|
8368
8197
|
var BN = /*@__PURE__*/getDefaultExportFromCjs$1(bnExports);
|
|
8369
8198
|
|
|
8370
|
-
const crypto$3 = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined;
|
|
8371
|
-
|
|
8372
|
-
/**
|
|
8373
|
-
* Utilities for hex, bytes, CSPRNG.
|
|
8374
|
-
* @module
|
|
8375
|
-
*/
|
|
8376
|
-
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
8377
|
-
// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.
|
|
8378
|
-
// node.js versions earlier than v19 don't declare it in global scope.
|
|
8379
|
-
// For node.js, package.json#exports field mapping rewrites import
|
|
8380
|
-
// from `crypto` to `cryptoNode`, which imports native module.
|
|
8381
|
-
// Makes the utils un-importable in browsers without a bundler.
|
|
8382
|
-
// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.
|
|
8383
|
-
/** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */
|
|
8384
|
-
function isBytes$2(a) {
|
|
8385
|
-
return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');
|
|
8386
|
-
}
|
|
8387
|
-
/** Asserts something is positive integer. */
|
|
8388
|
-
function anumber$1(n) {
|
|
8389
|
-
if (!Number.isSafeInteger(n) || n < 0)
|
|
8390
|
-
throw new Error('positive integer expected, got ' + n);
|
|
8391
|
-
}
|
|
8392
|
-
/** Asserts something is Uint8Array. */
|
|
8393
|
-
function abytes$2(b, ...lengths) {
|
|
8394
|
-
if (!isBytes$2(b))
|
|
8395
|
-
throw new Error('Uint8Array expected');
|
|
8396
|
-
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
8397
|
-
throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length);
|
|
8398
|
-
}
|
|
8399
|
-
/** Asserts something is hash */
|
|
8400
|
-
function ahash(h) {
|
|
8401
|
-
if (typeof h !== 'function' || typeof h.create !== 'function')
|
|
8402
|
-
throw new Error('Hash should be wrapped by utils.createHasher');
|
|
8403
|
-
anumber$1(h.outputLen);
|
|
8404
|
-
anumber$1(h.blockLen);
|
|
8405
|
-
}
|
|
8406
|
-
/** Asserts a hash instance has not been destroyed / finished */
|
|
8407
|
-
function aexists(instance, checkFinished = true) {
|
|
8408
|
-
if (instance.destroyed)
|
|
8409
|
-
throw new Error('Hash instance has been destroyed');
|
|
8410
|
-
if (checkFinished && instance.finished)
|
|
8411
|
-
throw new Error('Hash#digest() has already been called');
|
|
8412
|
-
}
|
|
8413
|
-
/** Asserts output is properly-sized byte array */
|
|
8414
|
-
function aoutput(out, instance) {
|
|
8415
|
-
abytes$2(out);
|
|
8416
|
-
const min = instance.outputLen;
|
|
8417
|
-
if (out.length < min) {
|
|
8418
|
-
throw new Error('digestInto() expects output buffer of length at least ' + min);
|
|
8419
|
-
}
|
|
8420
|
-
}
|
|
8421
|
-
/** Cast u8 / u16 / u32 to u32. */
|
|
8422
|
-
function u32$1(arr) {
|
|
8423
|
-
return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
8424
|
-
}
|
|
8425
|
-
/** Zeroize a byte array. Warning: JS provides no guarantees. */
|
|
8426
|
-
function clean(...arrays) {
|
|
8427
|
-
for (let i = 0; i < arrays.length; i++) {
|
|
8428
|
-
arrays[i].fill(0);
|
|
8429
|
-
}
|
|
8430
|
-
}
|
|
8431
|
-
/** Create DataView of an array for easy byte-level manipulation. */
|
|
8432
|
-
function createView$1(arr) {
|
|
8433
|
-
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
8434
|
-
}
|
|
8435
|
-
/** The rotate right (circular right shift) operation for uint32 */
|
|
8436
|
-
function rotr$1(word, shift) {
|
|
8437
|
-
return (word << (32 - shift)) | (word >>> shift);
|
|
8438
|
-
}
|
|
8439
|
-
/** Is current platform little-endian? Most are. Big-Endian platform: IBM */
|
|
8440
|
-
const isLE$1 = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)();
|
|
8441
|
-
/** The byte swap operation for uint32 */
|
|
8442
|
-
function byteSwap(word) {
|
|
8443
|
-
return (((word << 24) & 0xff000000) |
|
|
8444
|
-
((word << 8) & 0xff0000) |
|
|
8445
|
-
((word >>> 8) & 0xff00) |
|
|
8446
|
-
((word >>> 24) & 0xff));
|
|
8447
|
-
}
|
|
8448
|
-
/** In place byte swap for Uint32Array */
|
|
8449
|
-
function byteSwap32(arr) {
|
|
8450
|
-
for (let i = 0; i < arr.length; i++) {
|
|
8451
|
-
arr[i] = byteSwap(arr[i]);
|
|
8452
|
-
}
|
|
8453
|
-
return arr;
|
|
8454
|
-
}
|
|
8455
|
-
const swap32IfBE = isLE$1
|
|
8456
|
-
? (u) => u
|
|
8457
|
-
: byteSwap32;
|
|
8458
|
-
/**
|
|
8459
|
-
* Converts string to bytes using UTF8 encoding.
|
|
8460
|
-
* @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99])
|
|
8461
|
-
*/
|
|
8462
|
-
function utf8ToBytes$2(str) {
|
|
8463
|
-
if (typeof str !== 'string')
|
|
8464
|
-
throw new Error('string expected');
|
|
8465
|
-
return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
|
|
8466
|
-
}
|
|
8467
|
-
/**
|
|
8468
|
-
* Normalizes (non-hex) string or Uint8Array to Uint8Array.
|
|
8469
|
-
* Warning: when Uint8Array is passed, it would NOT get copied.
|
|
8470
|
-
* Keep in mind for future mutable operations.
|
|
8471
|
-
*/
|
|
8472
|
-
function toBytes$1(data) {
|
|
8473
|
-
if (typeof data === 'string')
|
|
8474
|
-
data = utf8ToBytes$2(data);
|
|
8475
|
-
abytes$2(data);
|
|
8476
|
-
return data;
|
|
8477
|
-
}
|
|
8478
|
-
/** Copies several Uint8Arrays into one. */
|
|
8479
|
-
function concatBytes$3(...arrays) {
|
|
8480
|
-
let sum = 0;
|
|
8481
|
-
for (let i = 0; i < arrays.length; i++) {
|
|
8482
|
-
const a = arrays[i];
|
|
8483
|
-
abytes$2(a);
|
|
8484
|
-
sum += a.length;
|
|
8485
|
-
}
|
|
8486
|
-
const res = new Uint8Array(sum);
|
|
8487
|
-
for (let i = 0, pad = 0; i < arrays.length; i++) {
|
|
8488
|
-
const a = arrays[i];
|
|
8489
|
-
res.set(a, pad);
|
|
8490
|
-
pad += a.length;
|
|
8491
|
-
}
|
|
8492
|
-
return res;
|
|
8493
|
-
}
|
|
8494
|
-
/** For runtime check if class implements interface */
|
|
8495
|
-
let Hash$1 = class Hash {
|
|
8496
|
-
};
|
|
8497
|
-
/** Wraps hash function, creating an interface on top of it */
|
|
8498
|
-
function createHasher(hashCons) {
|
|
8499
|
-
const hashC = (msg) => hashCons().update(toBytes$1(msg)).digest();
|
|
8500
|
-
const tmp = hashCons();
|
|
8501
|
-
hashC.outputLen = tmp.outputLen;
|
|
8502
|
-
hashC.blockLen = tmp.blockLen;
|
|
8503
|
-
hashC.create = () => hashCons();
|
|
8504
|
-
return hashC;
|
|
8505
|
-
}
|
|
8506
|
-
/** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */
|
|
8507
|
-
function randomBytes$1(bytesLength = 32) {
|
|
8508
|
-
if (crypto$3 && typeof crypto$3.getRandomValues === 'function') {
|
|
8509
|
-
return crypto$3.getRandomValues(new Uint8Array(bytesLength));
|
|
8510
|
-
}
|
|
8511
|
-
// Legacy Node.js compatibility
|
|
8512
|
-
if (crypto$3 && typeof crypto$3.randomBytes === 'function') {
|
|
8513
|
-
return Uint8Array.from(crypto$3.randomBytes(bytesLength));
|
|
8514
|
-
}
|
|
8515
|
-
throw new Error('crypto.getRandomValues must be defined');
|
|
8516
|
-
}
|
|
8517
|
-
|
|
8518
|
-
/**
|
|
8519
|
-
* Internal Merkle-Damgard hash utils.
|
|
8520
|
-
* @module
|
|
8521
|
-
*/
|
|
8522
|
-
/** Polyfill for Safari 14. https://caniuse.com/mdn-javascript_builtins_dataview_setbiguint64 */
|
|
8523
|
-
function setBigUint64$1(view, byteOffset, value, isLE) {
|
|
8524
|
-
if (typeof view.setBigUint64 === 'function')
|
|
8525
|
-
return view.setBigUint64(byteOffset, value, isLE);
|
|
8526
|
-
const _32n = BigInt(32);
|
|
8527
|
-
const _u32_max = BigInt(0xffffffff);
|
|
8528
|
-
const wh = Number((value >> _32n) & _u32_max);
|
|
8529
|
-
const wl = Number(value & _u32_max);
|
|
8530
|
-
const h = isLE ? 4 : 0;
|
|
8531
|
-
const l = isLE ? 0 : 4;
|
|
8532
|
-
view.setUint32(byteOffset + h, wh, isLE);
|
|
8533
|
-
view.setUint32(byteOffset + l, wl, isLE);
|
|
8534
|
-
}
|
|
8535
|
-
/** Choice: a ? b : c */
|
|
8536
|
-
function Chi$1(a, b, c) {
|
|
8537
|
-
return (a & b) ^ (~a & c);
|
|
8538
|
-
}
|
|
8539
|
-
/** Majority function, true if any two inputs is true. */
|
|
8540
|
-
function Maj$1(a, b, c) {
|
|
8541
|
-
return (a & b) ^ (a & c) ^ (b & c);
|
|
8542
|
-
}
|
|
8543
|
-
/**
|
|
8544
|
-
* Merkle-Damgard hash construction base class.
|
|
8545
|
-
* Could be used to create MD5, RIPEMD, SHA1, SHA2.
|
|
8546
|
-
*/
|
|
8547
|
-
class HashMD extends Hash$1 {
|
|
8548
|
-
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
8549
|
-
super();
|
|
8550
|
-
this.finished = false;
|
|
8551
|
-
this.length = 0;
|
|
8552
|
-
this.pos = 0;
|
|
8553
|
-
this.destroyed = false;
|
|
8554
|
-
this.blockLen = blockLen;
|
|
8555
|
-
this.outputLen = outputLen;
|
|
8556
|
-
this.padOffset = padOffset;
|
|
8557
|
-
this.isLE = isLE;
|
|
8558
|
-
this.buffer = new Uint8Array(blockLen);
|
|
8559
|
-
this.view = createView$1(this.buffer);
|
|
8560
|
-
}
|
|
8561
|
-
update(data) {
|
|
8562
|
-
aexists(this);
|
|
8563
|
-
data = toBytes$1(data);
|
|
8564
|
-
abytes$2(data);
|
|
8565
|
-
const { view, buffer, blockLen } = this;
|
|
8566
|
-
const len = data.length;
|
|
8567
|
-
for (let pos = 0; pos < len;) {
|
|
8568
|
-
const take = Math.min(blockLen - this.pos, len - pos);
|
|
8569
|
-
// Fast path: we have at least one block in input, cast it to view and process
|
|
8570
|
-
if (take === blockLen) {
|
|
8571
|
-
const dataView = createView$1(data);
|
|
8572
|
-
for (; blockLen <= len - pos; pos += blockLen)
|
|
8573
|
-
this.process(dataView, pos);
|
|
8574
|
-
continue;
|
|
8575
|
-
}
|
|
8576
|
-
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
8577
|
-
this.pos += take;
|
|
8578
|
-
pos += take;
|
|
8579
|
-
if (this.pos === blockLen) {
|
|
8580
|
-
this.process(view, 0);
|
|
8581
|
-
this.pos = 0;
|
|
8582
|
-
}
|
|
8583
|
-
}
|
|
8584
|
-
this.length += data.length;
|
|
8585
|
-
this.roundClean();
|
|
8586
|
-
return this;
|
|
8587
|
-
}
|
|
8588
|
-
digestInto(out) {
|
|
8589
|
-
aexists(this);
|
|
8590
|
-
aoutput(out, this);
|
|
8591
|
-
this.finished = true;
|
|
8592
|
-
// Padding
|
|
8593
|
-
// We can avoid allocation of buffer for padding completely if it
|
|
8594
|
-
// was previously not allocated here. But it won't change performance.
|
|
8595
|
-
const { buffer, view, blockLen, isLE } = this;
|
|
8596
|
-
let { pos } = this;
|
|
8597
|
-
// append the bit '1' to the message
|
|
8598
|
-
buffer[pos++] = 0b10000000;
|
|
8599
|
-
clean(this.buffer.subarray(pos));
|
|
8600
|
-
// we have less than padOffset left in buffer, so we cannot put length in
|
|
8601
|
-
// current block, need process it and pad again
|
|
8602
|
-
if (this.padOffset > blockLen - pos) {
|
|
8603
|
-
this.process(view, 0);
|
|
8604
|
-
pos = 0;
|
|
8605
|
-
}
|
|
8606
|
-
// Pad until full block byte with zeros
|
|
8607
|
-
for (let i = pos; i < blockLen; i++)
|
|
8608
|
-
buffer[i] = 0;
|
|
8609
|
-
// Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that
|
|
8610
|
-
// You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.
|
|
8611
|
-
// So we just write lowest 64 bits of that value.
|
|
8612
|
-
setBigUint64$1(view, blockLen - 8, BigInt(this.length * 8), isLE);
|
|
8613
|
-
this.process(view, 0);
|
|
8614
|
-
const oview = createView$1(out);
|
|
8615
|
-
const len = this.outputLen;
|
|
8616
|
-
// NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT
|
|
8617
|
-
if (len % 4)
|
|
8618
|
-
throw new Error('_sha2: outputLen should be aligned to 32bit');
|
|
8619
|
-
const outLen = len / 4;
|
|
8620
|
-
const state = this.get();
|
|
8621
|
-
if (outLen > state.length)
|
|
8622
|
-
throw new Error('_sha2: outputLen bigger than state');
|
|
8623
|
-
for (let i = 0; i < outLen; i++)
|
|
8624
|
-
oview.setUint32(4 * i, state[i], isLE);
|
|
8625
|
-
}
|
|
8626
|
-
digest() {
|
|
8627
|
-
const { buffer, outputLen } = this;
|
|
8628
|
-
this.digestInto(buffer);
|
|
8629
|
-
const res = buffer.slice(0, outputLen);
|
|
8630
|
-
this.destroy();
|
|
8631
|
-
return res;
|
|
8632
|
-
}
|
|
8633
|
-
_cloneInto(to) {
|
|
8634
|
-
to || (to = new this.constructor());
|
|
8635
|
-
to.set(...this.get());
|
|
8636
|
-
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
|
8637
|
-
to.destroyed = destroyed;
|
|
8638
|
-
to.finished = finished;
|
|
8639
|
-
to.length = length;
|
|
8640
|
-
to.pos = pos;
|
|
8641
|
-
if (length % blockLen)
|
|
8642
|
-
to.buffer.set(buffer);
|
|
8643
|
-
return to;
|
|
8644
|
-
}
|
|
8645
|
-
clone() {
|
|
8646
|
-
return this._cloneInto();
|
|
8647
|
-
}
|
|
8648
|
-
}
|
|
8649
|
-
/**
|
|
8650
|
-
* Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53.
|
|
8651
|
-
* Check out `test/misc/sha2-gen-iv.js` for recomputation guide.
|
|
8652
|
-
*/
|
|
8653
|
-
/** Initial SHA256 state. Bits 0..32 of frac part of sqrt of primes 2..19 */
|
|
8654
|
-
const SHA256_IV = /* @__PURE__ */ Uint32Array.from([
|
|
8655
|
-
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,
|
|
8656
|
-
]);
|
|
8657
|
-
|
|
8658
|
-
/**
|
|
8659
|
-
* Internal helpers for u64. BigUint64Array is too slow as per 2025, so we implement it using Uint32Array.
|
|
8660
|
-
* @todo re-check https://issues.chromium.org/issues/42212588
|
|
8661
|
-
* @module
|
|
8662
|
-
*/
|
|
8663
|
-
const U32_MASK64$1 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
8664
|
-
const _32n$1 = /* @__PURE__ */ BigInt(32);
|
|
8665
|
-
function fromBig$1(n, le = false) {
|
|
8666
|
-
if (le)
|
|
8667
|
-
return { h: Number(n & U32_MASK64$1), l: Number((n >> _32n$1) & U32_MASK64$1) };
|
|
8668
|
-
return { h: Number((n >> _32n$1) & U32_MASK64$1) | 0, l: Number(n & U32_MASK64$1) | 0 };
|
|
8669
|
-
}
|
|
8670
|
-
function split$1(lst, le = false) {
|
|
8671
|
-
const len = lst.length;
|
|
8672
|
-
let Ah = new Uint32Array(len);
|
|
8673
|
-
let Al = new Uint32Array(len);
|
|
8674
|
-
for (let i = 0; i < len; i++) {
|
|
8675
|
-
const { h, l } = fromBig$1(lst[i], le);
|
|
8676
|
-
[Ah[i], Al[i]] = [h, l];
|
|
8677
|
-
}
|
|
8678
|
-
return [Ah, Al];
|
|
8679
|
-
}
|
|
8680
|
-
// Left rotate for Shift in [1, 32)
|
|
8681
|
-
const rotlSH$1 = (h, l, s) => (h << s) | (l >>> (32 - s));
|
|
8682
|
-
const rotlSL$1 = (h, l, s) => (l << s) | (h >>> (32 - s));
|
|
8683
|
-
// Left rotate for Shift in (32, 64), NOTE: 32 is special case.
|
|
8684
|
-
const rotlBH$1 = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));
|
|
8685
|
-
const rotlBL$1 = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));
|
|
8686
|
-
|
|
8687
|
-
/**
|
|
8688
|
-
* SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256.
|
|
8689
|
-
* SHA256 is the fastest hash implementable in JS, even faster than Blake3.
|
|
8690
|
-
* Check out [RFC 4634](https://datatracker.ietf.org/doc/html/rfc4634) and
|
|
8691
|
-
* [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf).
|
|
8692
|
-
* @module
|
|
8693
|
-
*/
|
|
8694
|
-
/**
|
|
8695
|
-
* Round constants:
|
|
8696
|
-
* First 32 bits of fractional parts of the cube roots of the first 64 primes 2..311)
|
|
8697
|
-
*/
|
|
8698
|
-
// prettier-ignore
|
|
8699
|
-
const SHA256_K$1 = /* @__PURE__ */ Uint32Array.from([
|
|
8700
|
-
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
8701
|
-
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
8702
|
-
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
8703
|
-
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
|
8704
|
-
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
|
8705
|
-
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
8706
|
-
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
8707
|
-
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
|
8708
|
-
]);
|
|
8709
|
-
/** Reusable temporary buffer. "W" comes straight from spec. */
|
|
8710
|
-
const SHA256_W$1 = /* @__PURE__ */ new Uint32Array(64);
|
|
8711
|
-
let SHA256$1 = class SHA256 extends HashMD {
|
|
8712
|
-
constructor(outputLen = 32) {
|
|
8713
|
-
super(64, outputLen, 8, false);
|
|
8714
|
-
// We cannot use array here since array allows indexing by variable
|
|
8715
|
-
// which means optimizer/compiler cannot use registers.
|
|
8716
|
-
this.A = SHA256_IV[0] | 0;
|
|
8717
|
-
this.B = SHA256_IV[1] | 0;
|
|
8718
|
-
this.C = SHA256_IV[2] | 0;
|
|
8719
|
-
this.D = SHA256_IV[3] | 0;
|
|
8720
|
-
this.E = SHA256_IV[4] | 0;
|
|
8721
|
-
this.F = SHA256_IV[5] | 0;
|
|
8722
|
-
this.G = SHA256_IV[6] | 0;
|
|
8723
|
-
this.H = SHA256_IV[7] | 0;
|
|
8724
|
-
}
|
|
8725
|
-
get() {
|
|
8726
|
-
const { A, B, C, D, E, F, G, H } = this;
|
|
8727
|
-
return [A, B, C, D, E, F, G, H];
|
|
8728
|
-
}
|
|
8729
|
-
// prettier-ignore
|
|
8730
|
-
set(A, B, C, D, E, F, G, H) {
|
|
8731
|
-
this.A = A | 0;
|
|
8732
|
-
this.B = B | 0;
|
|
8733
|
-
this.C = C | 0;
|
|
8734
|
-
this.D = D | 0;
|
|
8735
|
-
this.E = E | 0;
|
|
8736
|
-
this.F = F | 0;
|
|
8737
|
-
this.G = G | 0;
|
|
8738
|
-
this.H = H | 0;
|
|
8739
|
-
}
|
|
8740
|
-
process(view, offset) {
|
|
8741
|
-
// Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array
|
|
8742
|
-
for (let i = 0; i < 16; i++, offset += 4)
|
|
8743
|
-
SHA256_W$1[i] = view.getUint32(offset, false);
|
|
8744
|
-
for (let i = 16; i < 64; i++) {
|
|
8745
|
-
const W15 = SHA256_W$1[i - 15];
|
|
8746
|
-
const W2 = SHA256_W$1[i - 2];
|
|
8747
|
-
const s0 = rotr$1(W15, 7) ^ rotr$1(W15, 18) ^ (W15 >>> 3);
|
|
8748
|
-
const s1 = rotr$1(W2, 17) ^ rotr$1(W2, 19) ^ (W2 >>> 10);
|
|
8749
|
-
SHA256_W$1[i] = (s1 + SHA256_W$1[i - 7] + s0 + SHA256_W$1[i - 16]) | 0;
|
|
8750
|
-
}
|
|
8751
|
-
// Compression function main loop, 64 rounds
|
|
8752
|
-
let { A, B, C, D, E, F, G, H } = this;
|
|
8753
|
-
for (let i = 0; i < 64; i++) {
|
|
8754
|
-
const sigma1 = rotr$1(E, 6) ^ rotr$1(E, 11) ^ rotr$1(E, 25);
|
|
8755
|
-
const T1 = (H + sigma1 + Chi$1(E, F, G) + SHA256_K$1[i] + SHA256_W$1[i]) | 0;
|
|
8756
|
-
const sigma0 = rotr$1(A, 2) ^ rotr$1(A, 13) ^ rotr$1(A, 22);
|
|
8757
|
-
const T2 = (sigma0 + Maj$1(A, B, C)) | 0;
|
|
8758
|
-
H = G;
|
|
8759
|
-
G = F;
|
|
8760
|
-
F = E;
|
|
8761
|
-
E = (D + T1) | 0;
|
|
8762
|
-
D = C;
|
|
8763
|
-
C = B;
|
|
8764
|
-
B = A;
|
|
8765
|
-
A = (T1 + T2) | 0;
|
|
8766
|
-
}
|
|
8767
|
-
// Add the compressed chunk to the current hash value
|
|
8768
|
-
A = (A + this.A) | 0;
|
|
8769
|
-
B = (B + this.B) | 0;
|
|
8770
|
-
C = (C + this.C) | 0;
|
|
8771
|
-
D = (D + this.D) | 0;
|
|
8772
|
-
E = (E + this.E) | 0;
|
|
8773
|
-
F = (F + this.F) | 0;
|
|
8774
|
-
G = (G + this.G) | 0;
|
|
8775
|
-
H = (H + this.H) | 0;
|
|
8776
|
-
this.set(A, B, C, D, E, F, G, H);
|
|
8777
|
-
}
|
|
8778
|
-
roundClean() {
|
|
8779
|
-
clean(SHA256_W$1);
|
|
8780
|
-
}
|
|
8781
|
-
destroy() {
|
|
8782
|
-
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
8783
|
-
clean(this.buffer);
|
|
8784
|
-
}
|
|
8785
|
-
};
|
|
8786
|
-
/**
|
|
8787
|
-
* SHA2-256 hash function from RFC 4634.
|
|
8788
|
-
*
|
|
8789
|
-
* It is the fastest JS hash, even faster than Blake3.
|
|
8790
|
-
* To break sha256 using birthday attack, attackers need to try 2^128 hashes.
|
|
8791
|
-
* BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.
|
|
8792
|
-
*/
|
|
8793
|
-
const sha256$2 = /* @__PURE__ */ createHasher(() => new SHA256$1());
|
|
8794
|
-
|
|
8795
8199
|
/*! *****************************************************************************
|
|
8796
8200
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8797
8201
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
@@ -12153,6 +11557,57 @@ function requireBs58$1 () {
|
|
|
12153
11557
|
var bs58Exports = requireBs58$1();
|
|
12154
11558
|
var bs58$2 = /*@__PURE__*/getDefaultExportFromCjs(bs58Exports);
|
|
12155
11559
|
|
|
11560
|
+
// ─────────────────────────────────────────────────────────────
|
|
11561
|
+
// Local implementation of getSimulationComputeUnits
|
|
11562
|
+
// (Replaces @solana-developers/helpers to avoid Wallet import issue in browser/ESM builds)
|
|
11563
|
+
// Source: https://github.com/solana-developers/helpers/blob/main/src/lib/transaction.ts
|
|
11564
|
+
// ─────────────────────────────────────────────────────────────
|
|
11565
|
+
/**
|
|
11566
|
+
* Check if a given instruction is a SetComputeUnitLimit instruction
|
|
11567
|
+
* See https://github.com/solana-program/compute-budget/blob/main/clients/js/src/generated/programs/computeBudget.ts#L29
|
|
11568
|
+
*/
|
|
11569
|
+
function isSetComputeLimitInstruction(ix) {
|
|
11570
|
+
return (ix.programId.equals(ComputeBudgetProgram.programId) &&
|
|
11571
|
+
ix.data[0] === 2 // opcode for setComputeUnitLimit is 2
|
|
11572
|
+
);
|
|
11573
|
+
}
|
|
11574
|
+
/**
|
|
11575
|
+
* Get the compute units required for a set of instructions via simulation.
|
|
11576
|
+
* Credit https://twitter.com/stegabob, originally from https://x.com/stegaBOB/status/1766662289392889920
|
|
11577
|
+
*/
|
|
11578
|
+
async function getSimulationComputeUnits(connection, instructions, payer, lookupTables, commitment = "confirmed") {
|
|
11579
|
+
var _a, _b, _c;
|
|
11580
|
+
const simulationInstructions = [...instructions];
|
|
11581
|
+
// Replace or add compute limit instruction
|
|
11582
|
+
const computeLimitIndex = simulationInstructions.findIndex(isSetComputeLimitInstruction);
|
|
11583
|
+
const simulationLimitIx = ComputeBudgetProgram.setComputeUnitLimit({
|
|
11584
|
+
units: 1400000,
|
|
11585
|
+
});
|
|
11586
|
+
if (computeLimitIndex >= 0) {
|
|
11587
|
+
simulationInstructions[computeLimitIndex] = simulationLimitIx;
|
|
11588
|
+
}
|
|
11589
|
+
else {
|
|
11590
|
+
simulationInstructions.unshift(simulationLimitIx);
|
|
11591
|
+
}
|
|
11592
|
+
const testTransaction = new VersionedTransaction(new TransactionMessage({
|
|
11593
|
+
instructions: simulationInstructions,
|
|
11594
|
+
payerKey: payer,
|
|
11595
|
+
// RecentBlockhash can by any public key during simulation
|
|
11596
|
+
// since 'replaceRecentBlockhash' is set to 'true' below
|
|
11597
|
+
recentBlockhash: PublicKey.default.toString(),
|
|
11598
|
+
}).compileToV0Message(lookupTables));
|
|
11599
|
+
const rpcResponse = await connection.simulateTransaction(testTransaction, {
|
|
11600
|
+
replaceRecentBlockhash: true,
|
|
11601
|
+
sigVerify: false,
|
|
11602
|
+
commitment,
|
|
11603
|
+
});
|
|
11604
|
+
if ((_a = rpcResponse === null || rpcResponse === void 0 ? void 0 : rpcResponse.value) === null || _a === void 0 ? void 0 : _a.err) {
|
|
11605
|
+
const logs = ((_b = rpcResponse.value.logs) === null || _b === void 0 ? void 0 : _b.join("\n • ")) || "No logs available";
|
|
11606
|
+
throw new Error(`Transaction simulation failed:\n •${logs}` +
|
|
11607
|
+
JSON.stringify((_c = rpcResponse === null || rpcResponse === void 0 ? void 0 : rpcResponse.value) === null || _c === void 0 ? void 0 : _c.err));
|
|
11608
|
+
}
|
|
11609
|
+
return rpcResponse.value.unitsConsumed || null;
|
|
11610
|
+
}
|
|
12156
11611
|
/* ------------------------------------------------------------------ */
|
|
12157
11612
|
/* RFC-4501 message */
|
|
12158
11613
|
/* ------------------------------------------------------------------ */
|
|
@@ -12468,7 +11923,6 @@ async function makeApiRequest(method, urlPath, data, _overrides) {
|
|
|
12468
11923
|
// Signal to backend that client supports offchain transaction signing
|
|
12469
11924
|
if (typeof window !== "undefined" &&
|
|
12470
11925
|
window.TAROBASE_SUPPORTS_OFFCHAIN_SIGNING) {
|
|
12471
|
-
console.log("X-Supports-Offchain-Signing", "true");
|
|
12472
11926
|
headers["X-Supports-Offchain-Signing"] = "true";
|
|
12473
11927
|
}
|
|
12474
11928
|
const requestConfig = {
|
|
@@ -16862,7 +16316,7 @@ function output(out, instance) {
|
|
|
16862
16316
|
}
|
|
16863
16317
|
}
|
|
16864
16318
|
|
|
16865
|
-
const crypto$
|
|
16319
|
+
const crypto$3 = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined;
|
|
16866
16320
|
|
|
16867
16321
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
16868
16322
|
// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.
|
|
@@ -16872,20 +16326,20 @@ const crypto$2 = typeof globalThis === 'object' && 'crypto' in globalThis ? glob
|
|
|
16872
16326
|
// Makes the utils un-importable in browsers without a bundler.
|
|
16873
16327
|
// Once node.js 18 is deprecated, we can just drop the import.
|
|
16874
16328
|
const u8a$1 = (a) => a instanceof Uint8Array;
|
|
16875
|
-
const u32 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
16329
|
+
const u32$1 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
16876
16330
|
// Cast array to view
|
|
16877
|
-
const createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
16331
|
+
const createView$1 = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
16878
16332
|
// The rotate right (circular right shift) operation for uint32
|
|
16879
|
-
const rotr = (word, shift) => (word << (32 - shift)) | (word >>> shift);
|
|
16333
|
+
const rotr$1 = (word, shift) => (word << (32 - shift)) | (word >>> shift);
|
|
16880
16334
|
// big-endian hardware is rare. Just in case someone still decides to run hashes:
|
|
16881
16335
|
// early-throw an error because we don't support BE yet.
|
|
16882
|
-
const isLE = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;
|
|
16883
|
-
if (!isLE)
|
|
16336
|
+
const isLE$1 = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;
|
|
16337
|
+
if (!isLE$1)
|
|
16884
16338
|
throw new Error('Non little-endian hardware is not supported');
|
|
16885
16339
|
/**
|
|
16886
16340
|
* @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
|
|
16887
16341
|
*/
|
|
16888
|
-
function utf8ToBytes$
|
|
16342
|
+
function utf8ToBytes$2(str) {
|
|
16889
16343
|
if (typeof str !== 'string')
|
|
16890
16344
|
throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
|
|
16891
16345
|
return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
|
|
@@ -16895,9 +16349,9 @@ function utf8ToBytes$1(str) {
|
|
|
16895
16349
|
* Warning: when Uint8Array is passed, it would NOT get copied.
|
|
16896
16350
|
* Keep in mind for future mutable operations.
|
|
16897
16351
|
*/
|
|
16898
|
-
function toBytes(data) {
|
|
16352
|
+
function toBytes$1(data) {
|
|
16899
16353
|
if (typeof data === 'string')
|
|
16900
|
-
data = utf8ToBytes$
|
|
16354
|
+
data = utf8ToBytes$2(data);
|
|
16901
16355
|
if (!u8a$1(data))
|
|
16902
16356
|
throw new Error(`expected Uint8Array, got ${typeof data}`);
|
|
16903
16357
|
return data;
|
|
@@ -16905,7 +16359,7 @@ function toBytes(data) {
|
|
|
16905
16359
|
/**
|
|
16906
16360
|
* Copies several Uint8Arrays into one.
|
|
16907
16361
|
*/
|
|
16908
|
-
function concatBytes$
|
|
16362
|
+
function concatBytes$3(...arrays) {
|
|
16909
16363
|
const r = new Uint8Array(arrays.reduce((sum, a) => sum + a.length, 0));
|
|
16910
16364
|
let pad = 0; // walk through each item, ensure they have proper type
|
|
16911
16365
|
arrays.forEach((a) => {
|
|
@@ -16917,14 +16371,14 @@ function concatBytes$2(...arrays) {
|
|
|
16917
16371
|
return r;
|
|
16918
16372
|
}
|
|
16919
16373
|
// For runtime check if class implements interface
|
|
16920
|
-
class Hash {
|
|
16374
|
+
let Hash$1 = class Hash {
|
|
16921
16375
|
// Safe version that clones internal state
|
|
16922
16376
|
clone() {
|
|
16923
16377
|
return this._cloneInto();
|
|
16924
16378
|
}
|
|
16925
|
-
}
|
|
16379
|
+
};
|
|
16926
16380
|
function wrapConstructor(hashCons) {
|
|
16927
|
-
const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
|
|
16381
|
+
const hashC = (msg) => hashCons().update(toBytes$1(msg)).digest();
|
|
16928
16382
|
const tmp = hashCons();
|
|
16929
16383
|
hashC.outputLen = tmp.outputLen;
|
|
16930
16384
|
hashC.blockLen = tmp.blockLen;
|
|
@@ -16934,21 +16388,21 @@ function wrapConstructor(hashCons) {
|
|
|
16934
16388
|
/**
|
|
16935
16389
|
* Secure PRNG. Uses `crypto.getRandomValues`, which defers to OS.
|
|
16936
16390
|
*/
|
|
16937
|
-
function randomBytes(bytesLength = 32) {
|
|
16938
|
-
if (crypto$
|
|
16939
|
-
return crypto$
|
|
16391
|
+
function randomBytes$1(bytesLength = 32) {
|
|
16392
|
+
if (crypto$3 && typeof crypto$3.getRandomValues === 'function') {
|
|
16393
|
+
return crypto$3.getRandomValues(new Uint8Array(bytesLength));
|
|
16940
16394
|
}
|
|
16941
16395
|
throw new Error('crypto.getRandomValues must be defined');
|
|
16942
16396
|
}
|
|
16943
16397
|
|
|
16944
16398
|
// HMAC (RFC 2104)
|
|
16945
|
-
let HMAC$1 = class HMAC extends Hash {
|
|
16399
|
+
let HMAC$1 = class HMAC extends Hash$1 {
|
|
16946
16400
|
constructor(hash$1, _key) {
|
|
16947
16401
|
super();
|
|
16948
16402
|
this.finished = false;
|
|
16949
16403
|
this.destroyed = false;
|
|
16950
16404
|
hash(hash$1);
|
|
16951
|
-
const key = toBytes(_key);
|
|
16405
|
+
const key = toBytes$1(_key);
|
|
16952
16406
|
this.iHash = hash$1.create();
|
|
16953
16407
|
if (typeof this.iHash.update !== 'function')
|
|
16954
16408
|
throw new Error('Expected instance of class which extends utils.Hash');
|
|
@@ -17017,7 +16471,7 @@ const hmac$1 = (hash, key, message) => new HMAC$1(hash, key).update(message).dig
|
|
|
17017
16471
|
hmac$1.create = (hash, key) => new HMAC$1(hash, key);
|
|
17018
16472
|
|
|
17019
16473
|
// Polyfill for Safari 14
|
|
17020
|
-
function setBigUint64(view, byteOffset, value, isLE) {
|
|
16474
|
+
function setBigUint64$1(view, byteOffset, value, isLE) {
|
|
17021
16475
|
if (typeof view.setBigUint64 === 'function')
|
|
17022
16476
|
return view.setBigUint64(byteOffset, value, isLE);
|
|
17023
16477
|
const _32n = BigInt(32);
|
|
@@ -17030,7 +16484,7 @@ function setBigUint64(view, byteOffset, value, isLE) {
|
|
|
17030
16484
|
view.setUint32(byteOffset + l, wl, isLE);
|
|
17031
16485
|
}
|
|
17032
16486
|
// Base SHA2 class (RFC 6234)
|
|
17033
|
-
class SHA2 extends Hash {
|
|
16487
|
+
class SHA2 extends Hash$1 {
|
|
17034
16488
|
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
17035
16489
|
super();
|
|
17036
16490
|
this.blockLen = blockLen;
|
|
@@ -17042,18 +16496,18 @@ class SHA2 extends Hash {
|
|
|
17042
16496
|
this.pos = 0;
|
|
17043
16497
|
this.destroyed = false;
|
|
17044
16498
|
this.buffer = new Uint8Array(blockLen);
|
|
17045
|
-
this.view = createView(this.buffer);
|
|
16499
|
+
this.view = createView$1(this.buffer);
|
|
17046
16500
|
}
|
|
17047
16501
|
update(data) {
|
|
17048
16502
|
exists(this);
|
|
17049
16503
|
const { view, buffer, blockLen } = this;
|
|
17050
|
-
data = toBytes(data);
|
|
16504
|
+
data = toBytes$1(data);
|
|
17051
16505
|
const len = data.length;
|
|
17052
16506
|
for (let pos = 0; pos < len;) {
|
|
17053
16507
|
const take = Math.min(blockLen - this.pos, len - pos);
|
|
17054
16508
|
// Fast path: we have at least one block in input, cast it to view and process
|
|
17055
16509
|
if (take === blockLen) {
|
|
17056
|
-
const dataView = createView(data);
|
|
16510
|
+
const dataView = createView$1(data);
|
|
17057
16511
|
for (; blockLen <= len - pos; pos += blockLen)
|
|
17058
16512
|
this.process(dataView, pos);
|
|
17059
16513
|
continue;
|
|
@@ -17093,9 +16547,9 @@ class SHA2 extends Hash {
|
|
|
17093
16547
|
// Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that
|
|
17094
16548
|
// You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.
|
|
17095
16549
|
// So we just write lowest 64 bits of that value.
|
|
17096
|
-
setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
|
|
16550
|
+
setBigUint64$1(view, blockLen - 8, BigInt(this.length * 8), isLE);
|
|
17097
16551
|
this.process(view, 0);
|
|
17098
|
-
const oview = createView(out);
|
|
16552
|
+
const oview = createView$1(out);
|
|
17099
16553
|
const len = this.outputLen;
|
|
17100
16554
|
// NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT
|
|
17101
16555
|
if (len % 4)
|
|
@@ -17131,13 +16585,13 @@ class SHA2 extends Hash {
|
|
|
17131
16585
|
// SHA2-256 need to try 2^128 hashes to execute birthday attack.
|
|
17132
16586
|
// BTC network is doing 2^67 hashes/sec as per early 2023.
|
|
17133
16587
|
// Choice: a ? b : c
|
|
17134
|
-
const Chi = (a, b, c) => (a & b) ^ (~a & c);
|
|
16588
|
+
const Chi$1 = (a, b, c) => (a & b) ^ (~a & c);
|
|
17135
16589
|
// Majority function, true if any two inpust is true
|
|
17136
|
-
const Maj = (a, b, c) => (a & b) ^ (a & c) ^ (b & c);
|
|
16590
|
+
const Maj$1 = (a, b, c) => (a & b) ^ (a & c) ^ (b & c);
|
|
17137
16591
|
// Round constants:
|
|
17138
16592
|
// first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311)
|
|
17139
16593
|
// prettier-ignore
|
|
17140
|
-
const SHA256_K = /* @__PURE__ */ new Uint32Array([
|
|
16594
|
+
const SHA256_K$1 = /* @__PURE__ */ new Uint32Array([
|
|
17141
16595
|
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
17142
16596
|
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
17143
16597
|
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
@@ -17154,8 +16608,8 @@ const IV = /* @__PURE__ */ new Uint32Array([
|
|
|
17154
16608
|
]);
|
|
17155
16609
|
// Temporary buffer, not used to store anything between runs
|
|
17156
16610
|
// Named this way because it matches specification.
|
|
17157
|
-
const SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
17158
|
-
class SHA256 extends SHA2 {
|
|
16611
|
+
const SHA256_W$1 = /* @__PURE__ */ new Uint32Array(64);
|
|
16612
|
+
let SHA256$1 = class SHA256 extends SHA2 {
|
|
17159
16613
|
constructor() {
|
|
17160
16614
|
super(64, 32, 8, false);
|
|
17161
16615
|
// We cannot use array here since array allows indexing by variable
|
|
@@ -17187,21 +16641,21 @@ class SHA256 extends SHA2 {
|
|
|
17187
16641
|
process(view, offset) {
|
|
17188
16642
|
// Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array
|
|
17189
16643
|
for (let i = 0; i < 16; i++, offset += 4)
|
|
17190
|
-
SHA256_W[i] = view.getUint32(offset, false);
|
|
16644
|
+
SHA256_W$1[i] = view.getUint32(offset, false);
|
|
17191
16645
|
for (let i = 16; i < 64; i++) {
|
|
17192
|
-
const W15 = SHA256_W[i - 15];
|
|
17193
|
-
const W2 = SHA256_W[i - 2];
|
|
17194
|
-
const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ (W15 >>> 3);
|
|
17195
|
-
const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ (W2 >>> 10);
|
|
17196
|
-
SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;
|
|
16646
|
+
const W15 = SHA256_W$1[i - 15];
|
|
16647
|
+
const W2 = SHA256_W$1[i - 2];
|
|
16648
|
+
const s0 = rotr$1(W15, 7) ^ rotr$1(W15, 18) ^ (W15 >>> 3);
|
|
16649
|
+
const s1 = rotr$1(W2, 17) ^ rotr$1(W2, 19) ^ (W2 >>> 10);
|
|
16650
|
+
SHA256_W$1[i] = (s1 + SHA256_W$1[i - 7] + s0 + SHA256_W$1[i - 16]) | 0;
|
|
17197
16651
|
}
|
|
17198
16652
|
// Compression function main loop, 64 rounds
|
|
17199
16653
|
let { A, B, C, D, E, F, G, H } = this;
|
|
17200
16654
|
for (let i = 0; i < 64; i++) {
|
|
17201
|
-
const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
|
|
17202
|
-
const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;
|
|
17203
|
-
const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
|
|
17204
|
-
const T2 = (sigma0 + Maj(A, B, C)) | 0;
|
|
16655
|
+
const sigma1 = rotr$1(E, 6) ^ rotr$1(E, 11) ^ rotr$1(E, 25);
|
|
16656
|
+
const T1 = (H + sigma1 + Chi$1(E, F, G) + SHA256_K$1[i] + SHA256_W$1[i]) | 0;
|
|
16657
|
+
const sigma0 = rotr$1(A, 2) ^ rotr$1(A, 13) ^ rotr$1(A, 22);
|
|
16658
|
+
const T2 = (sigma0 + Maj$1(A, B, C)) | 0;
|
|
17205
16659
|
H = G;
|
|
17206
16660
|
G = F;
|
|
17207
16661
|
F = E;
|
|
@@ -17223,37 +16677,37 @@ class SHA256 extends SHA2 {
|
|
|
17223
16677
|
this.set(A, B, C, D, E, F, G, H);
|
|
17224
16678
|
}
|
|
17225
16679
|
roundClean() {
|
|
17226
|
-
SHA256_W.fill(0);
|
|
16680
|
+
SHA256_W$1.fill(0);
|
|
17227
16681
|
}
|
|
17228
16682
|
destroy() {
|
|
17229
16683
|
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
17230
16684
|
this.buffer.fill(0);
|
|
17231
16685
|
}
|
|
17232
|
-
}
|
|
16686
|
+
};
|
|
17233
16687
|
/**
|
|
17234
16688
|
* SHA2-256 hash function
|
|
17235
16689
|
* @param message - data that would be hashed
|
|
17236
16690
|
*/
|
|
17237
|
-
const sha256$
|
|
16691
|
+
const sha256$2 = /* @__PURE__ */ wrapConstructor(() => new SHA256$1());
|
|
17238
16692
|
|
|
17239
|
-
const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
17240
|
-
const _32n = /* @__PURE__ */ BigInt(32);
|
|
16693
|
+
const U32_MASK64$1 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
16694
|
+
const _32n$1 = /* @__PURE__ */ BigInt(32);
|
|
17241
16695
|
// We are not using BigUint64Array, because they are extremely slow as per 2022
|
|
17242
|
-
function fromBig(n, le = false) {
|
|
16696
|
+
function fromBig$1(n, le = false) {
|
|
17243
16697
|
if (le)
|
|
17244
|
-
return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };
|
|
17245
|
-
return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
|
|
16698
|
+
return { h: Number(n & U32_MASK64$1), l: Number((n >> _32n$1) & U32_MASK64$1) };
|
|
16699
|
+
return { h: Number((n >> _32n$1) & U32_MASK64$1) | 0, l: Number(n & U32_MASK64$1) | 0 };
|
|
17246
16700
|
}
|
|
17247
|
-
function split(lst, le = false) {
|
|
16701
|
+
function split$1(lst, le = false) {
|
|
17248
16702
|
let Ah = new Uint32Array(lst.length);
|
|
17249
16703
|
let Al = new Uint32Array(lst.length);
|
|
17250
16704
|
for (let i = 0; i < lst.length; i++) {
|
|
17251
|
-
const { h, l } = fromBig(lst[i], le);
|
|
16705
|
+
const { h, l } = fromBig$1(lst[i], le);
|
|
17252
16706
|
[Ah[i], Al[i]] = [h, l];
|
|
17253
16707
|
}
|
|
17254
16708
|
return [Ah, Al];
|
|
17255
16709
|
}
|
|
17256
|
-
const toBig = (h, l) => (BigInt(h >>> 0) << _32n) | BigInt(l >>> 0);
|
|
16710
|
+
const toBig = (h, l) => (BigInt(h >>> 0) << _32n$1) | BigInt(l >>> 0);
|
|
17257
16711
|
// for Shift in [0, 32)
|
|
17258
16712
|
const shrSH = (h, _l, s) => h >>> s;
|
|
17259
16713
|
const shrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);
|
|
@@ -17267,11 +16721,11 @@ const rotrBL = (h, l, s) => (h >>> (s - 32)) | (l << (64 - s));
|
|
|
17267
16721
|
const rotr32H = (_h, l) => l;
|
|
17268
16722
|
const rotr32L = (h, _l) => h;
|
|
17269
16723
|
// Left rotate for Shift in [1, 32)
|
|
17270
|
-
const rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s));
|
|
17271
|
-
const rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s));
|
|
16724
|
+
const rotlSH$1 = (h, l, s) => (h << s) | (l >>> (32 - s));
|
|
16725
|
+
const rotlSL$1 = (h, l, s) => (l << s) | (h >>> (32 - s));
|
|
17272
16726
|
// Left rotate for Shift in (32, 64), NOTE: 32 is special case.
|
|
17273
|
-
const rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));
|
|
17274
|
-
const rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));
|
|
16727
|
+
const rotlBH$1 = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));
|
|
16728
|
+
const rotlBL$1 = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));
|
|
17275
16729
|
// JS uses 32-bit signed integers for bitwise operations which means we cannot
|
|
17276
16730
|
// simple take carry out of low bit sum by shift, we need to use division.
|
|
17277
16731
|
function add(Ah, Al, Bh, Bl) {
|
|
@@ -17287,11 +16741,11 @@ const add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl
|
|
|
17287
16741
|
const add5H = (low, Ah, Bh, Ch, Dh, Eh) => (Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0;
|
|
17288
16742
|
// prettier-ignore
|
|
17289
16743
|
const u64 = {
|
|
17290
|
-
fromBig, split, toBig,
|
|
16744
|
+
fromBig: fromBig$1, split: split$1, toBig,
|
|
17291
16745
|
shrSH, shrSL,
|
|
17292
16746
|
rotrSH, rotrSL, rotrBH, rotrBL,
|
|
17293
16747
|
rotr32H, rotr32L,
|
|
17294
|
-
rotlSH, rotlSL, rotlBH, rotlBL,
|
|
16748
|
+
rotlSH: rotlSH$1, rotlSL: rotlSL$1, rotlBH: rotlBH$1, rotlBL: rotlBL$1,
|
|
17295
16749
|
add, add3L, add3H, add4L, add4H, add5H, add5L,
|
|
17296
16750
|
};
|
|
17297
16751
|
|
|
@@ -17468,7 +16922,7 @@ const anyGlobal = getGlobal();
|
|
|
17468
16922
|
anyGlobal.crypto || anyGlobal.msCrypto;
|
|
17469
16923
|
function createHash(algo) {
|
|
17470
16924
|
switch (algo) {
|
|
17471
|
-
case "sha256": return sha256$
|
|
16925
|
+
case "sha256": return sha256$2.create();
|
|
17472
16926
|
case "sha512": return sha512.create();
|
|
17473
16927
|
}
|
|
17474
16928
|
assertArgument(false, "invalid hashing algorithm name", "algorithm", algo);
|
|
@@ -17499,10 +16953,10 @@ for (let round = 0, R = _1n$b, x = 1, y = 0; round < 24; round++) {
|
|
|
17499
16953
|
}
|
|
17500
16954
|
_SHA3_IOTA$1.push(t);
|
|
17501
16955
|
}
|
|
17502
|
-
const [SHA3_IOTA_H$1, SHA3_IOTA_L$1] = /* @__PURE__ */ split(_SHA3_IOTA$1, true);
|
|
16956
|
+
const [SHA3_IOTA_H$1, SHA3_IOTA_L$1] = /* @__PURE__ */ split$1(_SHA3_IOTA$1, true);
|
|
17503
16957
|
// Left rotation (without 0, 32, 64)
|
|
17504
|
-
const rotlH$1 = (h, l, s) => (s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s));
|
|
17505
|
-
const rotlL$1 = (h, l, s) => (s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s));
|
|
16958
|
+
const rotlH$1 = (h, l, s) => (s > 32 ? rotlBH$1(h, l, s) : rotlSH$1(h, l, s));
|
|
16959
|
+
const rotlL$1 = (h, l, s) => (s > 32 ? rotlBL$1(h, l, s) : rotlSL$1(h, l, s));
|
|
17506
16960
|
// Same as keccakf1600, but allows to skip some rounds
|
|
17507
16961
|
function keccakP$1(s, rounds = 24) {
|
|
17508
16962
|
const B = new Uint32Array(5 * 2);
|
|
@@ -17549,7 +17003,7 @@ function keccakP$1(s, rounds = 24) {
|
|
|
17549
17003
|
}
|
|
17550
17004
|
B.fill(0);
|
|
17551
17005
|
}
|
|
17552
|
-
let Keccak$1 = class Keccak extends Hash {
|
|
17006
|
+
let Keccak$1 = class Keccak extends Hash$1 {
|
|
17553
17007
|
// NOTE: we accept arguments in bytes instead of bits here.
|
|
17554
17008
|
constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {
|
|
17555
17009
|
super();
|
|
@@ -17568,7 +17022,7 @@ let Keccak$1 = class Keccak extends Hash {
|
|
|
17568
17022
|
if (0 >= this.blockLen || this.blockLen >= 200)
|
|
17569
17023
|
throw new Error('Sha3 supports only keccak-f1600 function');
|
|
17570
17024
|
this.state = new Uint8Array(200);
|
|
17571
|
-
this.state32 = u32(this.state);
|
|
17025
|
+
this.state32 = u32$1(this.state);
|
|
17572
17026
|
}
|
|
17573
17027
|
keccak() {
|
|
17574
17028
|
keccakP$1(this.state32, this.rounds);
|
|
@@ -17578,7 +17032,7 @@ let Keccak$1 = class Keccak extends Hash {
|
|
|
17578
17032
|
update(data) {
|
|
17579
17033
|
exists(this);
|
|
17580
17034
|
const { blockLen, state } = this;
|
|
17581
|
-
data = toBytes(data);
|
|
17035
|
+
data = toBytes$1(data);
|
|
17582
17036
|
const len = data.length;
|
|
17583
17037
|
for (let pos = 0; pos < len;) {
|
|
17584
17038
|
const take = Math.min(blockLen - this.pos, len - pos);
|
|
@@ -17733,20 +17187,20 @@ let locked256 = false;
|
|
|
17733
17187
|
* //_result:
|
|
17734
17188
|
*
|
|
17735
17189
|
*/
|
|
17736
|
-
function sha256(_data) {
|
|
17190
|
+
function sha256$1(_data) {
|
|
17737
17191
|
const data = getBytes(_data, "data");
|
|
17738
17192
|
return hexlify(__sha256(data));
|
|
17739
17193
|
}
|
|
17740
|
-
sha256._ = _sha256;
|
|
17741
|
-
sha256.lock = function () { locked256 = true; };
|
|
17742
|
-
sha256.register = function (func) {
|
|
17194
|
+
sha256$1._ = _sha256;
|
|
17195
|
+
sha256$1.lock = function () { locked256 = true; };
|
|
17196
|
+
sha256$1.register = function (func) {
|
|
17743
17197
|
if (locked256) {
|
|
17744
17198
|
throw new Error("sha256 is locked");
|
|
17745
17199
|
}
|
|
17746
17200
|
__sha256 = func;
|
|
17747
17201
|
};
|
|
17748
|
-
Object.freeze(sha256);
|
|
17749
|
-
Object.freeze(sha256);
|
|
17202
|
+
Object.freeze(sha256$1);
|
|
17203
|
+
Object.freeze(sha256$1);
|
|
17750
17204
|
|
|
17751
17205
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
17752
17206
|
// 100 lines of code in the file are duplicated from noble-hashes (utils).
|
|
@@ -17855,7 +17309,7 @@ function ensureBytes$1(title, hex, expectedLength) {
|
|
|
17855
17309
|
/**
|
|
17856
17310
|
* Copies several Uint8Arrays into one.
|
|
17857
17311
|
*/
|
|
17858
|
-
function concatBytes$
|
|
17312
|
+
function concatBytes$2(...arrays) {
|
|
17859
17313
|
const r = new Uint8Array(arrays.reduce((sum, a) => sum + a.length, 0));
|
|
17860
17314
|
let pad = 0; // walk through each item, ensure they have proper type
|
|
17861
17315
|
arrays.forEach((a) => {
|
|
@@ -17878,7 +17332,7 @@ function equalBytes(b1, b2) {
|
|
|
17878
17332
|
/**
|
|
17879
17333
|
* @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
|
|
17880
17334
|
*/
|
|
17881
|
-
function utf8ToBytes(str) {
|
|
17335
|
+
function utf8ToBytes$1(str) {
|
|
17882
17336
|
if (typeof str !== 'string')
|
|
17883
17337
|
throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
|
|
17884
17338
|
return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
|
|
@@ -17961,7 +17415,7 @@ function createHmacDrbg$1(hashLen, qByteLen, hmacFn) {
|
|
|
17961
17415
|
out.push(sl);
|
|
17962
17416
|
len += v.length;
|
|
17963
17417
|
}
|
|
17964
|
-
return concatBytes$
|
|
17418
|
+
return concatBytes$2(...out);
|
|
17965
17419
|
};
|
|
17966
17420
|
const genUntil = (seed, pred) => {
|
|
17967
17421
|
reset();
|
|
@@ -18023,7 +17477,7 @@ var ut$4 = /*#__PURE__*/Object.freeze({
|
|
|
18023
17477
|
bytesToHex: bytesToHex$1,
|
|
18024
17478
|
bytesToNumberBE: bytesToNumberBE$1,
|
|
18025
17479
|
bytesToNumberLE: bytesToNumberLE$1,
|
|
18026
|
-
concatBytes: concatBytes$
|
|
17480
|
+
concatBytes: concatBytes$2,
|
|
18027
17481
|
createHmacDrbg: createHmacDrbg$1,
|
|
18028
17482
|
ensureBytes: ensureBytes$1,
|
|
18029
17483
|
equalBytes: equalBytes,
|
|
@@ -18033,7 +17487,7 @@ var ut$4 = /*#__PURE__*/Object.freeze({
|
|
|
18033
17487
|
numberToBytesLE: numberToBytesLE$1,
|
|
18034
17488
|
numberToHexUnpadded: numberToHexUnpadded$1,
|
|
18035
17489
|
numberToVarBytesBE: numberToVarBytesBE,
|
|
18036
|
-
utf8ToBytes: utf8ToBytes,
|
|
17490
|
+
utf8ToBytes: utf8ToBytes$1,
|
|
18037
17491
|
validateObject: validateObject$1
|
|
18038
17492
|
});
|
|
18039
17493
|
|
|
@@ -18641,7 +18095,7 @@ function weierstrassPoints$1(opts) {
|
|
|
18641
18095
|
const toBytes = CURVE.toBytes ||
|
|
18642
18096
|
((_c, point, _isCompressed) => {
|
|
18643
18097
|
const a = point.toAffine();
|
|
18644
|
-
return concatBytes$
|
|
18098
|
+
return concatBytes$2(Uint8Array.from([0x04]), Fp.toBytes(a.x), Fp.toBytes(a.y));
|
|
18645
18099
|
});
|
|
18646
18100
|
const fromBytes = CURVE.fromBytes ||
|
|
18647
18101
|
((bytes) => {
|
|
@@ -19094,7 +18548,7 @@ function weierstrass$1(curveDef) {
|
|
|
19094
18548
|
toBytes(_c, point, isCompressed) {
|
|
19095
18549
|
const a = point.toAffine();
|
|
19096
18550
|
const x = Fp.toBytes(a.x);
|
|
19097
|
-
const cat = concatBytes$
|
|
18551
|
+
const cat = concatBytes$2;
|
|
19098
18552
|
if (isCompressed) {
|
|
19099
18553
|
return cat(Uint8Array.from([point.hasEvenY() ? 0x02 : 0x03]), x);
|
|
19100
18554
|
}
|
|
@@ -19344,7 +18798,7 @@ function weierstrass$1(curveDef) {
|
|
|
19344
18798
|
const e = ent === true ? randomBytes(Fp.BYTES) : ent; // generate random bytes OR pass as-is
|
|
19345
18799
|
seedArgs.push(ensureBytes$1('extraEntropy', e)); // check for being bytes
|
|
19346
18800
|
}
|
|
19347
|
-
const seed = concatBytes$
|
|
18801
|
+
const seed = concatBytes$2(...seedArgs); // Step D of RFC6979 3.2
|
|
19348
18802
|
const m = h1int; // NOTE: no need to call bits2int second time here, it is inside truncateHash!
|
|
19349
18803
|
// Converts signature params into point w r/s, checks result for validity.
|
|
19350
18804
|
function k2sig(kBytes) {
|
|
@@ -19478,8 +18932,8 @@ function weierstrass$1(curveDef) {
|
|
|
19478
18932
|
function getHash$1(hash) {
|
|
19479
18933
|
return {
|
|
19480
18934
|
hash,
|
|
19481
|
-
hmac: (key, ...msgs) => hmac$1(hash, key, concatBytes$
|
|
19482
|
-
randomBytes,
|
|
18935
|
+
hmac: (key, ...msgs) => hmac$1(hash, key, concatBytes$3(...msgs)),
|
|
18936
|
+
randomBytes: randomBytes$1,
|
|
19483
18937
|
};
|
|
19484
18938
|
}
|
|
19485
18939
|
function createCurve$1(curveDef, defHash) {
|
|
@@ -19563,7 +19017,7 @@ const secp256k1$1 = createCurve$1({
|
|
|
19563
19017
|
return { k1neg, k1, k2neg, k2 };
|
|
19564
19018
|
},
|
|
19565
19019
|
},
|
|
19566
|
-
}, sha256$
|
|
19020
|
+
}, sha256$2);
|
|
19567
19021
|
// Schnorr signatures are superior to ECDSA from above. Below is Schnorr-specific BIP0340 code.
|
|
19568
19022
|
// https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki
|
|
19569
19023
|
BigInt(0);
|
|
@@ -20299,7 +19753,7 @@ function getVersionedHash(version, hash) {
|
|
|
20299
19753
|
while (versioned.length < 2) {
|
|
20300
19754
|
versioned = "0" + versioned;
|
|
20301
19755
|
}
|
|
20302
|
-
versioned += sha256(hash).substring(4);
|
|
19756
|
+
versioned += sha256$1(hash).substring(4);
|
|
20303
19757
|
return "0x" + versioned;
|
|
20304
19758
|
}
|
|
20305
19759
|
function handleAddress(value) {
|
|
@@ -21388,6 +20842,133 @@ class Transaction {
|
|
|
21388
20842
|
}
|
|
21389
20843
|
}
|
|
21390
20844
|
|
|
20845
|
+
// base-x encoding / decoding
|
|
20846
|
+
// Copyright (c) 2018 base-x contributors
|
|
20847
|
+
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
|
20848
|
+
// Distributed under the MIT software license, see the accompanying
|
|
20849
|
+
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
|
20850
|
+
function base$1 (ALPHABET) {
|
|
20851
|
+
if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
|
|
20852
|
+
const BASE_MAP = new Uint8Array(256);
|
|
20853
|
+
for (let j = 0; j < BASE_MAP.length; j++) {
|
|
20854
|
+
BASE_MAP[j] = 255;
|
|
20855
|
+
}
|
|
20856
|
+
for (let i = 0; i < ALPHABET.length; i++) {
|
|
20857
|
+
const x = ALPHABET.charAt(i);
|
|
20858
|
+
const xc = x.charCodeAt(0);
|
|
20859
|
+
if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
|
|
20860
|
+
BASE_MAP[xc] = i;
|
|
20861
|
+
}
|
|
20862
|
+
const BASE = ALPHABET.length;
|
|
20863
|
+
const LEADER = ALPHABET.charAt(0);
|
|
20864
|
+
const FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
|
|
20865
|
+
const iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
|
|
20866
|
+
function encode (source) {
|
|
20867
|
+
// eslint-disable-next-line no-empty
|
|
20868
|
+
if (source instanceof Uint8Array) ; else if (ArrayBuffer.isView(source)) {
|
|
20869
|
+
source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
20870
|
+
} else if (Array.isArray(source)) {
|
|
20871
|
+
source = Uint8Array.from(source);
|
|
20872
|
+
}
|
|
20873
|
+
if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') }
|
|
20874
|
+
if (source.length === 0) { return '' }
|
|
20875
|
+
// Skip & count leading zeroes.
|
|
20876
|
+
let zeroes = 0;
|
|
20877
|
+
let length = 0;
|
|
20878
|
+
let pbegin = 0;
|
|
20879
|
+
const pend = source.length;
|
|
20880
|
+
while (pbegin !== pend && source[pbegin] === 0) {
|
|
20881
|
+
pbegin++;
|
|
20882
|
+
zeroes++;
|
|
20883
|
+
}
|
|
20884
|
+
// Allocate enough space in big-endian base58 representation.
|
|
20885
|
+
const size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
|
|
20886
|
+
const b58 = new Uint8Array(size);
|
|
20887
|
+
// Process the bytes.
|
|
20888
|
+
while (pbegin !== pend) {
|
|
20889
|
+
let carry = source[pbegin];
|
|
20890
|
+
// Apply "b58 = b58 * 256 + ch".
|
|
20891
|
+
let i = 0;
|
|
20892
|
+
for (let it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
|
|
20893
|
+
carry += (256 * b58[it1]) >>> 0;
|
|
20894
|
+
b58[it1] = (carry % BASE) >>> 0;
|
|
20895
|
+
carry = (carry / BASE) >>> 0;
|
|
20896
|
+
}
|
|
20897
|
+
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
20898
|
+
length = i;
|
|
20899
|
+
pbegin++;
|
|
20900
|
+
}
|
|
20901
|
+
// Skip leading zeroes in base58 result.
|
|
20902
|
+
let it2 = size - length;
|
|
20903
|
+
while (it2 !== size && b58[it2] === 0) {
|
|
20904
|
+
it2++;
|
|
20905
|
+
}
|
|
20906
|
+
// Translate the result into a string.
|
|
20907
|
+
let str = LEADER.repeat(zeroes);
|
|
20908
|
+
for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }
|
|
20909
|
+
return str
|
|
20910
|
+
}
|
|
20911
|
+
function decodeUnsafe (source) {
|
|
20912
|
+
if (typeof source !== 'string') { throw new TypeError('Expected String') }
|
|
20913
|
+
if (source.length === 0) { return new Uint8Array() }
|
|
20914
|
+
let psz = 0;
|
|
20915
|
+
// Skip and count leading '1's.
|
|
20916
|
+
let zeroes = 0;
|
|
20917
|
+
let length = 0;
|
|
20918
|
+
while (source[psz] === LEADER) {
|
|
20919
|
+
zeroes++;
|
|
20920
|
+
psz++;
|
|
20921
|
+
}
|
|
20922
|
+
// Allocate enough space in big-endian base256 representation.
|
|
20923
|
+
const size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
|
|
20924
|
+
const b256 = new Uint8Array(size);
|
|
20925
|
+
// Process the characters.
|
|
20926
|
+
while (psz < source.length) {
|
|
20927
|
+
// Find code of next character
|
|
20928
|
+
const charCode = source.charCodeAt(psz);
|
|
20929
|
+
// Base map can not be indexed using char code
|
|
20930
|
+
if (charCode > 255) { return }
|
|
20931
|
+
// Decode character
|
|
20932
|
+
let carry = BASE_MAP[charCode];
|
|
20933
|
+
// Invalid character
|
|
20934
|
+
if (carry === 255) { return }
|
|
20935
|
+
let i = 0;
|
|
20936
|
+
for (let it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
|
|
20937
|
+
carry += (BASE * b256[it3]) >>> 0;
|
|
20938
|
+
b256[it3] = (carry % 256) >>> 0;
|
|
20939
|
+
carry = (carry / 256) >>> 0;
|
|
20940
|
+
}
|
|
20941
|
+
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
20942
|
+
length = i;
|
|
20943
|
+
psz++;
|
|
20944
|
+
}
|
|
20945
|
+
// Skip leading zeroes in b256.
|
|
20946
|
+
let it4 = size - length;
|
|
20947
|
+
while (it4 !== size && b256[it4] === 0) {
|
|
20948
|
+
it4++;
|
|
20949
|
+
}
|
|
20950
|
+
const vch = new Uint8Array(zeroes + (size - it4));
|
|
20951
|
+
let j = zeroes;
|
|
20952
|
+
while (it4 !== size) {
|
|
20953
|
+
vch[j++] = b256[it4++];
|
|
20954
|
+
}
|
|
20955
|
+
return vch
|
|
20956
|
+
}
|
|
20957
|
+
function decode (string) {
|
|
20958
|
+
const buffer = decodeUnsafe(string);
|
|
20959
|
+
if (buffer) { return buffer }
|
|
20960
|
+
throw new Error('Non-base' + BASE + ' character')
|
|
20961
|
+
}
|
|
20962
|
+
return {
|
|
20963
|
+
encode,
|
|
20964
|
+
decodeUnsafe,
|
|
20965
|
+
decode
|
|
20966
|
+
}
|
|
20967
|
+
}
|
|
20968
|
+
|
|
20969
|
+
var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
20970
|
+
var ue$3 = base$1(ALPHABET);
|
|
20971
|
+
|
|
21391
20972
|
// src/index.ts
|
|
21392
20973
|
function parseSignMessageResponse(base64Response, networkId) {
|
|
21393
20974
|
const networkPrefix = networkId.split(":")[0].toLowerCase();
|
|
@@ -25682,6 +25263,183 @@ class PhantomWalletProvider {
|
|
|
25682
25263
|
}
|
|
25683
25264
|
}
|
|
25684
25265
|
|
|
25266
|
+
/**
|
|
25267
|
+
* Internal helpers for u64. BigUint64Array is too slow as per 2025, so we implement it using Uint32Array.
|
|
25268
|
+
* @todo re-check https://issues.chromium.org/issues/42212588
|
|
25269
|
+
* @module
|
|
25270
|
+
*/
|
|
25271
|
+
const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
25272
|
+
const _32n = /* @__PURE__ */ BigInt(32);
|
|
25273
|
+
function fromBig(n, le = false) {
|
|
25274
|
+
if (le)
|
|
25275
|
+
return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };
|
|
25276
|
+
return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
|
|
25277
|
+
}
|
|
25278
|
+
function split(lst, le = false) {
|
|
25279
|
+
const len = lst.length;
|
|
25280
|
+
let Ah = new Uint32Array(len);
|
|
25281
|
+
let Al = new Uint32Array(len);
|
|
25282
|
+
for (let i = 0; i < len; i++) {
|
|
25283
|
+
const { h, l } = fromBig(lst[i], le);
|
|
25284
|
+
[Ah[i], Al[i]] = [h, l];
|
|
25285
|
+
}
|
|
25286
|
+
return [Ah, Al];
|
|
25287
|
+
}
|
|
25288
|
+
// Left rotate for Shift in [1, 32)
|
|
25289
|
+
const rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s));
|
|
25290
|
+
const rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s));
|
|
25291
|
+
// Left rotate for Shift in (32, 64), NOTE: 32 is special case.
|
|
25292
|
+
const rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));
|
|
25293
|
+
const rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));
|
|
25294
|
+
|
|
25295
|
+
const crypto$2 = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined;
|
|
25296
|
+
|
|
25297
|
+
/**
|
|
25298
|
+
* Utilities for hex, bytes, CSPRNG.
|
|
25299
|
+
* @module
|
|
25300
|
+
*/
|
|
25301
|
+
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
25302
|
+
// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.
|
|
25303
|
+
// node.js versions earlier than v19 don't declare it in global scope.
|
|
25304
|
+
// For node.js, package.json#exports field mapping rewrites import
|
|
25305
|
+
// from `crypto` to `cryptoNode`, which imports native module.
|
|
25306
|
+
// Makes the utils un-importable in browsers without a bundler.
|
|
25307
|
+
// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.
|
|
25308
|
+
/** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */
|
|
25309
|
+
function isBytes$2(a) {
|
|
25310
|
+
return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');
|
|
25311
|
+
}
|
|
25312
|
+
/** Asserts something is positive integer. */
|
|
25313
|
+
function anumber$1(n) {
|
|
25314
|
+
if (!Number.isSafeInteger(n) || n < 0)
|
|
25315
|
+
throw new Error('positive integer expected, got ' + n);
|
|
25316
|
+
}
|
|
25317
|
+
/** Asserts something is Uint8Array. */
|
|
25318
|
+
function abytes$2(b, ...lengths) {
|
|
25319
|
+
if (!isBytes$2(b))
|
|
25320
|
+
throw new Error('Uint8Array expected');
|
|
25321
|
+
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
25322
|
+
throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length);
|
|
25323
|
+
}
|
|
25324
|
+
/** Asserts something is hash */
|
|
25325
|
+
function ahash(h) {
|
|
25326
|
+
if (typeof h !== 'function' || typeof h.create !== 'function')
|
|
25327
|
+
throw new Error('Hash should be wrapped by utils.createHasher');
|
|
25328
|
+
anumber$1(h.outputLen);
|
|
25329
|
+
anumber$1(h.blockLen);
|
|
25330
|
+
}
|
|
25331
|
+
/** Asserts a hash instance has not been destroyed / finished */
|
|
25332
|
+
function aexists(instance, checkFinished = true) {
|
|
25333
|
+
if (instance.destroyed)
|
|
25334
|
+
throw new Error('Hash instance has been destroyed');
|
|
25335
|
+
if (checkFinished && instance.finished)
|
|
25336
|
+
throw new Error('Hash#digest() has already been called');
|
|
25337
|
+
}
|
|
25338
|
+
/** Asserts output is properly-sized byte array */
|
|
25339
|
+
function aoutput(out, instance) {
|
|
25340
|
+
abytes$2(out);
|
|
25341
|
+
const min = instance.outputLen;
|
|
25342
|
+
if (out.length < min) {
|
|
25343
|
+
throw new Error('digestInto() expects output buffer of length at least ' + min);
|
|
25344
|
+
}
|
|
25345
|
+
}
|
|
25346
|
+
/** Cast u8 / u16 / u32 to u32. */
|
|
25347
|
+
function u32(arr) {
|
|
25348
|
+
return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
25349
|
+
}
|
|
25350
|
+
/** Zeroize a byte array. Warning: JS provides no guarantees. */
|
|
25351
|
+
function clean(...arrays) {
|
|
25352
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
25353
|
+
arrays[i].fill(0);
|
|
25354
|
+
}
|
|
25355
|
+
}
|
|
25356
|
+
/** Create DataView of an array for easy byte-level manipulation. */
|
|
25357
|
+
function createView(arr) {
|
|
25358
|
+
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
25359
|
+
}
|
|
25360
|
+
/** The rotate right (circular right shift) operation for uint32 */
|
|
25361
|
+
function rotr(word, shift) {
|
|
25362
|
+
return (word << (32 - shift)) | (word >>> shift);
|
|
25363
|
+
}
|
|
25364
|
+
/** Is current platform little-endian? Most are. Big-Endian platform: IBM */
|
|
25365
|
+
const isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)();
|
|
25366
|
+
/** The byte swap operation for uint32 */
|
|
25367
|
+
function byteSwap(word) {
|
|
25368
|
+
return (((word << 24) & 0xff000000) |
|
|
25369
|
+
((word << 8) & 0xff0000) |
|
|
25370
|
+
((word >>> 8) & 0xff00) |
|
|
25371
|
+
((word >>> 24) & 0xff));
|
|
25372
|
+
}
|
|
25373
|
+
/** In place byte swap for Uint32Array */
|
|
25374
|
+
function byteSwap32(arr) {
|
|
25375
|
+
for (let i = 0; i < arr.length; i++) {
|
|
25376
|
+
arr[i] = byteSwap(arr[i]);
|
|
25377
|
+
}
|
|
25378
|
+
return arr;
|
|
25379
|
+
}
|
|
25380
|
+
const swap32IfBE = isLE
|
|
25381
|
+
? (u) => u
|
|
25382
|
+
: byteSwap32;
|
|
25383
|
+
/**
|
|
25384
|
+
* Converts string to bytes using UTF8 encoding.
|
|
25385
|
+
* @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99])
|
|
25386
|
+
*/
|
|
25387
|
+
function utf8ToBytes(str) {
|
|
25388
|
+
if (typeof str !== 'string')
|
|
25389
|
+
throw new Error('string expected');
|
|
25390
|
+
return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
|
|
25391
|
+
}
|
|
25392
|
+
/**
|
|
25393
|
+
* Normalizes (non-hex) string or Uint8Array to Uint8Array.
|
|
25394
|
+
* Warning: when Uint8Array is passed, it would NOT get copied.
|
|
25395
|
+
* Keep in mind for future mutable operations.
|
|
25396
|
+
*/
|
|
25397
|
+
function toBytes(data) {
|
|
25398
|
+
if (typeof data === 'string')
|
|
25399
|
+
data = utf8ToBytes(data);
|
|
25400
|
+
abytes$2(data);
|
|
25401
|
+
return data;
|
|
25402
|
+
}
|
|
25403
|
+
/** Copies several Uint8Arrays into one. */
|
|
25404
|
+
function concatBytes$1(...arrays) {
|
|
25405
|
+
let sum = 0;
|
|
25406
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
25407
|
+
const a = arrays[i];
|
|
25408
|
+
abytes$2(a);
|
|
25409
|
+
sum += a.length;
|
|
25410
|
+
}
|
|
25411
|
+
const res = new Uint8Array(sum);
|
|
25412
|
+
for (let i = 0, pad = 0; i < arrays.length; i++) {
|
|
25413
|
+
const a = arrays[i];
|
|
25414
|
+
res.set(a, pad);
|
|
25415
|
+
pad += a.length;
|
|
25416
|
+
}
|
|
25417
|
+
return res;
|
|
25418
|
+
}
|
|
25419
|
+
/** For runtime check if class implements interface */
|
|
25420
|
+
class Hash {
|
|
25421
|
+
}
|
|
25422
|
+
/** Wraps hash function, creating an interface on top of it */
|
|
25423
|
+
function createHasher(hashCons) {
|
|
25424
|
+
const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
|
|
25425
|
+
const tmp = hashCons();
|
|
25426
|
+
hashC.outputLen = tmp.outputLen;
|
|
25427
|
+
hashC.blockLen = tmp.blockLen;
|
|
25428
|
+
hashC.create = () => hashCons();
|
|
25429
|
+
return hashC;
|
|
25430
|
+
}
|
|
25431
|
+
/** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */
|
|
25432
|
+
function randomBytes(bytesLength = 32) {
|
|
25433
|
+
if (crypto$2 && typeof crypto$2.getRandomValues === 'function') {
|
|
25434
|
+
return crypto$2.getRandomValues(new Uint8Array(bytesLength));
|
|
25435
|
+
}
|
|
25436
|
+
// Legacy Node.js compatibility
|
|
25437
|
+
if (crypto$2 && typeof crypto$2.randomBytes === 'function') {
|
|
25438
|
+
return Uint8Array.from(crypto$2.randomBytes(bytesLength));
|
|
25439
|
+
}
|
|
25440
|
+
throw new Error('crypto.getRandomValues must be defined');
|
|
25441
|
+
}
|
|
25442
|
+
|
|
25685
25443
|
/**
|
|
25686
25444
|
* SHA3 (keccak) hash function, based on a new "Sponge function" design.
|
|
25687
25445
|
* Different from older hashes, the internal state is bigger than output size.
|
|
@@ -25720,12 +25478,12 @@ for (let round = 0, R = _1n$5, x = 1, y = 0; round < 24; round++) {
|
|
|
25720
25478
|
}
|
|
25721
25479
|
_SHA3_IOTA.push(t);
|
|
25722
25480
|
}
|
|
25723
|
-
const IOTAS = split
|
|
25481
|
+
const IOTAS = split(_SHA3_IOTA, true);
|
|
25724
25482
|
const SHA3_IOTA_H = IOTAS[0];
|
|
25725
25483
|
const SHA3_IOTA_L = IOTAS[1];
|
|
25726
25484
|
// Left rotation (without 0, 32, 64)
|
|
25727
|
-
const rotlH = (h, l, s) => (s > 32 ? rotlBH
|
|
25728
|
-
const rotlL = (h, l, s) => (s > 32 ? rotlBL
|
|
25485
|
+
const rotlH = (h, l, s) => (s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s));
|
|
25486
|
+
const rotlL = (h, l, s) => (s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s));
|
|
25729
25487
|
/** `keccakf1600` internal function, additionally allows to adjust round count. */
|
|
25730
25488
|
function keccakP(s, rounds = 24) {
|
|
25731
25489
|
const B = new Uint32Array(5 * 2);
|
|
@@ -25773,7 +25531,7 @@ function keccakP(s, rounds = 24) {
|
|
|
25773
25531
|
clean(B);
|
|
25774
25532
|
}
|
|
25775
25533
|
/** Keccak sponge function. */
|
|
25776
|
-
class Keccak extends Hash
|
|
25534
|
+
class Keccak extends Hash {
|
|
25777
25535
|
// NOTE: we accept arguments in bytes instead of bits here.
|
|
25778
25536
|
constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {
|
|
25779
25537
|
super();
|
|
@@ -25794,7 +25552,7 @@ class Keccak extends Hash$1 {
|
|
|
25794
25552
|
if (!(0 < blockLen && blockLen < 200))
|
|
25795
25553
|
throw new Error('only keccak-f1600 function is supported');
|
|
25796
25554
|
this.state = new Uint8Array(200);
|
|
25797
|
-
this.state32 = u32
|
|
25555
|
+
this.state32 = u32(this.state);
|
|
25798
25556
|
}
|
|
25799
25557
|
clone() {
|
|
25800
25558
|
return this._cloneInto();
|
|
@@ -25808,7 +25566,7 @@ class Keccak extends Hash$1 {
|
|
|
25808
25566
|
}
|
|
25809
25567
|
update(data) {
|
|
25810
25568
|
aexists(this);
|
|
25811
|
-
data = toBytes
|
|
25569
|
+
data = toBytes(data);
|
|
25812
25570
|
abytes$2(data);
|
|
25813
25571
|
const { blockLen, state } = this;
|
|
25814
25572
|
const len = data.length;
|
|
@@ -25894,17 +25652,265 @@ const gen = (suffix, blockLen, outputLen) => createHasher(() => new Keccak(block
|
|
|
25894
25652
|
/** keccak-256 hash function. Different from SHA3-256. */
|
|
25895
25653
|
const keccak_256 = /* @__PURE__ */ (() => gen(0x01, 136, 256 / 8))();
|
|
25896
25654
|
|
|
25655
|
+
/**
|
|
25656
|
+
* Internal Merkle-Damgard hash utils.
|
|
25657
|
+
* @module
|
|
25658
|
+
*/
|
|
25659
|
+
/** Polyfill for Safari 14. https://caniuse.com/mdn-javascript_builtins_dataview_setbiguint64 */
|
|
25660
|
+
function setBigUint64(view, byteOffset, value, isLE) {
|
|
25661
|
+
if (typeof view.setBigUint64 === 'function')
|
|
25662
|
+
return view.setBigUint64(byteOffset, value, isLE);
|
|
25663
|
+
const _32n = BigInt(32);
|
|
25664
|
+
const _u32_max = BigInt(0xffffffff);
|
|
25665
|
+
const wh = Number((value >> _32n) & _u32_max);
|
|
25666
|
+
const wl = Number(value & _u32_max);
|
|
25667
|
+
const h = isLE ? 4 : 0;
|
|
25668
|
+
const l = isLE ? 0 : 4;
|
|
25669
|
+
view.setUint32(byteOffset + h, wh, isLE);
|
|
25670
|
+
view.setUint32(byteOffset + l, wl, isLE);
|
|
25671
|
+
}
|
|
25672
|
+
/** Choice: a ? b : c */
|
|
25673
|
+
function Chi(a, b, c) {
|
|
25674
|
+
return (a & b) ^ (~a & c);
|
|
25675
|
+
}
|
|
25676
|
+
/** Majority function, true if any two inputs is true. */
|
|
25677
|
+
function Maj(a, b, c) {
|
|
25678
|
+
return (a & b) ^ (a & c) ^ (b & c);
|
|
25679
|
+
}
|
|
25680
|
+
/**
|
|
25681
|
+
* Merkle-Damgard hash construction base class.
|
|
25682
|
+
* Could be used to create MD5, RIPEMD, SHA1, SHA2.
|
|
25683
|
+
*/
|
|
25684
|
+
class HashMD extends Hash {
|
|
25685
|
+
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
25686
|
+
super();
|
|
25687
|
+
this.finished = false;
|
|
25688
|
+
this.length = 0;
|
|
25689
|
+
this.pos = 0;
|
|
25690
|
+
this.destroyed = false;
|
|
25691
|
+
this.blockLen = blockLen;
|
|
25692
|
+
this.outputLen = outputLen;
|
|
25693
|
+
this.padOffset = padOffset;
|
|
25694
|
+
this.isLE = isLE;
|
|
25695
|
+
this.buffer = new Uint8Array(blockLen);
|
|
25696
|
+
this.view = createView(this.buffer);
|
|
25697
|
+
}
|
|
25698
|
+
update(data) {
|
|
25699
|
+
aexists(this);
|
|
25700
|
+
data = toBytes(data);
|
|
25701
|
+
abytes$2(data);
|
|
25702
|
+
const { view, buffer, blockLen } = this;
|
|
25703
|
+
const len = data.length;
|
|
25704
|
+
for (let pos = 0; pos < len;) {
|
|
25705
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
|
25706
|
+
// Fast path: we have at least one block in input, cast it to view and process
|
|
25707
|
+
if (take === blockLen) {
|
|
25708
|
+
const dataView = createView(data);
|
|
25709
|
+
for (; blockLen <= len - pos; pos += blockLen)
|
|
25710
|
+
this.process(dataView, pos);
|
|
25711
|
+
continue;
|
|
25712
|
+
}
|
|
25713
|
+
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
25714
|
+
this.pos += take;
|
|
25715
|
+
pos += take;
|
|
25716
|
+
if (this.pos === blockLen) {
|
|
25717
|
+
this.process(view, 0);
|
|
25718
|
+
this.pos = 0;
|
|
25719
|
+
}
|
|
25720
|
+
}
|
|
25721
|
+
this.length += data.length;
|
|
25722
|
+
this.roundClean();
|
|
25723
|
+
return this;
|
|
25724
|
+
}
|
|
25725
|
+
digestInto(out) {
|
|
25726
|
+
aexists(this);
|
|
25727
|
+
aoutput(out, this);
|
|
25728
|
+
this.finished = true;
|
|
25729
|
+
// Padding
|
|
25730
|
+
// We can avoid allocation of buffer for padding completely if it
|
|
25731
|
+
// was previously not allocated here. But it won't change performance.
|
|
25732
|
+
const { buffer, view, blockLen, isLE } = this;
|
|
25733
|
+
let { pos } = this;
|
|
25734
|
+
// append the bit '1' to the message
|
|
25735
|
+
buffer[pos++] = 0b10000000;
|
|
25736
|
+
clean(this.buffer.subarray(pos));
|
|
25737
|
+
// we have less than padOffset left in buffer, so we cannot put length in
|
|
25738
|
+
// current block, need process it and pad again
|
|
25739
|
+
if (this.padOffset > blockLen - pos) {
|
|
25740
|
+
this.process(view, 0);
|
|
25741
|
+
pos = 0;
|
|
25742
|
+
}
|
|
25743
|
+
// Pad until full block byte with zeros
|
|
25744
|
+
for (let i = pos; i < blockLen; i++)
|
|
25745
|
+
buffer[i] = 0;
|
|
25746
|
+
// Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that
|
|
25747
|
+
// You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.
|
|
25748
|
+
// So we just write lowest 64 bits of that value.
|
|
25749
|
+
setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
|
|
25750
|
+
this.process(view, 0);
|
|
25751
|
+
const oview = createView(out);
|
|
25752
|
+
const len = this.outputLen;
|
|
25753
|
+
// NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT
|
|
25754
|
+
if (len % 4)
|
|
25755
|
+
throw new Error('_sha2: outputLen should be aligned to 32bit');
|
|
25756
|
+
const outLen = len / 4;
|
|
25757
|
+
const state = this.get();
|
|
25758
|
+
if (outLen > state.length)
|
|
25759
|
+
throw new Error('_sha2: outputLen bigger than state');
|
|
25760
|
+
for (let i = 0; i < outLen; i++)
|
|
25761
|
+
oview.setUint32(4 * i, state[i], isLE);
|
|
25762
|
+
}
|
|
25763
|
+
digest() {
|
|
25764
|
+
const { buffer, outputLen } = this;
|
|
25765
|
+
this.digestInto(buffer);
|
|
25766
|
+
const res = buffer.slice(0, outputLen);
|
|
25767
|
+
this.destroy();
|
|
25768
|
+
return res;
|
|
25769
|
+
}
|
|
25770
|
+
_cloneInto(to) {
|
|
25771
|
+
to || (to = new this.constructor());
|
|
25772
|
+
to.set(...this.get());
|
|
25773
|
+
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
|
25774
|
+
to.destroyed = destroyed;
|
|
25775
|
+
to.finished = finished;
|
|
25776
|
+
to.length = length;
|
|
25777
|
+
to.pos = pos;
|
|
25778
|
+
if (length % blockLen)
|
|
25779
|
+
to.buffer.set(buffer);
|
|
25780
|
+
return to;
|
|
25781
|
+
}
|
|
25782
|
+
clone() {
|
|
25783
|
+
return this._cloneInto();
|
|
25784
|
+
}
|
|
25785
|
+
}
|
|
25786
|
+
/**
|
|
25787
|
+
* Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53.
|
|
25788
|
+
* Check out `test/misc/sha2-gen-iv.js` for recomputation guide.
|
|
25789
|
+
*/
|
|
25790
|
+
/** Initial SHA256 state. Bits 0..32 of frac part of sqrt of primes 2..19 */
|
|
25791
|
+
const SHA256_IV = /* @__PURE__ */ Uint32Array.from([
|
|
25792
|
+
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,
|
|
25793
|
+
]);
|
|
25794
|
+
|
|
25795
|
+
/**
|
|
25796
|
+
* SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256.
|
|
25797
|
+
* SHA256 is the fastest hash implementable in JS, even faster than Blake3.
|
|
25798
|
+
* Check out [RFC 4634](https://datatracker.ietf.org/doc/html/rfc4634) and
|
|
25799
|
+
* [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf).
|
|
25800
|
+
* @module
|
|
25801
|
+
*/
|
|
25802
|
+
/**
|
|
25803
|
+
* Round constants:
|
|
25804
|
+
* First 32 bits of fractional parts of the cube roots of the first 64 primes 2..311)
|
|
25805
|
+
*/
|
|
25806
|
+
// prettier-ignore
|
|
25807
|
+
const SHA256_K = /* @__PURE__ */ Uint32Array.from([
|
|
25808
|
+
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
25809
|
+
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
25810
|
+
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
25811
|
+
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
|
25812
|
+
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
|
25813
|
+
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
25814
|
+
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
25815
|
+
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
|
25816
|
+
]);
|
|
25817
|
+
/** Reusable temporary buffer. "W" comes straight from spec. */
|
|
25818
|
+
const SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
25819
|
+
class SHA256 extends HashMD {
|
|
25820
|
+
constructor(outputLen = 32) {
|
|
25821
|
+
super(64, outputLen, 8, false);
|
|
25822
|
+
// We cannot use array here since array allows indexing by variable
|
|
25823
|
+
// which means optimizer/compiler cannot use registers.
|
|
25824
|
+
this.A = SHA256_IV[0] | 0;
|
|
25825
|
+
this.B = SHA256_IV[1] | 0;
|
|
25826
|
+
this.C = SHA256_IV[2] | 0;
|
|
25827
|
+
this.D = SHA256_IV[3] | 0;
|
|
25828
|
+
this.E = SHA256_IV[4] | 0;
|
|
25829
|
+
this.F = SHA256_IV[5] | 0;
|
|
25830
|
+
this.G = SHA256_IV[6] | 0;
|
|
25831
|
+
this.H = SHA256_IV[7] | 0;
|
|
25832
|
+
}
|
|
25833
|
+
get() {
|
|
25834
|
+
const { A, B, C, D, E, F, G, H } = this;
|
|
25835
|
+
return [A, B, C, D, E, F, G, H];
|
|
25836
|
+
}
|
|
25837
|
+
// prettier-ignore
|
|
25838
|
+
set(A, B, C, D, E, F, G, H) {
|
|
25839
|
+
this.A = A | 0;
|
|
25840
|
+
this.B = B | 0;
|
|
25841
|
+
this.C = C | 0;
|
|
25842
|
+
this.D = D | 0;
|
|
25843
|
+
this.E = E | 0;
|
|
25844
|
+
this.F = F | 0;
|
|
25845
|
+
this.G = G | 0;
|
|
25846
|
+
this.H = H | 0;
|
|
25847
|
+
}
|
|
25848
|
+
process(view, offset) {
|
|
25849
|
+
// Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array
|
|
25850
|
+
for (let i = 0; i < 16; i++, offset += 4)
|
|
25851
|
+
SHA256_W[i] = view.getUint32(offset, false);
|
|
25852
|
+
for (let i = 16; i < 64; i++) {
|
|
25853
|
+
const W15 = SHA256_W[i - 15];
|
|
25854
|
+
const W2 = SHA256_W[i - 2];
|
|
25855
|
+
const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ (W15 >>> 3);
|
|
25856
|
+
const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ (W2 >>> 10);
|
|
25857
|
+
SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;
|
|
25858
|
+
}
|
|
25859
|
+
// Compression function main loop, 64 rounds
|
|
25860
|
+
let { A, B, C, D, E, F, G, H } = this;
|
|
25861
|
+
for (let i = 0; i < 64; i++) {
|
|
25862
|
+
const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
|
|
25863
|
+
const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;
|
|
25864
|
+
const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
|
|
25865
|
+
const T2 = (sigma0 + Maj(A, B, C)) | 0;
|
|
25866
|
+
H = G;
|
|
25867
|
+
G = F;
|
|
25868
|
+
F = E;
|
|
25869
|
+
E = (D + T1) | 0;
|
|
25870
|
+
D = C;
|
|
25871
|
+
C = B;
|
|
25872
|
+
B = A;
|
|
25873
|
+
A = (T1 + T2) | 0;
|
|
25874
|
+
}
|
|
25875
|
+
// Add the compressed chunk to the current hash value
|
|
25876
|
+
A = (A + this.A) | 0;
|
|
25877
|
+
B = (B + this.B) | 0;
|
|
25878
|
+
C = (C + this.C) | 0;
|
|
25879
|
+
D = (D + this.D) | 0;
|
|
25880
|
+
E = (E + this.E) | 0;
|
|
25881
|
+
F = (F + this.F) | 0;
|
|
25882
|
+
G = (G + this.G) | 0;
|
|
25883
|
+
H = (H + this.H) | 0;
|
|
25884
|
+
this.set(A, B, C, D, E, F, G, H);
|
|
25885
|
+
}
|
|
25886
|
+
roundClean() {
|
|
25887
|
+
clean(SHA256_W);
|
|
25888
|
+
}
|
|
25889
|
+
destroy() {
|
|
25890
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
25891
|
+
clean(this.buffer);
|
|
25892
|
+
}
|
|
25893
|
+
}
|
|
25894
|
+
/**
|
|
25895
|
+
* SHA2-256 hash function from RFC 4634.
|
|
25896
|
+
*
|
|
25897
|
+
* It is the fastest JS hash, even faster than Blake3.
|
|
25898
|
+
* To break sha256 using birthday attack, attackers need to try 2^128 hashes.
|
|
25899
|
+
* BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.
|
|
25900
|
+
*/
|
|
25901
|
+
const sha256 = /* @__PURE__ */ createHasher(() => new SHA256());
|
|
25902
|
+
|
|
25897
25903
|
/**
|
|
25898
25904
|
* HMAC: RFC2104 message authentication code.
|
|
25899
25905
|
* @module
|
|
25900
25906
|
*/
|
|
25901
|
-
class HMAC extends Hash
|
|
25907
|
+
class HMAC extends Hash {
|
|
25902
25908
|
constructor(hash, _key) {
|
|
25903
25909
|
super();
|
|
25904
25910
|
this.finished = false;
|
|
25905
25911
|
this.destroyed = false;
|
|
25906
25912
|
ahash(hash);
|
|
25907
|
-
const key = toBytes
|
|
25913
|
+
const key = toBytes(_key);
|
|
25908
25914
|
this.iHash = hash.create();
|
|
25909
25915
|
if (typeof this.iHash.update !== 'function')
|
|
25910
25916
|
throw new Error('Expected instance of class which extends utils.Hash');
|
|
@@ -37238,8 +37244,8 @@ function weierstrass(curveDef) {
|
|
|
37238
37244
|
function getHash(hash) {
|
|
37239
37245
|
return {
|
|
37240
37246
|
hash,
|
|
37241
|
-
hmac: (key, ...msgs) => hmac(hash, key, concatBytes$
|
|
37242
|
-
randomBytes
|
|
37247
|
+
hmac: (key, ...msgs) => hmac(hash, key, concatBytes$1(...msgs)),
|
|
37248
|
+
randomBytes,
|
|
37243
37249
|
};
|
|
37244
37250
|
}
|
|
37245
37251
|
function createCurve(curveDef, defHash) {
|
|
@@ -37345,7 +37351,7 @@ const secp256k1 = createCurve({
|
|
|
37345
37351
|
return { k1neg, k1, k2neg, k2 };
|
|
37346
37352
|
},
|
|
37347
37353
|
},
|
|
37348
|
-
}, sha256
|
|
37354
|
+
}, sha256);
|
|
37349
37355
|
|
|
37350
37356
|
/**
|
|
37351
37357
|
* Deserializes a {@link ox#Hex.Hex} signature into a structured {@link ox#Signature.Signature}.
|