@solana/web3.js 1.78.3 → 1.78.4
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/lib/index.iife.js +566 -179
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +9 -8
- package/lib/index.iife.min.js.map +1 -1
- package/package.json +9 -9
package/lib/index.iife.js
CHANGED
|
@@ -155,7 +155,10 @@ var solanaWeb3 = (function (exports) {
|
|
|
155
155
|
if ("executing" === state) throw new Error("Generator is already running");
|
|
156
156
|
if ("completed" === state) {
|
|
157
157
|
if ("throw" === method) throw arg;
|
|
158
|
-
return
|
|
158
|
+
return {
|
|
159
|
+
value: void 0,
|
|
160
|
+
done: !0
|
|
161
|
+
};
|
|
159
162
|
}
|
|
160
163
|
for (context.method = method, context.arg = arg;;) {
|
|
161
164
|
var delegate = context.delegate;
|
|
@@ -208,7 +211,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
208
211
|
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
209
212
|
}
|
|
210
213
|
function values(iterable) {
|
|
211
|
-
if (iterable) {
|
|
214
|
+
if (iterable || "" === iterable) {
|
|
212
215
|
var iteratorMethod = iterable[iteratorSymbol];
|
|
213
216
|
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
214
217
|
if ("function" == typeof iterable.next) return iterable;
|
|
@@ -221,15 +224,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
221
224
|
return next.next = next;
|
|
222
225
|
}
|
|
223
226
|
}
|
|
224
|
-
|
|
225
|
-
next: doneResult
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
function doneResult() {
|
|
229
|
-
return {
|
|
230
|
-
value: undefined,
|
|
231
|
-
done: !0
|
|
232
|
-
};
|
|
227
|
+
throw new TypeError(typeof iterable + " is not iterable");
|
|
233
228
|
}
|
|
234
229
|
return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
|
|
235
230
|
value: GeneratorFunctionPrototype,
|
|
@@ -3070,48 +3065,48 @@ var solanaWeb3 = (function (exports) {
|
|
|
3070
3065
|
}
|
|
3071
3066
|
} (buffer));
|
|
3072
3067
|
|
|
3073
|
-
function number$
|
|
3068
|
+
function number$2(n) {
|
|
3074
3069
|
if (!Number.isSafeInteger(n) || n < 0)
|
|
3075
3070
|
throw new Error(`Wrong positive integer: ${n}`);
|
|
3076
3071
|
}
|
|
3077
|
-
function bool(b) {
|
|
3072
|
+
function bool$1(b) {
|
|
3078
3073
|
if (typeof b !== 'boolean')
|
|
3079
3074
|
throw new Error(`Expected boolean, not ${b}`);
|
|
3080
3075
|
}
|
|
3081
|
-
function bytes(b, ...lengths) {
|
|
3076
|
+
function bytes$1(b, ...lengths) {
|
|
3082
3077
|
if (!(b instanceof Uint8Array))
|
|
3083
3078
|
throw new TypeError('Expected Uint8Array');
|
|
3084
3079
|
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
3085
3080
|
throw new TypeError(`Expected Uint8Array of length ${lengths}, not of length=${b.length}`);
|
|
3086
3081
|
}
|
|
3087
|
-
function hash(hash) {
|
|
3082
|
+
function hash$1(hash) {
|
|
3088
3083
|
if (typeof hash !== 'function' || typeof hash.create !== 'function')
|
|
3089
3084
|
throw new Error('Hash should be wrapped by utils.wrapConstructor');
|
|
3090
|
-
number$
|
|
3091
|
-
number$
|
|
3085
|
+
number$2(hash.outputLen);
|
|
3086
|
+
number$2(hash.blockLen);
|
|
3092
3087
|
}
|
|
3093
|
-
function exists(instance, checkFinished = true) {
|
|
3088
|
+
function exists$1(instance, checkFinished = true) {
|
|
3094
3089
|
if (instance.destroyed)
|
|
3095
3090
|
throw new Error('Hash instance has been destroyed');
|
|
3096
3091
|
if (checkFinished && instance.finished)
|
|
3097
3092
|
throw new Error('Hash#digest() has already been called');
|
|
3098
3093
|
}
|
|
3099
|
-
function output(out, instance) {
|
|
3100
|
-
bytes(out);
|
|
3094
|
+
function output$1(out, instance) {
|
|
3095
|
+
bytes$1(out);
|
|
3101
3096
|
const min = instance.outputLen;
|
|
3102
3097
|
if (out.length < min) {
|
|
3103
3098
|
throw new Error(`digestInto() expects output buffer of length at least ${min}`);
|
|
3104
3099
|
}
|
|
3105
3100
|
}
|
|
3106
|
-
const assert$
|
|
3107
|
-
number: number$
|
|
3108
|
-
bool,
|
|
3109
|
-
bytes,
|
|
3110
|
-
hash,
|
|
3111
|
-
exists,
|
|
3112
|
-
output,
|
|
3101
|
+
const assert$4 = {
|
|
3102
|
+
number: number$2,
|
|
3103
|
+
bool: bool$1,
|
|
3104
|
+
bytes: bytes$1,
|
|
3105
|
+
hash: hash$1,
|
|
3106
|
+
exists: exists$1,
|
|
3107
|
+
output: output$1,
|
|
3113
3108
|
};
|
|
3114
|
-
var assert$
|
|
3109
|
+
var assert$5 = assert$4;
|
|
3115
3110
|
|
|
3116
3111
|
const crypto$1 = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined;
|
|
3117
3112
|
|
|
@@ -3121,26 +3116,25 @@ var solanaWeb3 = (function (exports) {
|
|
|
3121
3116
|
// rewrites import from `crypto` to `cryptoNode`, which imports native module.
|
|
3122
3117
|
// Makes the utils un-importable in browsers without a bundler.
|
|
3123
3118
|
// Once node.js 18 is deprecated, we can just drop the import.
|
|
3124
|
-
const u32$1 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
3125
3119
|
// Cast array to view
|
|
3126
|
-
const createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
3120
|
+
const createView$1 = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
3127
3121
|
// The rotate right (circular right shift) operation for uint32
|
|
3128
|
-
const rotr = (word, shift) => (word << (32 - shift)) | (word >>> shift);
|
|
3122
|
+
const rotr$1 = (word, shift) => (word << (32 - shift)) | (word >>> shift);
|
|
3129
3123
|
// big-endian hardware is rare. Just in case someone still decides to run hashes:
|
|
3130
3124
|
// early-throw an error because we don't support BE yet.
|
|
3131
|
-
const isLE = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;
|
|
3132
|
-
if (!isLE)
|
|
3125
|
+
const isLE$1 = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;
|
|
3126
|
+
if (!isLE$1)
|
|
3133
3127
|
throw new Error('Non little-endian hardware is not supported');
|
|
3134
3128
|
Array.from({ length: 256 }, (v, i) => i.toString(16).padStart(2, '0'));
|
|
3135
|
-
function utf8ToBytes$
|
|
3129
|
+
function utf8ToBytes$2(str) {
|
|
3136
3130
|
if (typeof str !== 'string') {
|
|
3137
3131
|
throw new TypeError(`utf8ToBytes expected string, got ${typeof str}`);
|
|
3138
3132
|
}
|
|
3139
3133
|
return new TextEncoder().encode(str);
|
|
3140
3134
|
}
|
|
3141
|
-
function toBytes(data) {
|
|
3135
|
+
function toBytes$1(data) {
|
|
3142
3136
|
if (typeof data === 'string')
|
|
3143
|
-
data = utf8ToBytes$
|
|
3137
|
+
data = utf8ToBytes$2(data);
|
|
3144
3138
|
if (!(data instanceof Uint8Array))
|
|
3145
3139
|
throw new TypeError(`Expected input type is Uint8Array (got ${typeof data})`);
|
|
3146
3140
|
return data;
|
|
@@ -3164,28 +3158,20 @@ var solanaWeb3 = (function (exports) {
|
|
|
3164
3158
|
return result;
|
|
3165
3159
|
}
|
|
3166
3160
|
// For runtime check if class implements interface
|
|
3167
|
-
class Hash {
|
|
3161
|
+
let Hash$1 = class Hash {
|
|
3168
3162
|
// Safe version that clones internal state
|
|
3169
3163
|
clone() {
|
|
3170
3164
|
return this._cloneInto();
|
|
3171
3165
|
}
|
|
3172
|
-
}
|
|
3173
|
-
function wrapConstructor(hashConstructor) {
|
|
3174
|
-
const hashC = (message) => hashConstructor().update(toBytes(message)).digest();
|
|
3166
|
+
};
|
|
3167
|
+
function wrapConstructor$1(hashConstructor) {
|
|
3168
|
+
const hashC = (message) => hashConstructor().update(toBytes$1(message)).digest();
|
|
3175
3169
|
const tmp = hashConstructor();
|
|
3176
3170
|
hashC.outputLen = tmp.outputLen;
|
|
3177
3171
|
hashC.blockLen = tmp.blockLen;
|
|
3178
3172
|
hashC.create = () => hashConstructor();
|
|
3179
3173
|
return hashC;
|
|
3180
3174
|
}
|
|
3181
|
-
function wrapConstructorWithOpts(hashCons) {
|
|
3182
|
-
const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
|
|
3183
|
-
const tmp = hashCons({});
|
|
3184
|
-
hashC.outputLen = tmp.outputLen;
|
|
3185
|
-
hashC.blockLen = tmp.blockLen;
|
|
3186
|
-
hashC.create = (opts) => hashCons(opts);
|
|
3187
|
-
return hashC;
|
|
3188
|
-
}
|
|
3189
3175
|
/**
|
|
3190
3176
|
* Secure PRNG. Uses `globalThis.crypto` or node.js crypto module.
|
|
3191
3177
|
*/
|
|
@@ -3197,7 +3183,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
3197
3183
|
}
|
|
3198
3184
|
|
|
3199
3185
|
// Polyfill for Safari 14
|
|
3200
|
-
function setBigUint64(view, byteOffset, value, isLE) {
|
|
3186
|
+
function setBigUint64$1(view, byteOffset, value, isLE) {
|
|
3201
3187
|
if (typeof view.setBigUint64 === 'function')
|
|
3202
3188
|
return view.setBigUint64(byteOffset, value, isLE);
|
|
3203
3189
|
const _32n = BigInt(32);
|
|
@@ -3210,7 +3196,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
3210
3196
|
view.setUint32(byteOffset + l, wl, isLE);
|
|
3211
3197
|
}
|
|
3212
3198
|
// Base SHA2 class (RFC 6234)
|
|
3213
|
-
class SHA2 extends Hash {
|
|
3199
|
+
let SHA2$1 = class SHA2 extends Hash$1 {
|
|
3214
3200
|
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
3215
3201
|
super();
|
|
3216
3202
|
this.blockLen = blockLen;
|
|
@@ -3222,18 +3208,18 @@ var solanaWeb3 = (function (exports) {
|
|
|
3222
3208
|
this.pos = 0;
|
|
3223
3209
|
this.destroyed = false;
|
|
3224
3210
|
this.buffer = new Uint8Array(blockLen);
|
|
3225
|
-
this.view = createView(this.buffer);
|
|
3211
|
+
this.view = createView$1(this.buffer);
|
|
3226
3212
|
}
|
|
3227
3213
|
update(data) {
|
|
3228
|
-
assert$
|
|
3214
|
+
assert$5.exists(this);
|
|
3229
3215
|
const { view, buffer, blockLen } = this;
|
|
3230
|
-
data = toBytes(data);
|
|
3216
|
+
data = toBytes$1(data);
|
|
3231
3217
|
const len = data.length;
|
|
3232
3218
|
for (let pos = 0; pos < len;) {
|
|
3233
3219
|
const take = Math.min(blockLen - this.pos, len - pos);
|
|
3234
3220
|
// Fast path: we have at least one block in input, cast it to view and process
|
|
3235
3221
|
if (take === blockLen) {
|
|
3236
|
-
const dataView = createView(data);
|
|
3222
|
+
const dataView = createView$1(data);
|
|
3237
3223
|
for (; blockLen <= len - pos; pos += blockLen)
|
|
3238
3224
|
this.process(dataView, pos);
|
|
3239
3225
|
continue;
|
|
@@ -3251,8 +3237,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
3251
3237
|
return this;
|
|
3252
3238
|
}
|
|
3253
3239
|
digestInto(out) {
|
|
3254
|
-
assert$
|
|
3255
|
-
assert$
|
|
3240
|
+
assert$5.exists(this);
|
|
3241
|
+
assert$5.output(out, this);
|
|
3256
3242
|
this.finished = true;
|
|
3257
3243
|
// Padding
|
|
3258
3244
|
// We can avoid allocation of buffer for padding completely if it
|
|
@@ -3273,9 +3259,9 @@ var solanaWeb3 = (function (exports) {
|
|
|
3273
3259
|
// Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that
|
|
3274
3260
|
// You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.
|
|
3275
3261
|
// So we just write lowest 64 bits of that value.
|
|
3276
|
-
setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
|
|
3262
|
+
setBigUint64$1(view, blockLen - 8, BigInt(this.length * 8), isLE);
|
|
3277
3263
|
this.process(view, 0);
|
|
3278
|
-
const oview = createView(out);
|
|
3264
|
+
const oview = createView$1(out);
|
|
3279
3265
|
const len = this.outputLen;
|
|
3280
3266
|
// NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT
|
|
3281
3267
|
if (len % 4)
|
|
@@ -3306,72 +3292,72 @@ var solanaWeb3 = (function (exports) {
|
|
|
3306
3292
|
to.buffer.set(buffer);
|
|
3307
3293
|
return to;
|
|
3308
3294
|
}
|
|
3309
|
-
}
|
|
3295
|
+
};
|
|
3310
3296
|
|
|
3311
|
-
const U32_MASK64 = BigInt(2 ** 32 - 1);
|
|
3312
|
-
const _32n = BigInt(32);
|
|
3297
|
+
const U32_MASK64$1 = BigInt(2 ** 32 - 1);
|
|
3298
|
+
const _32n$1 = BigInt(32);
|
|
3313
3299
|
// We are not using BigUint64Array, because they are extremely slow as per 2022
|
|
3314
|
-
function fromBig(n, le = false) {
|
|
3300
|
+
function fromBig$1(n, le = false) {
|
|
3315
3301
|
if (le)
|
|
3316
|
-
return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };
|
|
3317
|
-
return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
|
|
3302
|
+
return { h: Number(n & U32_MASK64$1), l: Number((n >> _32n$1) & U32_MASK64$1) };
|
|
3303
|
+
return { h: Number((n >> _32n$1) & U32_MASK64$1) | 0, l: Number(n & U32_MASK64$1) | 0 };
|
|
3318
3304
|
}
|
|
3319
|
-
function split(lst, le = false) {
|
|
3305
|
+
function split$1(lst, le = false) {
|
|
3320
3306
|
let Ah = new Uint32Array(lst.length);
|
|
3321
3307
|
let Al = new Uint32Array(lst.length);
|
|
3322
3308
|
for (let i = 0; i < lst.length; i++) {
|
|
3323
|
-
const { h, l } = fromBig(lst[i], le);
|
|
3309
|
+
const { h, l } = fromBig$1(lst[i], le);
|
|
3324
3310
|
[Ah[i], Al[i]] = [h, l];
|
|
3325
3311
|
}
|
|
3326
3312
|
return [Ah, Al];
|
|
3327
3313
|
}
|
|
3328
|
-
const toBig = (h, l) => (BigInt(h >>> 0) << _32n) | BigInt(l >>> 0);
|
|
3314
|
+
const toBig$1 = (h, l) => (BigInt(h >>> 0) << _32n$1) | BigInt(l >>> 0);
|
|
3329
3315
|
// for Shift in [0, 32)
|
|
3330
|
-
const shrSH = (h, l, s) => h >>> s;
|
|
3331
|
-
const shrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);
|
|
3316
|
+
const shrSH$1 = (h, l, s) => h >>> s;
|
|
3317
|
+
const shrSL$1 = (h, l, s) => (h << (32 - s)) | (l >>> s);
|
|
3332
3318
|
// Right rotate for Shift in [1, 32)
|
|
3333
|
-
const rotrSH = (h, l, s) => (h >>> s) | (l << (32 - s));
|
|
3334
|
-
const rotrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);
|
|
3319
|
+
const rotrSH$1 = (h, l, s) => (h >>> s) | (l << (32 - s));
|
|
3320
|
+
const rotrSL$1 = (h, l, s) => (h << (32 - s)) | (l >>> s);
|
|
3335
3321
|
// Right rotate for Shift in (32, 64), NOTE: 32 is special case.
|
|
3336
|
-
const rotrBH = (h, l, s) => (h << (64 - s)) | (l >>> (s - 32));
|
|
3337
|
-
const rotrBL = (h, l, s) => (h >>> (s - 32)) | (l << (64 - s));
|
|
3322
|
+
const rotrBH$1 = (h, l, s) => (h << (64 - s)) | (l >>> (s - 32));
|
|
3323
|
+
const rotrBL$1 = (h, l, s) => (h >>> (s - 32)) | (l << (64 - s));
|
|
3338
3324
|
// Right rotate for shift===32 (just swaps l&h)
|
|
3339
|
-
const rotr32H = (h, l) => l;
|
|
3340
|
-
const rotr32L = (h, l) => h;
|
|
3325
|
+
const rotr32H$1 = (h, l) => l;
|
|
3326
|
+
const rotr32L$1 = (h, l) => h;
|
|
3341
3327
|
// Left rotate for Shift in [1, 32)
|
|
3342
|
-
const rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s));
|
|
3343
|
-
const rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s));
|
|
3328
|
+
const rotlSH$1 = (h, l, s) => (h << s) | (l >>> (32 - s));
|
|
3329
|
+
const rotlSL$1 = (h, l, s) => (l << s) | (h >>> (32 - s));
|
|
3344
3330
|
// Left rotate for Shift in (32, 64), NOTE: 32 is special case.
|
|
3345
|
-
const rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));
|
|
3346
|
-
const rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));
|
|
3331
|
+
const rotlBH$1 = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));
|
|
3332
|
+
const rotlBL$1 = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));
|
|
3347
3333
|
// JS uses 32-bit signed integers for bitwise operations which means we cannot
|
|
3348
3334
|
// simple take carry out of low bit sum by shift, we need to use division.
|
|
3349
3335
|
// Removing "export" has 5% perf penalty -_-
|
|
3350
|
-
function add(Ah, Al, Bh, Bl) {
|
|
3336
|
+
function add$1(Ah, Al, Bh, Bl) {
|
|
3351
3337
|
const l = (Al >>> 0) + (Bl >>> 0);
|
|
3352
3338
|
return { h: (Ah + Bh + ((l / 2 ** 32) | 0)) | 0, l: l | 0 };
|
|
3353
3339
|
}
|
|
3354
3340
|
// Addition with more than 2 elements
|
|
3355
|
-
const add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
|
|
3356
|
-
const add3H = (low, Ah, Bh, Ch) => (Ah + Bh + Ch + ((low / 2 ** 32) | 0)) | 0;
|
|
3357
|
-
const add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
|
|
3358
|
-
const add4H = (low, Ah, Bh, Ch, Dh) => (Ah + Bh + Ch + Dh + ((low / 2 ** 32) | 0)) | 0;
|
|
3359
|
-
const add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
|
|
3360
|
-
const add5H = (low, Ah, Bh, Ch, Dh, Eh) => (Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0;
|
|
3341
|
+
const add3L$1 = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
|
|
3342
|
+
const add3H$1 = (low, Ah, Bh, Ch) => (Ah + Bh + Ch + ((low / 2 ** 32) | 0)) | 0;
|
|
3343
|
+
const add4L$1 = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
|
|
3344
|
+
const add4H$1 = (low, Ah, Bh, Ch, Dh) => (Ah + Bh + Ch + Dh + ((low / 2 ** 32) | 0)) | 0;
|
|
3345
|
+
const add5L$1 = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
|
|
3346
|
+
const add5H$1 = (low, Ah, Bh, Ch, Dh, Eh) => (Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0;
|
|
3361
3347
|
// prettier-ignore
|
|
3362
|
-
const u64$
|
|
3363
|
-
fromBig, split, toBig,
|
|
3364
|
-
shrSH, shrSL,
|
|
3365
|
-
rotrSH, rotrSL, rotrBH, rotrBL,
|
|
3366
|
-
rotr32H, rotr32L,
|
|
3367
|
-
rotlSH, rotlSL, rotlBH, rotlBL,
|
|
3368
|
-
add, add3L, add3H, add4L, add4H, add5H, add5L,
|
|
3348
|
+
const u64$3 = {
|
|
3349
|
+
fromBig: fromBig$1, split: split$1, toBig: toBig$1,
|
|
3350
|
+
shrSH: shrSH$1, shrSL: shrSL$1,
|
|
3351
|
+
rotrSH: rotrSH$1, rotrSL: rotrSL$1, rotrBH: rotrBH$1, rotrBL: rotrBL$1,
|
|
3352
|
+
rotr32H: rotr32H$1, rotr32L: rotr32L$1,
|
|
3353
|
+
rotlSH: rotlSH$1, rotlSL: rotlSL$1, rotlBH: rotlBH$1, rotlBL: rotlBL$1,
|
|
3354
|
+
add: add$1, add3L: add3L$1, add3H: add3H$1, add4L: add4L$1, add4H: add4H$1, add5H: add5H$1, add5L: add5L$1,
|
|
3369
3355
|
};
|
|
3370
|
-
var u64$
|
|
3356
|
+
var u64$4 = u64$3;
|
|
3371
3357
|
|
|
3372
3358
|
// Round contants (first 32 bits of the fractional parts of the cube roots of the first 80 primes 2..409):
|
|
3373
3359
|
// prettier-ignore
|
|
3374
|
-
const [SHA512_Kh, SHA512_Kl] = u64$
|
|
3360
|
+
const [SHA512_Kh, SHA512_Kl] = u64$4.split([
|
|
3375
3361
|
'0x428a2f98d728ae22', '0x7137449123ef65cd', '0xb5c0fbcfec4d3b2f', '0xe9b5dba58189dbbc',
|
|
3376
3362
|
'0x3956c25bf348b538', '0x59f111f1b605d019', '0x923f82a4af194f9b', '0xab1c5ed5da6d8118',
|
|
3377
3363
|
'0xd807aa98a3030242', '0x12835b0145706fbe', '0x243185be4ee4b28c', '0x550c7dc3d5ffb4e2',
|
|
@@ -3396,7 +3382,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
3396
3382
|
// Temporary buffer, not used to store anything between runs
|
|
3397
3383
|
const SHA512_W_H = new Uint32Array(80);
|
|
3398
3384
|
const SHA512_W_L = new Uint32Array(80);
|
|
3399
|
-
class SHA512 extends SHA2 {
|
|
3385
|
+
class SHA512 extends SHA2$1 {
|
|
3400
3386
|
constructor() {
|
|
3401
3387
|
super(128, 64, 16, false);
|
|
3402
3388
|
// We cannot use array here since array allows indexing by variable which means optimizer/compiler cannot use registers.
|
|
@@ -3454,16 +3440,16 @@ var solanaWeb3 = (function (exports) {
|
|
|
3454
3440
|
// s0 := (w[i-15] rightrotate 1) xor (w[i-15] rightrotate 8) xor (w[i-15] rightshift 7)
|
|
3455
3441
|
const W15h = SHA512_W_H[i - 15] | 0;
|
|
3456
3442
|
const W15l = SHA512_W_L[i - 15] | 0;
|
|
3457
|
-
const s0h = u64$
|
|
3458
|
-
const s0l = u64$
|
|
3443
|
+
const s0h = u64$4.rotrSH(W15h, W15l, 1) ^ u64$4.rotrSH(W15h, W15l, 8) ^ u64$4.shrSH(W15h, W15l, 7);
|
|
3444
|
+
const s0l = u64$4.rotrSL(W15h, W15l, 1) ^ u64$4.rotrSL(W15h, W15l, 8) ^ u64$4.shrSL(W15h, W15l, 7);
|
|
3459
3445
|
// s1 := (w[i-2] rightrotate 19) xor (w[i-2] rightrotate 61) xor (w[i-2] rightshift 6)
|
|
3460
3446
|
const W2h = SHA512_W_H[i - 2] | 0;
|
|
3461
3447
|
const W2l = SHA512_W_L[i - 2] | 0;
|
|
3462
|
-
const s1h = u64$
|
|
3463
|
-
const s1l = u64$
|
|
3448
|
+
const s1h = u64$4.rotrSH(W2h, W2l, 19) ^ u64$4.rotrBH(W2h, W2l, 61) ^ u64$4.shrSH(W2h, W2l, 6);
|
|
3449
|
+
const s1l = u64$4.rotrSL(W2h, W2l, 19) ^ u64$4.rotrBL(W2h, W2l, 61) ^ u64$4.shrSL(W2h, W2l, 6);
|
|
3464
3450
|
// SHA256_W[i] = s0 + s1 + SHA256_W[i - 7] + SHA256_W[i - 16];
|
|
3465
|
-
const SUMl = u64$
|
|
3466
|
-
const SUMh = u64$
|
|
3451
|
+
const SUMl = u64$4.add4L(s0l, s1l, SHA512_W_L[i - 7], SHA512_W_L[i - 16]);
|
|
3452
|
+
const SUMh = u64$4.add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]);
|
|
3467
3453
|
SHA512_W_H[i] = SUMh | 0;
|
|
3468
3454
|
SHA512_W_L[i] = SUMl | 0;
|
|
3469
3455
|
}
|
|
@@ -3471,19 +3457,19 @@ var solanaWeb3 = (function (exports) {
|
|
|
3471
3457
|
// Compression function main loop, 80 rounds
|
|
3472
3458
|
for (let i = 0; i < 80; i++) {
|
|
3473
3459
|
// S1 := (e rightrotate 14) xor (e rightrotate 18) xor (e rightrotate 41)
|
|
3474
|
-
const sigma1h = u64$
|
|
3475
|
-
const sigma1l = u64$
|
|
3460
|
+
const sigma1h = u64$4.rotrSH(Eh, El, 14) ^ u64$4.rotrSH(Eh, El, 18) ^ u64$4.rotrBH(Eh, El, 41);
|
|
3461
|
+
const sigma1l = u64$4.rotrSL(Eh, El, 14) ^ u64$4.rotrSL(Eh, El, 18) ^ u64$4.rotrBL(Eh, El, 41);
|
|
3476
3462
|
//const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;
|
|
3477
3463
|
const CHIh = (Eh & Fh) ^ (~Eh & Gh);
|
|
3478
3464
|
const CHIl = (El & Fl) ^ (~El & Gl);
|
|
3479
3465
|
// T1 = H + sigma1 + Chi(E, F, G) + SHA512_K[i] + SHA512_W[i]
|
|
3480
3466
|
// prettier-ignore
|
|
3481
|
-
const T1ll = u64$
|
|
3482
|
-
const T1h = u64$
|
|
3467
|
+
const T1ll = u64$4.add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]);
|
|
3468
|
+
const T1h = u64$4.add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]);
|
|
3483
3469
|
const T1l = T1ll | 0;
|
|
3484
3470
|
// S0 := (a rightrotate 28) xor (a rightrotate 34) xor (a rightrotate 39)
|
|
3485
|
-
const sigma0h = u64$
|
|
3486
|
-
const sigma0l = u64$
|
|
3471
|
+
const sigma0h = u64$4.rotrSH(Ah, Al, 28) ^ u64$4.rotrBH(Ah, Al, 34) ^ u64$4.rotrBH(Ah, Al, 39);
|
|
3472
|
+
const sigma0l = u64$4.rotrSL(Ah, Al, 28) ^ u64$4.rotrBL(Ah, Al, 34) ^ u64$4.rotrBL(Ah, Al, 39);
|
|
3487
3473
|
const MAJh = (Ah & Bh) ^ (Ah & Ch) ^ (Bh & Ch);
|
|
3488
3474
|
const MAJl = (Al & Bl) ^ (Al & Cl) ^ (Bl & Cl);
|
|
3489
3475
|
Hh = Gh | 0;
|
|
@@ -3492,26 +3478,26 @@ var solanaWeb3 = (function (exports) {
|
|
|
3492
3478
|
Gl = Fl | 0;
|
|
3493
3479
|
Fh = Eh | 0;
|
|
3494
3480
|
Fl = El | 0;
|
|
3495
|
-
({ h: Eh, l: El } = u64$
|
|
3481
|
+
({ h: Eh, l: El } = u64$4.add(Dh | 0, Dl | 0, T1h | 0, T1l | 0));
|
|
3496
3482
|
Dh = Ch | 0;
|
|
3497
3483
|
Dl = Cl | 0;
|
|
3498
3484
|
Ch = Bh | 0;
|
|
3499
3485
|
Cl = Bl | 0;
|
|
3500
3486
|
Bh = Ah | 0;
|
|
3501
3487
|
Bl = Al | 0;
|
|
3502
|
-
const All = u64$
|
|
3503
|
-
Ah = u64$
|
|
3488
|
+
const All = u64$4.add3L(T1l, sigma0l, MAJl);
|
|
3489
|
+
Ah = u64$4.add3H(All, T1h, sigma0h, MAJh);
|
|
3504
3490
|
Al = All | 0;
|
|
3505
3491
|
}
|
|
3506
3492
|
// Add the compressed chunk to the current hash value
|
|
3507
|
-
({ h: Ah, l: Al } = u64$
|
|
3508
|
-
({ h: Bh, l: Bl } = u64$
|
|
3509
|
-
({ h: Ch, l: Cl } = u64$
|
|
3510
|
-
({ h: Dh, l: Dl } = u64$
|
|
3511
|
-
({ h: Eh, l: El } = u64$
|
|
3512
|
-
({ h: Fh, l: Fl } = u64$
|
|
3513
|
-
({ h: Gh, l: Gl } = u64$
|
|
3514
|
-
({ h: Hh, l: Hl } = u64$
|
|
3493
|
+
({ h: Ah, l: Al } = u64$4.add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));
|
|
3494
|
+
({ h: Bh, l: Bl } = u64$4.add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));
|
|
3495
|
+
({ h: Ch, l: Cl } = u64$4.add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));
|
|
3496
|
+
({ h: Dh, l: Dl } = u64$4.add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));
|
|
3497
|
+
({ h: Eh, l: El } = u64$4.add(this.Eh | 0, this.El | 0, Eh | 0, El | 0));
|
|
3498
|
+
({ h: Fh, l: Fl } = u64$4.add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));
|
|
3499
|
+
({ h: Gh, l: Gl } = u64$4.add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));
|
|
3500
|
+
({ h: Hh, l: Hl } = u64$4.add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));
|
|
3515
3501
|
this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);
|
|
3516
3502
|
}
|
|
3517
3503
|
roundClean() {
|
|
@@ -3592,19 +3578,19 @@ var solanaWeb3 = (function (exports) {
|
|
|
3592
3578
|
this.outputLen = 48;
|
|
3593
3579
|
}
|
|
3594
3580
|
}
|
|
3595
|
-
const sha512 = wrapConstructor(() => new SHA512());
|
|
3596
|
-
wrapConstructor(() => new SHA512_224());
|
|
3597
|
-
wrapConstructor(() => new SHA512_256());
|
|
3598
|
-
wrapConstructor(() => new SHA384());
|
|
3581
|
+
const sha512 = wrapConstructor$1(() => new SHA512());
|
|
3582
|
+
wrapConstructor$1(() => new SHA512_224());
|
|
3583
|
+
wrapConstructor$1(() => new SHA512_256());
|
|
3584
|
+
wrapConstructor$1(() => new SHA384());
|
|
3599
3585
|
|
|
3600
3586
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
3601
3587
|
const _0n$8 = BigInt(0);
|
|
3602
3588
|
const _1n$8 = BigInt(1);
|
|
3603
3589
|
const _2n$6 = BigInt(2);
|
|
3604
|
-
const u8a = (a) => a instanceof Uint8Array;
|
|
3590
|
+
const u8a$1 = (a) => a instanceof Uint8Array;
|
|
3605
3591
|
const hexes = Array.from({ length: 256 }, (v, i) => i.toString(16).padStart(2, '0'));
|
|
3606
3592
|
function bytesToHex(bytes) {
|
|
3607
|
-
if (!u8a(bytes))
|
|
3593
|
+
if (!u8a$1(bytes))
|
|
3608
3594
|
throw new Error('Uint8Array expected');
|
|
3609
3595
|
// pre-caching improves the speed 6x
|
|
3610
3596
|
let hex = '';
|
|
@@ -3645,7 +3631,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
3645
3631
|
return hexToNumber(bytesToHex(bytes));
|
|
3646
3632
|
}
|
|
3647
3633
|
function bytesToNumberLE(bytes) {
|
|
3648
|
-
if (!u8a(bytes))
|
|
3634
|
+
if (!u8a$1(bytes))
|
|
3649
3635
|
throw new Error('Uint8Array expected');
|
|
3650
3636
|
return hexToNumber(bytesToHex(Uint8Array.from(bytes).reverse()));
|
|
3651
3637
|
}
|
|
@@ -3663,7 +3649,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
3663
3649
|
throw new Error(`${title} must be valid hex string, got "${hex}". Cause: ${e}`);
|
|
3664
3650
|
}
|
|
3665
3651
|
}
|
|
3666
|
-
else if (u8a(hex)) {
|
|
3652
|
+
else if (u8a$1(hex)) {
|
|
3667
3653
|
// Uint8Array.from() instead of hash.slice() because node.js Buffer
|
|
3668
3654
|
// is instance of Uint8Array, and its slice() creates **mutable** copy
|
|
3669
3655
|
res = Uint8Array.from(hex);
|
|
@@ -3681,7 +3667,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
3681
3667
|
const r = new Uint8Array(arrs.reduce((sum, a) => sum + a.length, 0));
|
|
3682
3668
|
let pad = 0; // walk through each item, ensure they have proper type
|
|
3683
3669
|
arrs.forEach((a) => {
|
|
3684
|
-
if (!u8a(a))
|
|
3670
|
+
if (!u8a$1(a))
|
|
3685
3671
|
throw new Error('Uint8Array expected');
|
|
3686
3672
|
r.set(a, pad);
|
|
3687
3673
|
pad += a.length;
|
|
@@ -3697,7 +3683,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
3697
3683
|
return false;
|
|
3698
3684
|
return true;
|
|
3699
3685
|
}
|
|
3700
|
-
function utf8ToBytes(str) {
|
|
3686
|
+
function utf8ToBytes$1(str) {
|
|
3701
3687
|
if (typeof str !== 'string') {
|
|
3702
3688
|
throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
|
|
3703
3689
|
}
|
|
@@ -3838,7 +3824,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
3838
3824
|
numberToBytesLE: numberToBytesLE,
|
|
3839
3825
|
numberToHexUnpadded: numberToHexUnpadded,
|
|
3840
3826
|
numberToVarBytesBE: numberToVarBytesBE,
|
|
3841
|
-
utf8ToBytes: utf8ToBytes,
|
|
3827
|
+
utf8ToBytes: utf8ToBytes$1,
|
|
3842
3828
|
validateObject: validateObject
|
|
3843
3829
|
});
|
|
3844
3830
|
|
|
@@ -4887,7 +4873,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
4887
4873
|
if (dst instanceof Uint8Array)
|
|
4888
4874
|
return dst;
|
|
4889
4875
|
if (typeof dst === 'string')
|
|
4890
|
-
return utf8ToBytes(dst);
|
|
4876
|
+
return utf8ToBytes$1(dst);
|
|
4891
4877
|
throw new Error('DST must be Uint8Array or string');
|
|
4892
4878
|
}
|
|
4893
4879
|
// Octet Stream to Integer. "spec" implementation of os2ip is 2.5x slower vs bytesToNumberBE.
|
|
@@ -4927,7 +4913,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
4927
4913
|
isNum(lenInBytes);
|
|
4928
4914
|
// https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-16#section-5.3.3
|
|
4929
4915
|
if (DST.length > 255)
|
|
4930
|
-
DST = H(concatBytes(utf8ToBytes('H2C-OVERSIZE-DST-'), DST));
|
|
4916
|
+
DST = H(concatBytes(utf8ToBytes$1('H2C-OVERSIZE-DST-'), DST));
|
|
4931
4917
|
const { outputLen: b_in_bytes, blockLen: r_in_bytes } = H;
|
|
4932
4918
|
const ell = Math.ceil(lenInBytes / b_in_bytes);
|
|
4933
4919
|
if (ell > 255)
|
|
@@ -4953,7 +4939,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
4953
4939
|
// DST = H('H2C-OVERSIZE-DST-' || a_very_long_DST, Math.ceil((lenInBytes * k) / 8));
|
|
4954
4940
|
if (DST.length > 255) {
|
|
4955
4941
|
const dkLen = Math.ceil((2 * k) / 8);
|
|
4956
|
-
DST = H.create({ dkLen }).update(utf8ToBytes('H2C-OVERSIZE-DST-')).update(DST).digest();
|
|
4942
|
+
DST = H.create({ dkLen }).update(utf8ToBytes$1('H2C-OVERSIZE-DST-')).update(DST).digest();
|
|
4957
4943
|
}
|
|
4958
4944
|
if (lenInBytes > 65535 || DST.length > 255)
|
|
4959
4945
|
throw new Error('expand_message_xof: invalid lenInBytes');
|
|
@@ -5140,7 +5126,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
5140
5126
|
function ed25519_domain(data, ctx, phflag) {
|
|
5141
5127
|
if (ctx.length > 255)
|
|
5142
5128
|
throw new Error('Context is too big');
|
|
5143
|
-
return concatBytes$1(utf8ToBytes$
|
|
5129
|
+
return concatBytes$1(utf8ToBytes$2('SigEd25519 no Ed25519 collisions'), new Uint8Array([phflag ? 1 : 0, ctx.length]), ctx, data);
|
|
5144
5130
|
}
|
|
5145
5131
|
twistedEdwards({ ...ed25519Defaults, domain: ed25519_domain });
|
|
5146
5132
|
twistedEdwards({
|
|
@@ -9029,14 +9015,232 @@ var solanaWeb3 = (function (exports) {
|
|
|
9029
9015
|
|
|
9030
9016
|
var bs58$1 = /*@__PURE__*/getDefaultExportFromCjs(bs58);
|
|
9031
9017
|
|
|
9018
|
+
function number$1(n) {
|
|
9019
|
+
if (!Number.isSafeInteger(n) || n < 0)
|
|
9020
|
+
throw new Error(`Wrong positive integer: ${n}`);
|
|
9021
|
+
}
|
|
9022
|
+
function bool(b) {
|
|
9023
|
+
if (typeof b !== 'boolean')
|
|
9024
|
+
throw new Error(`Expected boolean, not ${b}`);
|
|
9025
|
+
}
|
|
9026
|
+
function bytes(b, ...lengths) {
|
|
9027
|
+
if (!(b instanceof Uint8Array))
|
|
9028
|
+
throw new Error('Expected Uint8Array');
|
|
9029
|
+
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
9030
|
+
throw new Error(`Expected Uint8Array of length ${lengths}, not of length=${b.length}`);
|
|
9031
|
+
}
|
|
9032
|
+
function hash(hash) {
|
|
9033
|
+
if (typeof hash !== 'function' || typeof hash.create !== 'function')
|
|
9034
|
+
throw new Error('Hash should be wrapped by utils.wrapConstructor');
|
|
9035
|
+
number$1(hash.outputLen);
|
|
9036
|
+
number$1(hash.blockLen);
|
|
9037
|
+
}
|
|
9038
|
+
function exists(instance, checkFinished = true) {
|
|
9039
|
+
if (instance.destroyed)
|
|
9040
|
+
throw new Error('Hash instance has been destroyed');
|
|
9041
|
+
if (checkFinished && instance.finished)
|
|
9042
|
+
throw new Error('Hash#digest() has already been called');
|
|
9043
|
+
}
|
|
9044
|
+
function output(out, instance) {
|
|
9045
|
+
bytes(out);
|
|
9046
|
+
const min = instance.outputLen;
|
|
9047
|
+
if (out.length < min) {
|
|
9048
|
+
throw new Error(`digestInto() expects output buffer of length at least ${min}`);
|
|
9049
|
+
}
|
|
9050
|
+
}
|
|
9051
|
+
const assert$2 = {
|
|
9052
|
+
number: number$1,
|
|
9053
|
+
bool,
|
|
9054
|
+
bytes,
|
|
9055
|
+
hash,
|
|
9056
|
+
exists,
|
|
9057
|
+
output,
|
|
9058
|
+
};
|
|
9059
|
+
var assert$3 = assert$2;
|
|
9060
|
+
|
|
9061
|
+
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
9062
|
+
// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.
|
|
9063
|
+
// node.js versions earlier than v19 don't declare it in global scope.
|
|
9064
|
+
// For node.js, package.json#exports field mapping rewrites import
|
|
9065
|
+
// from `crypto` to `cryptoNode`, which imports native module.
|
|
9066
|
+
// Makes the utils un-importable in browsers without a bundler.
|
|
9067
|
+
// Once node.js 18 is deprecated, we can just drop the import.
|
|
9068
|
+
const u8a = (a) => a instanceof Uint8Array;
|
|
9069
|
+
const u32$1 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
9070
|
+
// Cast array to view
|
|
9071
|
+
const createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
9072
|
+
// The rotate right (circular right shift) operation for uint32
|
|
9073
|
+
const rotr = (word, shift) => (word << (32 - shift)) | (word >>> shift);
|
|
9074
|
+
// big-endian hardware is rare. Just in case someone still decides to run hashes:
|
|
9075
|
+
// early-throw an error because we don't support BE yet.
|
|
9076
|
+
const isLE = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;
|
|
9077
|
+
if (!isLE)
|
|
9078
|
+
throw new Error('Non little-endian hardware is not supported');
|
|
9079
|
+
Array.from({ length: 256 }, (v, i) => i.toString(16).padStart(2, '0'));
|
|
9080
|
+
/**
|
|
9081
|
+
* @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
|
|
9082
|
+
*/
|
|
9083
|
+
function utf8ToBytes(str) {
|
|
9084
|
+
if (typeof str !== 'string')
|
|
9085
|
+
throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
|
|
9086
|
+
return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
|
|
9087
|
+
}
|
|
9088
|
+
/**
|
|
9089
|
+
* Normalizes (non-hex) string or Uint8Array to Uint8Array.
|
|
9090
|
+
* Warning: when Uint8Array is passed, it would NOT get copied.
|
|
9091
|
+
* Keep in mind for future mutable operations.
|
|
9092
|
+
*/
|
|
9093
|
+
function toBytes(data) {
|
|
9094
|
+
if (typeof data === 'string')
|
|
9095
|
+
data = utf8ToBytes(data);
|
|
9096
|
+
if (!u8a(data))
|
|
9097
|
+
throw new Error(`expected Uint8Array, got ${typeof data}`);
|
|
9098
|
+
return data;
|
|
9099
|
+
}
|
|
9100
|
+
// For runtime check if class implements interface
|
|
9101
|
+
class Hash {
|
|
9102
|
+
// Safe version that clones internal state
|
|
9103
|
+
clone() {
|
|
9104
|
+
return this._cloneInto();
|
|
9105
|
+
}
|
|
9106
|
+
}
|
|
9107
|
+
function wrapConstructor(hashCons) {
|
|
9108
|
+
const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
|
|
9109
|
+
const tmp = hashCons();
|
|
9110
|
+
hashC.outputLen = tmp.outputLen;
|
|
9111
|
+
hashC.blockLen = tmp.blockLen;
|
|
9112
|
+
hashC.create = () => hashCons();
|
|
9113
|
+
return hashC;
|
|
9114
|
+
}
|
|
9115
|
+
function wrapXOFConstructorWithOpts(hashCons) {
|
|
9116
|
+
const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
|
|
9117
|
+
const tmp = hashCons({});
|
|
9118
|
+
hashC.outputLen = tmp.outputLen;
|
|
9119
|
+
hashC.blockLen = tmp.blockLen;
|
|
9120
|
+
hashC.create = (opts) => hashCons(opts);
|
|
9121
|
+
return hashC;
|
|
9122
|
+
}
|
|
9123
|
+
|
|
9124
|
+
// Polyfill for Safari 14
|
|
9125
|
+
function setBigUint64(view, byteOffset, value, isLE) {
|
|
9126
|
+
if (typeof view.setBigUint64 === 'function')
|
|
9127
|
+
return view.setBigUint64(byteOffset, value, isLE);
|
|
9128
|
+
const _32n = BigInt(32);
|
|
9129
|
+
const _u32_max = BigInt(0xffffffff);
|
|
9130
|
+
const wh = Number((value >> _32n) & _u32_max);
|
|
9131
|
+
const wl = Number(value & _u32_max);
|
|
9132
|
+
const h = isLE ? 4 : 0;
|
|
9133
|
+
const l = isLE ? 0 : 4;
|
|
9134
|
+
view.setUint32(byteOffset + h, wh, isLE);
|
|
9135
|
+
view.setUint32(byteOffset + l, wl, isLE);
|
|
9136
|
+
}
|
|
9137
|
+
// Base SHA2 class (RFC 6234)
|
|
9138
|
+
class SHA2 extends Hash {
|
|
9139
|
+
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
9140
|
+
super();
|
|
9141
|
+
this.blockLen = blockLen;
|
|
9142
|
+
this.outputLen = outputLen;
|
|
9143
|
+
this.padOffset = padOffset;
|
|
9144
|
+
this.isLE = isLE;
|
|
9145
|
+
this.finished = false;
|
|
9146
|
+
this.length = 0;
|
|
9147
|
+
this.pos = 0;
|
|
9148
|
+
this.destroyed = false;
|
|
9149
|
+
this.buffer = new Uint8Array(blockLen);
|
|
9150
|
+
this.view = createView(this.buffer);
|
|
9151
|
+
}
|
|
9152
|
+
update(data) {
|
|
9153
|
+
assert$3.exists(this);
|
|
9154
|
+
const { view, buffer, blockLen } = this;
|
|
9155
|
+
data = toBytes(data);
|
|
9156
|
+
const len = data.length;
|
|
9157
|
+
for (let pos = 0; pos < len;) {
|
|
9158
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
|
9159
|
+
// Fast path: we have at least one block in input, cast it to view and process
|
|
9160
|
+
if (take === blockLen) {
|
|
9161
|
+
const dataView = createView(data);
|
|
9162
|
+
for (; blockLen <= len - pos; pos += blockLen)
|
|
9163
|
+
this.process(dataView, pos);
|
|
9164
|
+
continue;
|
|
9165
|
+
}
|
|
9166
|
+
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
9167
|
+
this.pos += take;
|
|
9168
|
+
pos += take;
|
|
9169
|
+
if (this.pos === blockLen) {
|
|
9170
|
+
this.process(view, 0);
|
|
9171
|
+
this.pos = 0;
|
|
9172
|
+
}
|
|
9173
|
+
}
|
|
9174
|
+
this.length += data.length;
|
|
9175
|
+
this.roundClean();
|
|
9176
|
+
return this;
|
|
9177
|
+
}
|
|
9178
|
+
digestInto(out) {
|
|
9179
|
+
assert$3.exists(this);
|
|
9180
|
+
assert$3.output(out, this);
|
|
9181
|
+
this.finished = true;
|
|
9182
|
+
// Padding
|
|
9183
|
+
// We can avoid allocation of buffer for padding completely if it
|
|
9184
|
+
// was previously not allocated here. But it won't change performance.
|
|
9185
|
+
const { buffer, view, blockLen, isLE } = this;
|
|
9186
|
+
let { pos } = this;
|
|
9187
|
+
// append the bit '1' to the message
|
|
9188
|
+
buffer[pos++] = 0b10000000;
|
|
9189
|
+
this.buffer.subarray(pos).fill(0);
|
|
9190
|
+
// we have less than padOffset left in buffer, so we cannot put length in current block, need process it and pad again
|
|
9191
|
+
if (this.padOffset > blockLen - pos) {
|
|
9192
|
+
this.process(view, 0);
|
|
9193
|
+
pos = 0;
|
|
9194
|
+
}
|
|
9195
|
+
// Pad until full block byte with zeros
|
|
9196
|
+
for (let i = pos; i < blockLen; i++)
|
|
9197
|
+
buffer[i] = 0;
|
|
9198
|
+
// Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that
|
|
9199
|
+
// You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.
|
|
9200
|
+
// So we just write lowest 64 bits of that value.
|
|
9201
|
+
setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
|
|
9202
|
+
this.process(view, 0);
|
|
9203
|
+
const oview = createView(out);
|
|
9204
|
+
const len = this.outputLen;
|
|
9205
|
+
// NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT
|
|
9206
|
+
if (len % 4)
|
|
9207
|
+
throw new Error('_sha2: outputLen should be aligned to 32bit');
|
|
9208
|
+
const outLen = len / 4;
|
|
9209
|
+
const state = this.get();
|
|
9210
|
+
if (outLen > state.length)
|
|
9211
|
+
throw new Error('_sha2: outputLen bigger than state');
|
|
9212
|
+
for (let i = 0; i < outLen; i++)
|
|
9213
|
+
oview.setUint32(4 * i, state[i], isLE);
|
|
9214
|
+
}
|
|
9215
|
+
digest() {
|
|
9216
|
+
const { buffer, outputLen } = this;
|
|
9217
|
+
this.digestInto(buffer);
|
|
9218
|
+
const res = buffer.slice(0, outputLen);
|
|
9219
|
+
this.destroy();
|
|
9220
|
+
return res;
|
|
9221
|
+
}
|
|
9222
|
+
_cloneInto(to) {
|
|
9223
|
+
to || (to = new this.constructor());
|
|
9224
|
+
to.set(...this.get());
|
|
9225
|
+
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
|
9226
|
+
to.length = length;
|
|
9227
|
+
to.pos = pos;
|
|
9228
|
+
to.finished = finished;
|
|
9229
|
+
to.destroyed = destroyed;
|
|
9230
|
+
if (length % blockLen)
|
|
9231
|
+
to.buffer.set(buffer);
|
|
9232
|
+
return to;
|
|
9233
|
+
}
|
|
9234
|
+
}
|
|
9235
|
+
|
|
9032
9236
|
// Choice: a ? b : c
|
|
9033
|
-
const Chi = (a, b, c) => (a & b) ^ (~a & c);
|
|
9237
|
+
const Chi$1 = (a, b, c) => (a & b) ^ (~a & c);
|
|
9034
9238
|
// Majority function, true if any two inpust is true
|
|
9035
|
-
const Maj = (a, b, c) => (a & b) ^ (a & c) ^ (b & c);
|
|
9239
|
+
const Maj$1 = (a, b, c) => (a & b) ^ (a & c) ^ (b & c);
|
|
9036
9240
|
// Round constants:
|
|
9037
9241
|
// first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311)
|
|
9038
9242
|
// prettier-ignore
|
|
9039
|
-
const SHA256_K = new Uint32Array([
|
|
9243
|
+
const SHA256_K$1 = new Uint32Array([
|
|
9040
9244
|
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
9041
9245
|
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
9042
9246
|
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
@@ -9048,25 +9252,25 @@ var solanaWeb3 = (function (exports) {
|
|
|
9048
9252
|
]);
|
|
9049
9253
|
// Initial state (first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19):
|
|
9050
9254
|
// prettier-ignore
|
|
9051
|
-
const IV = new Uint32Array([
|
|
9255
|
+
const IV$1 = new Uint32Array([
|
|
9052
9256
|
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
|
|
9053
9257
|
]);
|
|
9054
9258
|
// Temporary buffer, not used to store anything between runs
|
|
9055
9259
|
// Named this way because it matches specification.
|
|
9056
|
-
const SHA256_W = new Uint32Array(64);
|
|
9057
|
-
class SHA256 extends SHA2 {
|
|
9260
|
+
const SHA256_W$1 = new Uint32Array(64);
|
|
9261
|
+
let SHA256$1 = class SHA256 extends SHA2 {
|
|
9058
9262
|
constructor() {
|
|
9059
9263
|
super(64, 32, 8, false);
|
|
9060
9264
|
// We cannot use array here since array allows indexing by variable
|
|
9061
9265
|
// which means optimizer/compiler cannot use registers.
|
|
9062
|
-
this.A = IV[0] | 0;
|
|
9063
|
-
this.B = IV[1] | 0;
|
|
9064
|
-
this.C = IV[2] | 0;
|
|
9065
|
-
this.D = IV[3] | 0;
|
|
9066
|
-
this.E = IV[4] | 0;
|
|
9067
|
-
this.F = IV[5] | 0;
|
|
9068
|
-
this.G = IV[6] | 0;
|
|
9069
|
-
this.H = IV[7] | 0;
|
|
9266
|
+
this.A = IV$1[0] | 0;
|
|
9267
|
+
this.B = IV$1[1] | 0;
|
|
9268
|
+
this.C = IV$1[2] | 0;
|
|
9269
|
+
this.D = IV$1[3] | 0;
|
|
9270
|
+
this.E = IV$1[4] | 0;
|
|
9271
|
+
this.F = IV$1[5] | 0;
|
|
9272
|
+
this.G = IV$1[6] | 0;
|
|
9273
|
+
this.H = IV$1[7] | 0;
|
|
9070
9274
|
}
|
|
9071
9275
|
get() {
|
|
9072
9276
|
const { A, B, C, D, E, F, G, H } = this;
|
|
@@ -9086,21 +9290,21 @@ var solanaWeb3 = (function (exports) {
|
|
|
9086
9290
|
process(view, offset) {
|
|
9087
9291
|
// Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array
|
|
9088
9292
|
for (let i = 0; i < 16; i++, offset += 4)
|
|
9089
|
-
SHA256_W[i] = view.getUint32(offset, false);
|
|
9293
|
+
SHA256_W$1[i] = view.getUint32(offset, false);
|
|
9090
9294
|
for (let i = 16; i < 64; i++) {
|
|
9091
|
-
const W15 = SHA256_W[i - 15];
|
|
9092
|
-
const W2 = SHA256_W[i - 2];
|
|
9295
|
+
const W15 = SHA256_W$1[i - 15];
|
|
9296
|
+
const W2 = SHA256_W$1[i - 2];
|
|
9093
9297
|
const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ (W15 >>> 3);
|
|
9094
9298
|
const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ (W2 >>> 10);
|
|
9095
|
-
SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;
|
|
9299
|
+
SHA256_W$1[i] = (s1 + SHA256_W$1[i - 7] + s0 + SHA256_W$1[i - 16]) | 0;
|
|
9096
9300
|
}
|
|
9097
9301
|
// Compression function main loop, 64 rounds
|
|
9098
9302
|
let { A, B, C, D, E, F, G, H } = this;
|
|
9099
9303
|
for (let i = 0; i < 64; i++) {
|
|
9100
9304
|
const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
|
|
9101
|
-
const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;
|
|
9305
|
+
const T1 = (H + sigma1 + Chi$1(E, F, G) + SHA256_K$1[i] + SHA256_W$1[i]) | 0;
|
|
9102
9306
|
const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
|
|
9103
|
-
const T2 = (sigma0 + Maj(A, B, C)) | 0;
|
|
9307
|
+
const T2 = (sigma0 + Maj$1(A, B, C)) | 0;
|
|
9104
9308
|
H = G;
|
|
9105
9309
|
G = F;
|
|
9106
9310
|
F = E;
|
|
@@ -9122,15 +9326,15 @@ var solanaWeb3 = (function (exports) {
|
|
|
9122
9326
|
this.set(A, B, C, D, E, F, G, H);
|
|
9123
9327
|
}
|
|
9124
9328
|
roundClean() {
|
|
9125
|
-
SHA256_W.fill(0);
|
|
9329
|
+
SHA256_W$1.fill(0);
|
|
9126
9330
|
}
|
|
9127
9331
|
destroy() {
|
|
9128
9332
|
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
9129
9333
|
this.buffer.fill(0);
|
|
9130
9334
|
}
|
|
9131
|
-
}
|
|
9335
|
+
};
|
|
9132
9336
|
// Constants from https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf
|
|
9133
|
-
class SHA224 extends SHA256 {
|
|
9337
|
+
let SHA224$1 = class SHA224 extends SHA256$1 {
|
|
9134
9338
|
constructor() {
|
|
9135
9339
|
super();
|
|
9136
9340
|
this.A = 0xc1059ed8 | 0;
|
|
@@ -9143,13 +9347,13 @@ var solanaWeb3 = (function (exports) {
|
|
|
9143
9347
|
this.H = 0xbefa4fa4 | 0;
|
|
9144
9348
|
this.outputLen = 28;
|
|
9145
9349
|
}
|
|
9146
|
-
}
|
|
9350
|
+
};
|
|
9147
9351
|
/**
|
|
9148
9352
|
* SHA2-256 hash function
|
|
9149
9353
|
* @param message - data that would be hashed
|
|
9150
9354
|
*/
|
|
9151
|
-
const sha256 = wrapConstructor(() => new SHA256());
|
|
9152
|
-
wrapConstructor(() => new SHA224());
|
|
9355
|
+
const sha256$1 = wrapConstructor(() => new SHA256$1());
|
|
9356
|
+
wrapConstructor(() => new SHA224$1());
|
|
9153
9357
|
|
|
9154
9358
|
var lib = {};
|
|
9155
9359
|
|
|
@@ -10440,7 +10644,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
10440
10644
|
while (1) switch (_context.prev = _context.next) {
|
|
10441
10645
|
case 0:
|
|
10442
10646
|
buffer$1 = buffer.Buffer.concat([fromPublicKey.toBuffer(), buffer.Buffer.from(seed), programId.toBuffer()]);
|
|
10443
|
-
publicKeyBytes = sha256(buffer$1);
|
|
10647
|
+
publicKeyBytes = sha256$1(buffer$1);
|
|
10444
10648
|
return _context.abrupt("return", new PublicKey(publicKeyBytes));
|
|
10445
10649
|
case 3:
|
|
10446
10650
|
case "end":
|
|
@@ -10468,7 +10672,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
10468
10672
|
buffer$1 = buffer.Buffer.concat([buffer$1, toBuffer(seed)]);
|
|
10469
10673
|
});
|
|
10470
10674
|
buffer$1 = buffer.Buffer.concat([buffer$1, programId.toBuffer(), buffer.Buffer.from('ProgramDerivedAddress')]);
|
|
10471
|
-
var publicKeyBytes = sha256(buffer$1);
|
|
10675
|
+
var publicKeyBytes = sha256$1(buffer$1);
|
|
10472
10676
|
if (isOnCurve(publicKeyBytes)) {
|
|
10473
10677
|
throw new Error("Invalid seeds, address must fall off the curve");
|
|
10474
10678
|
}
|
|
@@ -15364,7 +15568,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
15364
15568
|
return bigIntLayout;
|
|
15365
15569
|
};
|
|
15366
15570
|
};
|
|
15367
|
-
var u64 = bigInt(8);
|
|
15571
|
+
var u64$2 = bigInt(8);
|
|
15368
15572
|
|
|
15369
15573
|
/**
|
|
15370
15574
|
* Create account system transaction params
|
|
@@ -15731,7 +15935,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
15731
15935
|
},
|
|
15732
15936
|
Transfer: {
|
|
15733
15937
|
index: 2,
|
|
15734
|
-
layout: struct([u32('instruction'), u64('lamports')])
|
|
15938
|
+
layout: struct([u32('instruction'), u64$2('lamports')])
|
|
15735
15939
|
},
|
|
15736
15940
|
CreateWithSeed: {
|
|
15737
15941
|
index: 3,
|
|
@@ -15767,7 +15971,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
15767
15971
|
},
|
|
15768
15972
|
TransferWithSeed: {
|
|
15769
15973
|
index: 11,
|
|
15770
|
-
layout: struct([u32('instruction'), u64('lamports'), rustString('seed'), publicKey('programId')])
|
|
15974
|
+
layout: struct([u32('instruction'), u64$2('lamports'), rustString('seed'), publicKey('programId')])
|
|
15771
15975
|
},
|
|
15772
15976
|
UpgradeNonceAccount: {
|
|
15773
15977
|
index: 12,
|
|
@@ -19812,7 +20016,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
19812
20016
|
}();
|
|
19813
20017
|
var LookupTableMetaLayout = {
|
|
19814
20018
|
index: 1,
|
|
19815
|
-
layout: struct([u32('typeIndex'), u64('deactivationSlot'), nu64('lastExtendedSlot'), u8('lastExtendedStartIndex'), u8(),
|
|
20019
|
+
layout: struct([u32('typeIndex'), u64$2('deactivationSlot'), nu64('lastExtendedSlot'), u8('lastExtendedStartIndex'), u8(),
|
|
19816
20020
|
// option
|
|
19817
20021
|
seq(publicKey(), offset(u8(), -1), 'authority')])
|
|
19818
20022
|
};
|
|
@@ -26677,7 +26881,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
26677
26881
|
var LOOKUP_TABLE_INSTRUCTION_LAYOUTS = Object.freeze({
|
|
26678
26882
|
CreateLookupTable: {
|
|
26679
26883
|
index: 0,
|
|
26680
|
-
layout: struct([u32('instruction'), u64('recentSlot'), u8('bumpSeed')])
|
|
26884
|
+
layout: struct([u32('instruction'), u64$2('recentSlot'), u8('bumpSeed')])
|
|
26681
26885
|
},
|
|
26682
26886
|
FreezeLookupTable: {
|
|
26683
26887
|
index: 1,
|
|
@@ -26685,7 +26889,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
26685
26889
|
},
|
|
26686
26890
|
ExtendLookupTable: {
|
|
26687
26891
|
index: 2,
|
|
26688
|
-
layout: struct([u32('instruction'), u64(), seq(publicKey(), offset(u32(), -8), 'addresses')])
|
|
26892
|
+
layout: struct([u32('instruction'), u64$2(), seq(publicKey(), offset(u32(), -8), 'addresses')])
|
|
26689
26893
|
},
|
|
26690
26894
|
DeactivateLookupTable: {
|
|
26691
26895
|
index: 3,
|
|
@@ -27103,7 +27307,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
27103
27307
|
},
|
|
27104
27308
|
SetComputeUnitPrice: {
|
|
27105
27309
|
index: 3,
|
|
27106
|
-
layout: struct([u8('instruction'), u64('microLamports')])
|
|
27310
|
+
layout: struct([u8('instruction'), u64$2('microLamports')])
|
|
27107
27311
|
}
|
|
27108
27312
|
});
|
|
27109
27313
|
|
|
@@ -27273,6 +27477,67 @@ var solanaWeb3 = (function (exports) {
|
|
|
27273
27477
|
}();
|
|
27274
27478
|
Ed25519Program.programId = new PublicKey('Ed25519SigVerify111111111111111111111111111');
|
|
27275
27479
|
|
|
27480
|
+
const U32_MASK64 = BigInt(2 ** 32 - 1);
|
|
27481
|
+
const _32n = BigInt(32);
|
|
27482
|
+
// We are not using BigUint64Array, because they are extremely slow as per 2022
|
|
27483
|
+
function fromBig(n, le = false) {
|
|
27484
|
+
if (le)
|
|
27485
|
+
return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };
|
|
27486
|
+
return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
|
|
27487
|
+
}
|
|
27488
|
+
function split(lst, le = false) {
|
|
27489
|
+
let Ah = new Uint32Array(lst.length);
|
|
27490
|
+
let Al = new Uint32Array(lst.length);
|
|
27491
|
+
for (let i = 0; i < lst.length; i++) {
|
|
27492
|
+
const { h, l } = fromBig(lst[i], le);
|
|
27493
|
+
[Ah[i], Al[i]] = [h, l];
|
|
27494
|
+
}
|
|
27495
|
+
return [Ah, Al];
|
|
27496
|
+
}
|
|
27497
|
+
const toBig = (h, l) => (BigInt(h >>> 0) << _32n) | BigInt(l >>> 0);
|
|
27498
|
+
// for Shift in [0, 32)
|
|
27499
|
+
const shrSH = (h, l, s) => h >>> s;
|
|
27500
|
+
const shrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);
|
|
27501
|
+
// Right rotate for Shift in [1, 32)
|
|
27502
|
+
const rotrSH = (h, l, s) => (h >>> s) | (l << (32 - s));
|
|
27503
|
+
const rotrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);
|
|
27504
|
+
// Right rotate for Shift in (32, 64), NOTE: 32 is special case.
|
|
27505
|
+
const rotrBH = (h, l, s) => (h << (64 - s)) | (l >>> (s - 32));
|
|
27506
|
+
const rotrBL = (h, l, s) => (h >>> (s - 32)) | (l << (64 - s));
|
|
27507
|
+
// Right rotate for shift===32 (just swaps l&h)
|
|
27508
|
+
const rotr32H = (h, l) => l;
|
|
27509
|
+
const rotr32L = (h, l) => h;
|
|
27510
|
+
// Left rotate for Shift in [1, 32)
|
|
27511
|
+
const rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s));
|
|
27512
|
+
const rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s));
|
|
27513
|
+
// Left rotate for Shift in (32, 64), NOTE: 32 is special case.
|
|
27514
|
+
const rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));
|
|
27515
|
+
const rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));
|
|
27516
|
+
// JS uses 32-bit signed integers for bitwise operations which means we cannot
|
|
27517
|
+
// simple take carry out of low bit sum by shift, we need to use division.
|
|
27518
|
+
// Removing "export" has 5% perf penalty -_-
|
|
27519
|
+
function add(Ah, Al, Bh, Bl) {
|
|
27520
|
+
const l = (Al >>> 0) + (Bl >>> 0);
|
|
27521
|
+
return { h: (Ah + Bh + ((l / 2 ** 32) | 0)) | 0, l: l | 0 };
|
|
27522
|
+
}
|
|
27523
|
+
// Addition with more than 2 elements
|
|
27524
|
+
const add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
|
|
27525
|
+
const add3H = (low, Ah, Bh, Ch) => (Ah + Bh + Ch + ((low / 2 ** 32) | 0)) | 0;
|
|
27526
|
+
const add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
|
|
27527
|
+
const add4H = (low, Ah, Bh, Ch, Dh) => (Ah + Bh + Ch + Dh + ((low / 2 ** 32) | 0)) | 0;
|
|
27528
|
+
const add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
|
|
27529
|
+
const add5H = (low, Ah, Bh, Ch, Dh, Eh) => (Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0;
|
|
27530
|
+
// prettier-ignore
|
|
27531
|
+
const u64 = {
|
|
27532
|
+
fromBig, split, toBig,
|
|
27533
|
+
shrSH, shrSL,
|
|
27534
|
+
rotrSH, rotrSL, rotrBH, rotrBL,
|
|
27535
|
+
rotr32H, rotr32L,
|
|
27536
|
+
rotlSH, rotlSL, rotlBH, rotlBL,
|
|
27537
|
+
add, add3L, add3H, add4L, add4H, add5H, add5L,
|
|
27538
|
+
};
|
|
27539
|
+
var u64$1 = u64;
|
|
27540
|
+
|
|
27276
27541
|
// Various per round constants calculations
|
|
27277
27542
|
const [SHA3_PI, SHA3_ROTL, _SHA3_IOTA] = [[], [], []];
|
|
27278
27543
|
const _0n$2 = BigInt(0);
|
|
@@ -27296,10 +27561,10 @@ var solanaWeb3 = (function (exports) {
|
|
|
27296
27561
|
}
|
|
27297
27562
|
_SHA3_IOTA.push(t);
|
|
27298
27563
|
}
|
|
27299
|
-
const [SHA3_IOTA_H, SHA3_IOTA_L] = u64$
|
|
27564
|
+
const [SHA3_IOTA_H, SHA3_IOTA_L] = u64$1.split(_SHA3_IOTA, true);
|
|
27300
27565
|
// Left rotation (without 0, 32, 64)
|
|
27301
|
-
const rotlH = (h, l, s) => s > 32 ? u64$
|
|
27302
|
-
const rotlL = (h, l, s) => s > 32 ? u64$
|
|
27566
|
+
const rotlH = (h, l, s) => s > 32 ? u64$1.rotlBH(h, l, s) : u64$1.rotlSH(h, l, s);
|
|
27567
|
+
const rotlL = (h, l, s) => s > 32 ? u64$1.rotlBL(h, l, s) : u64$1.rotlSL(h, l, s);
|
|
27303
27568
|
// Same as keccakf1600, but allows to skip some rounds
|
|
27304
27569
|
function keccakP(s, rounds = 24) {
|
|
27305
27570
|
const B = new Uint32Array(5 * 2);
|
|
@@ -27472,10 +27737,132 @@ var solanaWeb3 = (function (exports) {
|
|
|
27472
27737
|
const keccak_256 = gen(0x01, 136, 256 / 8);
|
|
27473
27738
|
gen(0x01, 104, 384 / 8);
|
|
27474
27739
|
gen(0x01, 72, 512 / 8);
|
|
27475
|
-
const genShake = (suffix, blockLen, outputLen) =>
|
|
27740
|
+
const genShake = (suffix, blockLen, outputLen) => wrapXOFConstructorWithOpts((opts = {}) => new Keccak(blockLen, suffix, opts.dkLen === undefined ? outputLen : opts.dkLen, true));
|
|
27476
27741
|
genShake(0x1f, 168, 128 / 8);
|
|
27477
27742
|
genShake(0x1f, 136, 256 / 8);
|
|
27478
27743
|
|
|
27744
|
+
// Choice: a ? b : c
|
|
27745
|
+
const Chi = (a, b, c) => (a & b) ^ (~a & c);
|
|
27746
|
+
// Majority function, true if any two inpust is true
|
|
27747
|
+
const Maj = (a, b, c) => (a & b) ^ (a & c) ^ (b & c);
|
|
27748
|
+
// Round constants:
|
|
27749
|
+
// first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311)
|
|
27750
|
+
// prettier-ignore
|
|
27751
|
+
const SHA256_K = new Uint32Array([
|
|
27752
|
+
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
27753
|
+
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
27754
|
+
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
27755
|
+
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
|
27756
|
+
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
|
27757
|
+
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
27758
|
+
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
27759
|
+
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
|
27760
|
+
]);
|
|
27761
|
+
// Initial state (first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19):
|
|
27762
|
+
// prettier-ignore
|
|
27763
|
+
const IV = new Uint32Array([
|
|
27764
|
+
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
|
|
27765
|
+
]);
|
|
27766
|
+
// Temporary buffer, not used to store anything between runs
|
|
27767
|
+
// Named this way because it matches specification.
|
|
27768
|
+
const SHA256_W = new Uint32Array(64);
|
|
27769
|
+
class SHA256 extends SHA2$1 {
|
|
27770
|
+
constructor() {
|
|
27771
|
+
super(64, 32, 8, false);
|
|
27772
|
+
// We cannot use array here since array allows indexing by variable
|
|
27773
|
+
// which means optimizer/compiler cannot use registers.
|
|
27774
|
+
this.A = IV[0] | 0;
|
|
27775
|
+
this.B = IV[1] | 0;
|
|
27776
|
+
this.C = IV[2] | 0;
|
|
27777
|
+
this.D = IV[3] | 0;
|
|
27778
|
+
this.E = IV[4] | 0;
|
|
27779
|
+
this.F = IV[5] | 0;
|
|
27780
|
+
this.G = IV[6] | 0;
|
|
27781
|
+
this.H = IV[7] | 0;
|
|
27782
|
+
}
|
|
27783
|
+
get() {
|
|
27784
|
+
const { A, B, C, D, E, F, G, H } = this;
|
|
27785
|
+
return [A, B, C, D, E, F, G, H];
|
|
27786
|
+
}
|
|
27787
|
+
// prettier-ignore
|
|
27788
|
+
set(A, B, C, D, E, F, G, H) {
|
|
27789
|
+
this.A = A | 0;
|
|
27790
|
+
this.B = B | 0;
|
|
27791
|
+
this.C = C | 0;
|
|
27792
|
+
this.D = D | 0;
|
|
27793
|
+
this.E = E | 0;
|
|
27794
|
+
this.F = F | 0;
|
|
27795
|
+
this.G = G | 0;
|
|
27796
|
+
this.H = H | 0;
|
|
27797
|
+
}
|
|
27798
|
+
process(view, offset) {
|
|
27799
|
+
// Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array
|
|
27800
|
+
for (let i = 0; i < 16; i++, offset += 4)
|
|
27801
|
+
SHA256_W[i] = view.getUint32(offset, false);
|
|
27802
|
+
for (let i = 16; i < 64; i++) {
|
|
27803
|
+
const W15 = SHA256_W[i - 15];
|
|
27804
|
+
const W2 = SHA256_W[i - 2];
|
|
27805
|
+
const s0 = rotr$1(W15, 7) ^ rotr$1(W15, 18) ^ (W15 >>> 3);
|
|
27806
|
+
const s1 = rotr$1(W2, 17) ^ rotr$1(W2, 19) ^ (W2 >>> 10);
|
|
27807
|
+
SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;
|
|
27808
|
+
}
|
|
27809
|
+
// Compression function main loop, 64 rounds
|
|
27810
|
+
let { A, B, C, D, E, F, G, H } = this;
|
|
27811
|
+
for (let i = 0; i < 64; i++) {
|
|
27812
|
+
const sigma1 = rotr$1(E, 6) ^ rotr$1(E, 11) ^ rotr$1(E, 25);
|
|
27813
|
+
const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;
|
|
27814
|
+
const sigma0 = rotr$1(A, 2) ^ rotr$1(A, 13) ^ rotr$1(A, 22);
|
|
27815
|
+
const T2 = (sigma0 + Maj(A, B, C)) | 0;
|
|
27816
|
+
H = G;
|
|
27817
|
+
G = F;
|
|
27818
|
+
F = E;
|
|
27819
|
+
E = (D + T1) | 0;
|
|
27820
|
+
D = C;
|
|
27821
|
+
C = B;
|
|
27822
|
+
B = A;
|
|
27823
|
+
A = (T1 + T2) | 0;
|
|
27824
|
+
}
|
|
27825
|
+
// Add the compressed chunk to the current hash value
|
|
27826
|
+
A = (A + this.A) | 0;
|
|
27827
|
+
B = (B + this.B) | 0;
|
|
27828
|
+
C = (C + this.C) | 0;
|
|
27829
|
+
D = (D + this.D) | 0;
|
|
27830
|
+
E = (E + this.E) | 0;
|
|
27831
|
+
F = (F + this.F) | 0;
|
|
27832
|
+
G = (G + this.G) | 0;
|
|
27833
|
+
H = (H + this.H) | 0;
|
|
27834
|
+
this.set(A, B, C, D, E, F, G, H);
|
|
27835
|
+
}
|
|
27836
|
+
roundClean() {
|
|
27837
|
+
SHA256_W.fill(0);
|
|
27838
|
+
}
|
|
27839
|
+
destroy() {
|
|
27840
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
27841
|
+
this.buffer.fill(0);
|
|
27842
|
+
}
|
|
27843
|
+
}
|
|
27844
|
+
// Constants from https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf
|
|
27845
|
+
class SHA224 extends SHA256 {
|
|
27846
|
+
constructor() {
|
|
27847
|
+
super();
|
|
27848
|
+
this.A = 0xc1059ed8 | 0;
|
|
27849
|
+
this.B = 0x367cd507 | 0;
|
|
27850
|
+
this.C = 0x3070dd17 | 0;
|
|
27851
|
+
this.D = 0xf70e5939 | 0;
|
|
27852
|
+
this.E = 0xffc00b31 | 0;
|
|
27853
|
+
this.F = 0x68581511 | 0;
|
|
27854
|
+
this.G = 0x64f98fa7 | 0;
|
|
27855
|
+
this.H = 0xbefa4fa4 | 0;
|
|
27856
|
+
this.outputLen = 28;
|
|
27857
|
+
}
|
|
27858
|
+
}
|
|
27859
|
+
/**
|
|
27860
|
+
* SHA2-256 hash function
|
|
27861
|
+
* @param message - data that would be hashed
|
|
27862
|
+
*/
|
|
27863
|
+
const sha256 = wrapConstructor$1(() => new SHA256());
|
|
27864
|
+
wrapConstructor$1(() => new SHA224());
|
|
27865
|
+
|
|
27479
27866
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
27480
27867
|
// Short Weierstrass curve. The formula is: y² = x³ + ax + b
|
|
27481
27868
|
function validatePointOpts(curve) {
|
|
@@ -28511,13 +28898,13 @@ var solanaWeb3 = (function (exports) {
|
|
|
28511
28898
|
}
|
|
28512
28899
|
|
|
28513
28900
|
// HMAC (RFC 2104)
|
|
28514
|
-
class HMAC extends Hash {
|
|
28901
|
+
class HMAC extends Hash$1 {
|
|
28515
28902
|
constructor(hash, _key) {
|
|
28516
28903
|
super();
|
|
28517
28904
|
this.finished = false;
|
|
28518
28905
|
this.destroyed = false;
|
|
28519
|
-
assert$
|
|
28520
|
-
const key = toBytes(_key);
|
|
28906
|
+
assert$5.hash(hash);
|
|
28907
|
+
const key = toBytes$1(_key);
|
|
28521
28908
|
this.iHash = hash.create();
|
|
28522
28909
|
if (typeof this.iHash.update !== 'function')
|
|
28523
28910
|
throw new TypeError('Expected instance of class which extends utils.Hash');
|
|
@@ -28539,13 +28926,13 @@ var solanaWeb3 = (function (exports) {
|
|
|
28539
28926
|
pad.fill(0);
|
|
28540
28927
|
}
|
|
28541
28928
|
update(buf) {
|
|
28542
|
-
assert$
|
|
28929
|
+
assert$5.exists(this);
|
|
28543
28930
|
this.iHash.update(buf);
|
|
28544
28931
|
return this;
|
|
28545
28932
|
}
|
|
28546
28933
|
digestInto(out) {
|
|
28547
|
-
assert$
|
|
28548
|
-
assert$
|
|
28934
|
+
assert$5.exists(this);
|
|
28935
|
+
assert$5.bytes(out, this.outputLen);
|
|
28549
28936
|
this.finished = true;
|
|
28550
28937
|
this.iHash.digestInto(out);
|
|
28551
28938
|
this.oHash.update(out);
|