shogun-core 3.0.0 → 3.0.2
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/browser/shogun-core.js +607 -926
- package/dist/browser/shogun-core.js.map +1 -1
- package/dist/core.js +1 -1
- package/dist/gundb/db.js +9 -6
- package/dist/gundb/index.js +1 -1
- package/dist/managers/CoreInitializer.js +18 -11
- package/dist/types/core.d.ts +9 -5
- package/dist/types/gundb/db.d.ts +3 -3
- package/dist/types/gundb/index.d.ts +1 -1
- package/dist/types/gundb/rxjs.d.ts +1 -1
- package/dist/types/gundb/types.d.ts +107 -1
- package/dist/types/interfaces/plugin.d.ts +105 -1
- package/dist/types/interfaces/shogun.d.ts +16 -7
- package/dist/types/managers/AuthManager.d.ts +4 -1
- package/package.json +1 -1
- package/dist/gundb/improved-types.js +0 -4
- package/dist/types/gundb/improved-types.d.ts +0 -123
|
@@ -43829,7 +43829,7 @@ var __webpack_exports__ = {};
|
|
|
43829
43829
|
(() => {
|
|
43830
43830
|
"use strict";
|
|
43831
43831
|
/*!************************************!*\
|
|
43832
|
-
!*** ./src/index.ts +
|
|
43832
|
+
!*** ./src/index.ts + 211 modules ***!
|
|
43833
43833
|
\************************************/
|
|
43834
43834
|
// ESM COMPAT FLAG
|
|
43835
43835
|
__webpack_require__.r(__webpack_exports__);
|
|
@@ -47079,10 +47079,10 @@ var WebAuthnEventType;
|
|
|
47079
47079
|
WebAuthnEventType["ERROR"] = "error";
|
|
47080
47080
|
})(WebAuthnEventType || (WebAuthnEventType = {}));
|
|
47081
47081
|
|
|
47082
|
-
;// ./node_modules/@noble/
|
|
47082
|
+
;// ./node_modules/@noble/hashes/esm/crypto.js
|
|
47083
47083
|
const esm_crypto_crypto = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined;
|
|
47084
47084
|
//# sourceMappingURL=crypto.js.map
|
|
47085
|
-
;// ./node_modules/@noble/
|
|
47085
|
+
;// ./node_modules/@noble/hashes/esm/utils.js
|
|
47086
47086
|
/**
|
|
47087
47087
|
* Utilities for hex, bytes, CSPRNG.
|
|
47088
47088
|
* @module
|
|
@@ -47364,7 +47364,7 @@ function utils_randomBytes(bytesLength = 32) {
|
|
|
47364
47364
|
throw new Error('crypto.getRandomValues must be defined');
|
|
47365
47365
|
}
|
|
47366
47366
|
//# sourceMappingURL=utils.js.map
|
|
47367
|
-
;// ./node_modules/@noble/
|
|
47367
|
+
;// ./node_modules/@noble/hashes/esm/_md.js
|
|
47368
47368
|
/**
|
|
47369
47369
|
* Internal Merkle-Damgard hash utils.
|
|
47370
47370
|
* @module
|
|
@@ -47520,7 +47520,7 @@ const SHA512_IV = /* @__PURE__ */ Uint32Array.from([
|
|
|
47520
47520
|
0x510e527f, 0xade682d1, 0x9b05688c, 0x2b3e6c1f, 0x1f83d9ab, 0xfb41bd6b, 0x5be0cd19, 0x137e2179,
|
|
47521
47521
|
]);
|
|
47522
47522
|
//# sourceMappingURL=_md.js.map
|
|
47523
|
-
;// ./node_modules/@noble/
|
|
47523
|
+
;// ./node_modules/@noble/hashes/esm/_u64.js
|
|
47524
47524
|
/**
|
|
47525
47525
|
* Internal helpers for u64. BigUint64Array is too slow as per 2025, so we implement it using Uint32Array.
|
|
47526
47526
|
* @todo re-check https://issues.chromium.org/issues/42212588
|
|
@@ -47588,7 +47588,7 @@ const _u64_u64 = {
|
|
|
47588
47588
|
};
|
|
47589
47589
|
/* harmony default export */ const esm_u64 = (_u64_u64);
|
|
47590
47590
|
//# sourceMappingURL=_u64.js.map
|
|
47591
|
-
;// ./node_modules/@noble/
|
|
47591
|
+
;// ./node_modules/@noble/hashes/esm/sha2.js
|
|
47592
47592
|
/**
|
|
47593
47593
|
* SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256.
|
|
47594
47594
|
* SHA256 is the fastest hash implementable in JS, even faster than Blake3.
|
|
@@ -47964,7 +47964,7 @@ const sha2_sha512_256 = /* @__PURE__ */ createHasher(() => new sha2_SHA512_256()
|
|
|
47964
47964
|
*/
|
|
47965
47965
|
const sha2_sha512_224 = /* @__PURE__ */ createHasher(() => new sha2_SHA512_224());
|
|
47966
47966
|
//# sourceMappingURL=sha2.js.map
|
|
47967
|
-
;// ./node_modules/@noble/
|
|
47967
|
+
;// ./node_modules/@noble/hashes/esm/hmac.js
|
|
47968
47968
|
/**
|
|
47969
47969
|
* HMAC: RFC2104 message authentication code.
|
|
47970
47970
|
* @module
|
|
@@ -51451,523 +51451,54 @@ const secp256k1_hashToCurve = /* @__PURE__ */ (() => secp256k1_hasher.hashToCurv
|
|
|
51451
51451
|
/** @deprecated use `import { secp256k1_hasher } from '@noble/curves/secp256k1.js';` */
|
|
51452
51452
|
const secp256k1_encodeToCurve = /* @__PURE__ */ (() => secp256k1_hasher.encodeToCurve)();
|
|
51453
51453
|
//# sourceMappingURL=secp256k1.js.map
|
|
51454
|
-
;// ./node_modules/@noble/hashes/esm/_assert.js
|
|
51455
|
-
function _assert_number(n) {
|
|
51456
|
-
if (!Number.isSafeInteger(n) || n < 0)
|
|
51457
|
-
throw new Error(`Wrong positive integer: ${n}`);
|
|
51458
|
-
}
|
|
51459
|
-
function _assert_bool(b) {
|
|
51460
|
-
if (typeof b !== 'boolean')
|
|
51461
|
-
throw new Error(`Expected boolean, not ${b}`);
|
|
51462
|
-
}
|
|
51463
|
-
function _assert_bytes(b, ...lengths) {
|
|
51464
|
-
if (!(b instanceof Uint8Array))
|
|
51465
|
-
throw new Error('Expected Uint8Array');
|
|
51466
|
-
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
51467
|
-
throw new Error(`Expected Uint8Array of length ${lengths}, not of length=${b.length}`);
|
|
51468
|
-
}
|
|
51469
|
-
function hash(hash) {
|
|
51470
|
-
if (typeof hash !== 'function' || typeof hash.create !== 'function')
|
|
51471
|
-
throw new Error('Hash should be wrapped by utils.wrapConstructor');
|
|
51472
|
-
_assert_number(hash.outputLen);
|
|
51473
|
-
_assert_number(hash.blockLen);
|
|
51474
|
-
}
|
|
51475
|
-
function _assert_exists(instance, checkFinished = true) {
|
|
51476
|
-
if (instance.destroyed)
|
|
51477
|
-
throw new Error('Hash instance has been destroyed');
|
|
51478
|
-
if (checkFinished && instance.finished)
|
|
51479
|
-
throw new Error('Hash#digest() has already been called');
|
|
51480
|
-
}
|
|
51481
|
-
function _assert_output(out, instance) {
|
|
51482
|
-
_assert_bytes(out);
|
|
51483
|
-
const min = instance.outputLen;
|
|
51484
|
-
if (out.length < min) {
|
|
51485
|
-
throw new Error(`digestInto() expects output buffer of length at least ${min}`);
|
|
51486
|
-
}
|
|
51487
|
-
}
|
|
51488
|
-
const esm_assert_assert = {
|
|
51489
|
-
number: _assert_number,
|
|
51490
|
-
bool: _assert_bool,
|
|
51491
|
-
bytes: _assert_bytes,
|
|
51492
|
-
hash,
|
|
51493
|
-
exists: _assert_exists,
|
|
51494
|
-
output: _assert_output,
|
|
51495
|
-
};
|
|
51496
|
-
/* harmony default export */ const esm_assert = (esm_assert_assert);
|
|
51497
|
-
//# sourceMappingURL=_assert.js.map
|
|
51498
|
-
;// ./node_modules/@noble/hashes/esm/crypto.js
|
|
51499
|
-
const hashes_esm_crypto_crypto = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined;
|
|
51500
|
-
//# sourceMappingURL=crypto.js.map
|
|
51501
|
-
;// ./node_modules/@noble/hashes/esm/utils.js
|
|
51502
|
-
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
51503
|
-
// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.
|
|
51504
|
-
// node.js versions earlier than v19 don't declare it in global scope.
|
|
51505
|
-
// For node.js, package.json#exports field mapping rewrites import
|
|
51506
|
-
// from `crypto` to `cryptoNode`, which imports native module.
|
|
51507
|
-
// Makes the utils un-importable in browsers without a bundler.
|
|
51508
|
-
// Once node.js 18 is deprecated, we can just drop the import.
|
|
51509
|
-
|
|
51510
|
-
const utils_u8a = (a) => a instanceof Uint8Array;
|
|
51511
|
-
// Cast array to different type
|
|
51512
|
-
const esm_utils_u8 = (arr) => new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
51513
|
-
const esm_utils_u32 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
51514
|
-
// Cast array to view
|
|
51515
|
-
const esm_utils_createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
51516
|
-
// The rotate right (circular right shift) operation for uint32
|
|
51517
|
-
const esm_utils_rotr = (word, shift) => (word << (32 - shift)) | (word >>> shift);
|
|
51518
|
-
// big-endian hardware is rare. Just in case someone still decides to run hashes:
|
|
51519
|
-
// early-throw an error because we don't support BE yet.
|
|
51520
|
-
const esm_utils_isLE = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;
|
|
51521
|
-
if (!esm_utils_isLE)
|
|
51522
|
-
throw new Error('Non little-endian hardware is not supported');
|
|
51523
|
-
const esm_utils_hexes = Array.from({ length: 256 }, (v, i) => i.toString(16).padStart(2, '0'));
|
|
51524
|
-
/**
|
|
51525
|
-
* @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'
|
|
51526
|
-
*/
|
|
51527
|
-
function esm_utils_bytesToHex(bytes) {
|
|
51528
|
-
if (!utils_u8a(bytes))
|
|
51529
|
-
throw new Error('Uint8Array expected');
|
|
51530
|
-
// pre-caching improves the speed 6x
|
|
51531
|
-
let hex = '';
|
|
51532
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
51533
|
-
hex += esm_utils_hexes[bytes[i]];
|
|
51534
|
-
}
|
|
51535
|
-
return hex;
|
|
51536
|
-
}
|
|
51537
|
-
/**
|
|
51538
|
-
* @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])
|
|
51539
|
-
*/
|
|
51540
|
-
function esm_utils_hexToBytes(hex) {
|
|
51541
|
-
if (typeof hex !== 'string')
|
|
51542
|
-
throw new Error('hex string expected, got ' + typeof hex);
|
|
51543
|
-
const len = hex.length;
|
|
51544
|
-
if (len % 2)
|
|
51545
|
-
throw new Error('padded hex string expected, got unpadded hex of length ' + len);
|
|
51546
|
-
const array = new Uint8Array(len / 2);
|
|
51547
|
-
for (let i = 0; i < array.length; i++) {
|
|
51548
|
-
const j = i * 2;
|
|
51549
|
-
const hexByte = hex.slice(j, j + 2);
|
|
51550
|
-
const byte = Number.parseInt(hexByte, 16);
|
|
51551
|
-
if (Number.isNaN(byte) || byte < 0)
|
|
51552
|
-
throw new Error('Invalid byte sequence');
|
|
51553
|
-
array[i] = byte;
|
|
51554
|
-
}
|
|
51555
|
-
return array;
|
|
51556
|
-
}
|
|
51557
|
-
// There is no setImmediate in browser and setTimeout is slow.
|
|
51558
|
-
// call of async fn will return Promise, which will be fullfiled only on
|
|
51559
|
-
// next scheduler queue processing step and this is exactly what we need.
|
|
51560
|
-
const esm_utils_nextTick = async () => { };
|
|
51561
|
-
// Returns control to thread each 'tick' ms to avoid blocking
|
|
51562
|
-
async function esm_utils_asyncLoop(iters, tick, cb) {
|
|
51563
|
-
let ts = Date.now();
|
|
51564
|
-
for (let i = 0; i < iters; i++) {
|
|
51565
|
-
cb(i);
|
|
51566
|
-
// Date.now() is not monotonic, so in case if clock goes backwards we return return control too
|
|
51567
|
-
const diff = Date.now() - ts;
|
|
51568
|
-
if (diff >= 0 && diff < tick)
|
|
51569
|
-
continue;
|
|
51570
|
-
await esm_utils_nextTick();
|
|
51571
|
-
ts += diff;
|
|
51572
|
-
}
|
|
51573
|
-
}
|
|
51574
|
-
/**
|
|
51575
|
-
* @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
|
|
51576
|
-
*/
|
|
51577
|
-
function esm_utils_utf8ToBytes(str) {
|
|
51578
|
-
if (typeof str !== 'string')
|
|
51579
|
-
throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
|
|
51580
|
-
return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
|
|
51581
|
-
}
|
|
51582
|
-
/**
|
|
51583
|
-
* Normalizes (non-hex) string or Uint8Array to Uint8Array.
|
|
51584
|
-
* Warning: when Uint8Array is passed, it would NOT get copied.
|
|
51585
|
-
* Keep in mind for future mutable operations.
|
|
51586
|
-
*/
|
|
51587
|
-
function esm_utils_toBytes(data) {
|
|
51588
|
-
if (typeof data === 'string')
|
|
51589
|
-
data = esm_utils_utf8ToBytes(data);
|
|
51590
|
-
if (!utils_u8a(data))
|
|
51591
|
-
throw new Error(`expected Uint8Array, got ${typeof data}`);
|
|
51592
|
-
return data;
|
|
51593
|
-
}
|
|
51594
|
-
/**
|
|
51595
|
-
* Copies several Uint8Arrays into one.
|
|
51596
|
-
*/
|
|
51597
|
-
function esm_utils_concatBytes(...arrays) {
|
|
51598
|
-
const r = new Uint8Array(arrays.reduce((sum, a) => sum + a.length, 0));
|
|
51599
|
-
let pad = 0; // walk through each item, ensure they have proper type
|
|
51600
|
-
arrays.forEach((a) => {
|
|
51601
|
-
if (!utils_u8a(a))
|
|
51602
|
-
throw new Error('Uint8Array expected');
|
|
51603
|
-
r.set(a, pad);
|
|
51604
|
-
pad += a.length;
|
|
51605
|
-
});
|
|
51606
|
-
return r;
|
|
51607
|
-
}
|
|
51608
|
-
// For runtime check if class implements interface
|
|
51609
|
-
class esm_utils_Hash {
|
|
51610
|
-
// Safe version that clones internal state
|
|
51611
|
-
clone() {
|
|
51612
|
-
return this._cloneInto();
|
|
51613
|
-
}
|
|
51614
|
-
}
|
|
51615
|
-
// Check if object doens't have custom constructor (like Uint8Array/Array)
|
|
51616
|
-
const isPlainObject = (obj) => Object.prototype.toString.call(obj) === '[object Object]' && obj.constructor === Object;
|
|
51617
|
-
function esm_utils_checkOpts(defaults, opts) {
|
|
51618
|
-
if (opts !== undefined && (typeof opts !== 'object' || !isPlainObject(opts)))
|
|
51619
|
-
throw new Error('Options should be object or undefined');
|
|
51620
|
-
const merged = Object.assign(defaults, opts);
|
|
51621
|
-
return merged;
|
|
51622
|
-
}
|
|
51623
|
-
function esm_utils_wrapConstructor(hashCons) {
|
|
51624
|
-
const hashC = (msg) => hashCons().update(esm_utils_toBytes(msg)).digest();
|
|
51625
|
-
const tmp = hashCons();
|
|
51626
|
-
hashC.outputLen = tmp.outputLen;
|
|
51627
|
-
hashC.blockLen = tmp.blockLen;
|
|
51628
|
-
hashC.create = () => hashCons();
|
|
51629
|
-
return hashC;
|
|
51630
|
-
}
|
|
51631
|
-
function esm_utils_wrapConstructorWithOpts(hashCons) {
|
|
51632
|
-
const hashC = (msg, opts) => hashCons(opts).update(esm_utils_toBytes(msg)).digest();
|
|
51633
|
-
const tmp = hashCons({});
|
|
51634
|
-
hashC.outputLen = tmp.outputLen;
|
|
51635
|
-
hashC.blockLen = tmp.blockLen;
|
|
51636
|
-
hashC.create = (opts) => hashCons(opts);
|
|
51637
|
-
return hashC;
|
|
51638
|
-
}
|
|
51639
|
-
function esm_utils_wrapXOFConstructorWithOpts(hashCons) {
|
|
51640
|
-
const hashC = (msg, opts) => hashCons(opts).update(esm_utils_toBytes(msg)).digest();
|
|
51641
|
-
const tmp = hashCons({});
|
|
51642
|
-
hashC.outputLen = tmp.outputLen;
|
|
51643
|
-
hashC.blockLen = tmp.blockLen;
|
|
51644
|
-
hashC.create = (opts) => hashCons(opts);
|
|
51645
|
-
return hashC;
|
|
51646
|
-
}
|
|
51647
|
-
/**
|
|
51648
|
-
* Secure PRNG. Uses `crypto.getRandomValues`, which defers to OS.
|
|
51649
|
-
*/
|
|
51650
|
-
function esm_utils_randomBytes(bytesLength = 32) {
|
|
51651
|
-
if (hashes_esm_crypto_crypto && typeof hashes_esm_crypto_crypto.getRandomValues === 'function') {
|
|
51652
|
-
return hashes_esm_crypto_crypto.getRandomValues(new Uint8Array(bytesLength));
|
|
51653
|
-
}
|
|
51654
|
-
throw new Error('crypto.getRandomValues must be defined');
|
|
51655
|
-
}
|
|
51656
|
-
//# sourceMappingURL=utils.js.map
|
|
51657
|
-
;// ./node_modules/@noble/hashes/esm/_sha2.js
|
|
51658
|
-
|
|
51659
|
-
|
|
51660
|
-
// Polyfill for Safari 14
|
|
51661
|
-
function _sha2_setBigUint64(view, byteOffset, value, isLE) {
|
|
51662
|
-
if (typeof view.setBigUint64 === 'function')
|
|
51663
|
-
return view.setBigUint64(byteOffset, value, isLE);
|
|
51664
|
-
const _32n = BigInt(32);
|
|
51665
|
-
const _u32_max = BigInt(0xffffffff);
|
|
51666
|
-
const wh = Number((value >> _32n) & _u32_max);
|
|
51667
|
-
const wl = Number(value & _u32_max);
|
|
51668
|
-
const h = isLE ? 4 : 0;
|
|
51669
|
-
const l = isLE ? 0 : 4;
|
|
51670
|
-
view.setUint32(byteOffset + h, wh, isLE);
|
|
51671
|
-
view.setUint32(byteOffset + l, wl, isLE);
|
|
51672
|
-
}
|
|
51673
|
-
// Base SHA2 class (RFC 6234)
|
|
51674
|
-
class _sha2_SHA2 extends esm_utils_Hash {
|
|
51675
|
-
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
51676
|
-
super();
|
|
51677
|
-
this.blockLen = blockLen;
|
|
51678
|
-
this.outputLen = outputLen;
|
|
51679
|
-
this.padOffset = padOffset;
|
|
51680
|
-
this.isLE = isLE;
|
|
51681
|
-
this.finished = false;
|
|
51682
|
-
this.length = 0;
|
|
51683
|
-
this.pos = 0;
|
|
51684
|
-
this.destroyed = false;
|
|
51685
|
-
this.buffer = new Uint8Array(blockLen);
|
|
51686
|
-
this.view = esm_utils_createView(this.buffer);
|
|
51687
|
-
}
|
|
51688
|
-
update(data) {
|
|
51689
|
-
esm_assert.exists(this);
|
|
51690
|
-
const { view, buffer, blockLen } = this;
|
|
51691
|
-
data = esm_utils_toBytes(data);
|
|
51692
|
-
const len = data.length;
|
|
51693
|
-
for (let pos = 0; pos < len;) {
|
|
51694
|
-
const take = Math.min(blockLen - this.pos, len - pos);
|
|
51695
|
-
// Fast path: we have at least one block in input, cast it to view and process
|
|
51696
|
-
if (take === blockLen) {
|
|
51697
|
-
const dataView = esm_utils_createView(data);
|
|
51698
|
-
for (; blockLen <= len - pos; pos += blockLen)
|
|
51699
|
-
this.process(dataView, pos);
|
|
51700
|
-
continue;
|
|
51701
|
-
}
|
|
51702
|
-
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
51703
|
-
this.pos += take;
|
|
51704
|
-
pos += take;
|
|
51705
|
-
if (this.pos === blockLen) {
|
|
51706
|
-
this.process(view, 0);
|
|
51707
|
-
this.pos = 0;
|
|
51708
|
-
}
|
|
51709
|
-
}
|
|
51710
|
-
this.length += data.length;
|
|
51711
|
-
this.roundClean();
|
|
51712
|
-
return this;
|
|
51713
|
-
}
|
|
51714
|
-
digestInto(out) {
|
|
51715
|
-
esm_assert.exists(this);
|
|
51716
|
-
esm_assert.output(out, this);
|
|
51717
|
-
this.finished = true;
|
|
51718
|
-
// Padding
|
|
51719
|
-
// We can avoid allocation of buffer for padding completely if it
|
|
51720
|
-
// was previously not allocated here. But it won't change performance.
|
|
51721
|
-
const { buffer, view, blockLen, isLE } = this;
|
|
51722
|
-
let { pos } = this;
|
|
51723
|
-
// append the bit '1' to the message
|
|
51724
|
-
buffer[pos++] = 0b10000000;
|
|
51725
|
-
this.buffer.subarray(pos).fill(0);
|
|
51726
|
-
// we have less than padOffset left in buffer, so we cannot put length in current block, need process it and pad again
|
|
51727
|
-
if (this.padOffset > blockLen - pos) {
|
|
51728
|
-
this.process(view, 0);
|
|
51729
|
-
pos = 0;
|
|
51730
|
-
}
|
|
51731
|
-
// Pad until full block byte with zeros
|
|
51732
|
-
for (let i = pos; i < blockLen; i++)
|
|
51733
|
-
buffer[i] = 0;
|
|
51734
|
-
// Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that
|
|
51735
|
-
// You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.
|
|
51736
|
-
// So we just write lowest 64 bits of that value.
|
|
51737
|
-
_sha2_setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
|
|
51738
|
-
this.process(view, 0);
|
|
51739
|
-
const oview = esm_utils_createView(out);
|
|
51740
|
-
const len = this.outputLen;
|
|
51741
|
-
// NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT
|
|
51742
|
-
if (len % 4)
|
|
51743
|
-
throw new Error('_sha2: outputLen should be aligned to 32bit');
|
|
51744
|
-
const outLen = len / 4;
|
|
51745
|
-
const state = this.get();
|
|
51746
|
-
if (outLen > state.length)
|
|
51747
|
-
throw new Error('_sha2: outputLen bigger than state');
|
|
51748
|
-
for (let i = 0; i < outLen; i++)
|
|
51749
|
-
oview.setUint32(4 * i, state[i], isLE);
|
|
51750
|
-
}
|
|
51751
|
-
digest() {
|
|
51752
|
-
const { buffer, outputLen } = this;
|
|
51753
|
-
this.digestInto(buffer);
|
|
51754
|
-
const res = buffer.slice(0, outputLen);
|
|
51755
|
-
this.destroy();
|
|
51756
|
-
return res;
|
|
51757
|
-
}
|
|
51758
|
-
_cloneInto(to) {
|
|
51759
|
-
to || (to = new this.constructor());
|
|
51760
|
-
to.set(...this.get());
|
|
51761
|
-
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
|
51762
|
-
to.length = length;
|
|
51763
|
-
to.pos = pos;
|
|
51764
|
-
to.finished = finished;
|
|
51765
|
-
to.destroyed = destroyed;
|
|
51766
|
-
if (length % blockLen)
|
|
51767
|
-
to.buffer.set(buffer);
|
|
51768
|
-
return to;
|
|
51769
|
-
}
|
|
51770
|
-
}
|
|
51771
|
-
//# sourceMappingURL=_sha2.js.map
|
|
51772
51454
|
;// ./node_modules/@noble/hashes/esm/sha256.js
|
|
51773
|
-
|
|
51774
|
-
|
|
51775
|
-
// Choice: a ? b : c
|
|
51776
|
-
const sha256_Chi = (a, b, c) => (a & b) ^ (~a & c);
|
|
51777
|
-
// Majority function, true if any two inpust is true
|
|
51778
|
-
const sha256_Maj = (a, b, c) => (a & b) ^ (a & c) ^ (b & c);
|
|
51779
|
-
// Round constants:
|
|
51780
|
-
// first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311)
|
|
51781
|
-
// prettier-ignore
|
|
51782
|
-
const sha256_SHA256_K = new Uint32Array([
|
|
51783
|
-
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
51784
|
-
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
51785
|
-
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
51786
|
-
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
|
51787
|
-
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
|
51788
|
-
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
51789
|
-
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
51790
|
-
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
|
51791
|
-
]);
|
|
51792
|
-
// Initial state (first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19):
|
|
51793
|
-
// prettier-ignore
|
|
51794
|
-
const sha256_IV = new Uint32Array([
|
|
51795
|
-
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
|
|
51796
|
-
]);
|
|
51797
|
-
// Temporary buffer, not used to store anything between runs
|
|
51798
|
-
// Named this way because it matches specification.
|
|
51799
|
-
const sha256_SHA256_W = new Uint32Array(64);
|
|
51800
|
-
class sha256_SHA256 extends _sha2_SHA2 {
|
|
51801
|
-
constructor() {
|
|
51802
|
-
super(64, 32, 8, false);
|
|
51803
|
-
// We cannot use array here since array allows indexing by variable
|
|
51804
|
-
// which means optimizer/compiler cannot use registers.
|
|
51805
|
-
this.A = sha256_IV[0] | 0;
|
|
51806
|
-
this.B = sha256_IV[1] | 0;
|
|
51807
|
-
this.C = sha256_IV[2] | 0;
|
|
51808
|
-
this.D = sha256_IV[3] | 0;
|
|
51809
|
-
this.E = sha256_IV[4] | 0;
|
|
51810
|
-
this.F = sha256_IV[5] | 0;
|
|
51811
|
-
this.G = sha256_IV[6] | 0;
|
|
51812
|
-
this.H = sha256_IV[7] | 0;
|
|
51813
|
-
}
|
|
51814
|
-
get() {
|
|
51815
|
-
const { A, B, C, D, E, F, G, H } = this;
|
|
51816
|
-
return [A, B, C, D, E, F, G, H];
|
|
51817
|
-
}
|
|
51818
|
-
// prettier-ignore
|
|
51819
|
-
set(A, B, C, D, E, F, G, H) {
|
|
51820
|
-
this.A = A | 0;
|
|
51821
|
-
this.B = B | 0;
|
|
51822
|
-
this.C = C | 0;
|
|
51823
|
-
this.D = D | 0;
|
|
51824
|
-
this.E = E | 0;
|
|
51825
|
-
this.F = F | 0;
|
|
51826
|
-
this.G = G | 0;
|
|
51827
|
-
this.H = H | 0;
|
|
51828
|
-
}
|
|
51829
|
-
process(view, offset) {
|
|
51830
|
-
// Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array
|
|
51831
|
-
for (let i = 0; i < 16; i++, offset += 4)
|
|
51832
|
-
sha256_SHA256_W[i] = view.getUint32(offset, false);
|
|
51833
|
-
for (let i = 16; i < 64; i++) {
|
|
51834
|
-
const W15 = sha256_SHA256_W[i - 15];
|
|
51835
|
-
const W2 = sha256_SHA256_W[i - 2];
|
|
51836
|
-
const s0 = esm_utils_rotr(W15, 7) ^ esm_utils_rotr(W15, 18) ^ (W15 >>> 3);
|
|
51837
|
-
const s1 = esm_utils_rotr(W2, 17) ^ esm_utils_rotr(W2, 19) ^ (W2 >>> 10);
|
|
51838
|
-
sha256_SHA256_W[i] = (s1 + sha256_SHA256_W[i - 7] + s0 + sha256_SHA256_W[i - 16]) | 0;
|
|
51839
|
-
}
|
|
51840
|
-
// Compression function main loop, 64 rounds
|
|
51841
|
-
let { A, B, C, D, E, F, G, H } = this;
|
|
51842
|
-
for (let i = 0; i < 64; i++) {
|
|
51843
|
-
const sigma1 = esm_utils_rotr(E, 6) ^ esm_utils_rotr(E, 11) ^ esm_utils_rotr(E, 25);
|
|
51844
|
-
const T1 = (H + sigma1 + sha256_Chi(E, F, G) + sha256_SHA256_K[i] + sha256_SHA256_W[i]) | 0;
|
|
51845
|
-
const sigma0 = esm_utils_rotr(A, 2) ^ esm_utils_rotr(A, 13) ^ esm_utils_rotr(A, 22);
|
|
51846
|
-
const T2 = (sigma0 + sha256_Maj(A, B, C)) | 0;
|
|
51847
|
-
H = G;
|
|
51848
|
-
G = F;
|
|
51849
|
-
F = E;
|
|
51850
|
-
E = (D + T1) | 0;
|
|
51851
|
-
D = C;
|
|
51852
|
-
C = B;
|
|
51853
|
-
B = A;
|
|
51854
|
-
A = (T1 + T2) | 0;
|
|
51855
|
-
}
|
|
51856
|
-
// Add the compressed chunk to the current hash value
|
|
51857
|
-
A = (A + this.A) | 0;
|
|
51858
|
-
B = (B + this.B) | 0;
|
|
51859
|
-
C = (C + this.C) | 0;
|
|
51860
|
-
D = (D + this.D) | 0;
|
|
51861
|
-
E = (E + this.E) | 0;
|
|
51862
|
-
F = (F + this.F) | 0;
|
|
51863
|
-
G = (G + this.G) | 0;
|
|
51864
|
-
H = (H + this.H) | 0;
|
|
51865
|
-
this.set(A, B, C, D, E, F, G, H);
|
|
51866
|
-
}
|
|
51867
|
-
roundClean() {
|
|
51868
|
-
sha256_SHA256_W.fill(0);
|
|
51869
|
-
}
|
|
51870
|
-
destroy() {
|
|
51871
|
-
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
51872
|
-
this.buffer.fill(0);
|
|
51873
|
-
}
|
|
51874
|
-
}
|
|
51875
|
-
// Constants from https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf
|
|
51876
|
-
class sha256_SHA224 extends sha256_SHA256 {
|
|
51877
|
-
constructor() {
|
|
51878
|
-
super();
|
|
51879
|
-
this.A = 0xc1059ed8 | 0;
|
|
51880
|
-
this.B = 0x367cd507 | 0;
|
|
51881
|
-
this.C = 0x3070dd17 | 0;
|
|
51882
|
-
this.D = 0xf70e5939 | 0;
|
|
51883
|
-
this.E = 0xffc00b31 | 0;
|
|
51884
|
-
this.F = 0x68581511 | 0;
|
|
51885
|
-
this.G = 0x64f98fa7 | 0;
|
|
51886
|
-
this.H = 0xbefa4fa4 | 0;
|
|
51887
|
-
this.outputLen = 28;
|
|
51888
|
-
}
|
|
51889
|
-
}
|
|
51890
51455
|
/**
|
|
51891
|
-
* SHA2-256 hash
|
|
51892
|
-
*
|
|
51456
|
+
* SHA2-256 a.k.a. sha256. In JS, it is the fastest hash, even faster than Blake3.
|
|
51457
|
+
*
|
|
51458
|
+
* To break sha256 using birthday attack, attackers need to try 2^128 hashes.
|
|
51459
|
+
* BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.
|
|
51460
|
+
*
|
|
51461
|
+
* Check out [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf).
|
|
51462
|
+
* @module
|
|
51463
|
+
* @deprecated
|
|
51893
51464
|
*/
|
|
51894
|
-
|
|
51895
|
-
|
|
51465
|
+
|
|
51466
|
+
/** @deprecated Use import from `noble/hashes/sha2` module */
|
|
51467
|
+
const sha256_SHA256 = sha2_SHA256;
|
|
51468
|
+
/** @deprecated Use import from `noble/hashes/sha2` module */
|
|
51469
|
+
const sha256_sha256 = esm_sha2_sha256;
|
|
51470
|
+
/** @deprecated Use import from `noble/hashes/sha2` module */
|
|
51471
|
+
const sha256_SHA224 = sha2_SHA224;
|
|
51472
|
+
/** @deprecated Use import from `noble/hashes/sha2` module */
|
|
51473
|
+
const sha256_sha224 = sha2_sha224;
|
|
51896
51474
|
//# sourceMappingURL=sha256.js.map
|
|
51897
|
-
;// ./node_modules/@noble/hashes/esm/_u64.js
|
|
51898
|
-
const esm_u64_U32_MASK64 = BigInt(2 ** 32 - 1);
|
|
51899
|
-
const esm_u64_32n = BigInt(32);
|
|
51900
|
-
// We are not using BigUint64Array, because they are extremely slow as per 2022
|
|
51901
|
-
function esm_u64_fromBig(n, le = false) {
|
|
51902
|
-
if (le)
|
|
51903
|
-
return { h: Number(n & esm_u64_U32_MASK64), l: Number((n >> esm_u64_32n) & esm_u64_U32_MASK64) };
|
|
51904
|
-
return { h: Number((n >> esm_u64_32n) & esm_u64_U32_MASK64) | 0, l: Number(n & esm_u64_U32_MASK64) | 0 };
|
|
51905
|
-
}
|
|
51906
|
-
function esm_u64_split(lst, le = false) {
|
|
51907
|
-
let Ah = new Uint32Array(lst.length);
|
|
51908
|
-
let Al = new Uint32Array(lst.length);
|
|
51909
|
-
for (let i = 0; i < lst.length; i++) {
|
|
51910
|
-
const { h, l } = esm_u64_fromBig(lst[i], le);
|
|
51911
|
-
[Ah[i], Al[i]] = [h, l];
|
|
51912
|
-
}
|
|
51913
|
-
return [Ah, Al];
|
|
51914
|
-
}
|
|
51915
|
-
const esm_u64_toBig = (h, l) => (BigInt(h >>> 0) << esm_u64_32n) | BigInt(l >>> 0);
|
|
51916
|
-
// for Shift in [0, 32)
|
|
51917
|
-
const esm_u64_shrSH = (h, l, s) => h >>> s;
|
|
51918
|
-
const esm_u64_shrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);
|
|
51919
|
-
// Right rotate for Shift in [1, 32)
|
|
51920
|
-
const esm_u64_rotrSH = (h, l, s) => (h >>> s) | (l << (32 - s));
|
|
51921
|
-
const esm_u64_rotrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);
|
|
51922
|
-
// Right rotate for Shift in (32, 64), NOTE: 32 is special case.
|
|
51923
|
-
const esm_u64_rotrBH = (h, l, s) => (h << (64 - s)) | (l >>> (s - 32));
|
|
51924
|
-
const esm_u64_rotrBL = (h, l, s) => (h >>> (s - 32)) | (l << (64 - s));
|
|
51925
|
-
// Right rotate for shift===32 (just swaps l&h)
|
|
51926
|
-
const esm_u64_rotr32H = (h, l) => l;
|
|
51927
|
-
const esm_u64_rotr32L = (h, l) => h;
|
|
51928
|
-
// Left rotate for Shift in [1, 32)
|
|
51929
|
-
const esm_u64_rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s));
|
|
51930
|
-
const esm_u64_rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s));
|
|
51931
|
-
// Left rotate for Shift in (32, 64), NOTE: 32 is special case.
|
|
51932
|
-
const esm_u64_rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));
|
|
51933
|
-
const esm_u64_rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));
|
|
51934
|
-
// JS uses 32-bit signed integers for bitwise operations which means we cannot
|
|
51935
|
-
// simple take carry out of low bit sum by shift, we need to use division.
|
|
51936
|
-
// Removing "export" has 5% perf penalty -_-
|
|
51937
|
-
function esm_u64_add(Ah, Al, Bh, Bl) {
|
|
51938
|
-
const l = (Al >>> 0) + (Bl >>> 0);
|
|
51939
|
-
return { h: (Ah + Bh + ((l / 2 ** 32) | 0)) | 0, l: l | 0 };
|
|
51940
|
-
}
|
|
51941
|
-
// Addition with more than 2 elements
|
|
51942
|
-
const esm_u64_add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
|
|
51943
|
-
const esm_u64_add3H = (low, Ah, Bh, Ch) => (Ah + Bh + Ch + ((low / 2 ** 32) | 0)) | 0;
|
|
51944
|
-
const esm_u64_add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
|
|
51945
|
-
const esm_u64_add4H = (low, Ah, Bh, Ch, Dh) => (Ah + Bh + Ch + Dh + ((low / 2 ** 32) | 0)) | 0;
|
|
51946
|
-
const esm_u64_add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
|
|
51947
|
-
const esm_u64_add5H = (low, Ah, Bh, Ch, Dh, Eh) => (Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0;
|
|
51948
|
-
// prettier-ignore
|
|
51949
|
-
const esm_u64_u64 = {
|
|
51950
|
-
fromBig: esm_u64_fromBig, split: esm_u64_split, toBig: esm_u64_toBig,
|
|
51951
|
-
shrSH: esm_u64_shrSH, shrSL: esm_u64_shrSL,
|
|
51952
|
-
rotrSH: esm_u64_rotrSH, rotrSL: esm_u64_rotrSL, rotrBH: esm_u64_rotrBH, rotrBL: esm_u64_rotrBL,
|
|
51953
|
-
rotr32H: esm_u64_rotr32H, rotr32L: esm_u64_rotr32L,
|
|
51954
|
-
rotlSH: esm_u64_rotlSH, rotlSL: esm_u64_rotlSL, rotlBH: esm_u64_rotlBH, rotlBL: esm_u64_rotlBL,
|
|
51955
|
-
add: esm_u64_add, add3L: esm_u64_add3L, add3H: esm_u64_add3H, add4L: esm_u64_add4L, add4H: esm_u64_add4H, add5H: esm_u64_add5H, add5L: esm_u64_add5L,
|
|
51956
|
-
};
|
|
51957
|
-
/* harmony default export */ const hashes_esm_u64 = (esm_u64_u64);
|
|
51958
|
-
//# sourceMappingURL=_u64.js.map
|
|
51959
51475
|
;// ./node_modules/@noble/hashes/esm/sha3.js
|
|
51476
|
+
/**
|
|
51477
|
+
* SHA3 (keccak) hash function, based on a new "Sponge function" design.
|
|
51478
|
+
* Different from older hashes, the internal state is bigger than output size.
|
|
51479
|
+
*
|
|
51480
|
+
* Check out [FIPS-202](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf),
|
|
51481
|
+
* [Website](https://keccak.team/keccak.html),
|
|
51482
|
+
* [the differences between SHA-3 and Keccak](https://crypto.stackexchange.com/questions/15727/what-are-the-key-differences-between-the-draft-sha-3-standard-and-the-keccak-sub).
|
|
51483
|
+
*
|
|
51484
|
+
* Check out `sha3-addons` module for cSHAKE, k12, and others.
|
|
51485
|
+
* @module
|
|
51486
|
+
*/
|
|
51960
51487
|
|
|
51488
|
+
// prettier-ignore
|
|
51961
51489
|
|
|
51962
|
-
|
|
51490
|
+
// No __PURE__ annotations in sha3 header:
|
|
51491
|
+
// EVERYTHING is in fact used on every export.
|
|
51963
51492
|
// Various per round constants calculations
|
|
51964
|
-
const [sha3_SHA3_PI, sha3_SHA3_ROTL, sha3_SHA3_IOTA] = [[], [], []];
|
|
51965
51493
|
const sha3_0n = BigInt(0);
|
|
51966
51494
|
const sha3_1n = BigInt(1);
|
|
51967
51495
|
const sha3_2n = BigInt(2);
|
|
51968
51496
|
const sha3_7n = BigInt(7);
|
|
51969
51497
|
const sha3_256n = BigInt(256);
|
|
51970
51498
|
const sha3_0x71n = BigInt(0x71);
|
|
51499
|
+
const sha3_SHA3_PI = [];
|
|
51500
|
+
const sha3_SHA3_ROTL = [];
|
|
51501
|
+
const sha3_SHA3_IOTA = [];
|
|
51971
51502
|
for (let round = 0, R = sha3_1n, x = 1, y = 0; round < 24; round++) {
|
|
51972
51503
|
// Pi
|
|
51973
51504
|
[x, y] = [y, (2 * x + 3 * y) % 5];
|
|
@@ -51979,15 +51510,17 @@ for (let round = 0, R = sha3_1n, x = 1, y = 0; round < 24; round++) {
|
|
|
51979
51510
|
for (let j = 0; j < 7; j++) {
|
|
51980
51511
|
R = ((R << sha3_1n) ^ ((R >> sha3_7n) * sha3_0x71n)) % sha3_256n;
|
|
51981
51512
|
if (R & sha3_2n)
|
|
51982
|
-
t ^= sha3_1n << ((sha3_1n << BigInt(j)) - sha3_1n);
|
|
51513
|
+
t ^= sha3_1n << ((sha3_1n << /* @__PURE__ */ BigInt(j)) - sha3_1n);
|
|
51983
51514
|
}
|
|
51984
51515
|
sha3_SHA3_IOTA.push(t);
|
|
51985
51516
|
}
|
|
51986
|
-
const
|
|
51517
|
+
const IOTAS = _u64_split(sha3_SHA3_IOTA, true);
|
|
51518
|
+
const sha3_SHA3_IOTA_H = IOTAS[0];
|
|
51519
|
+
const sha3_SHA3_IOTA_L = IOTAS[1];
|
|
51987
51520
|
// Left rotation (without 0, 32, 64)
|
|
51988
|
-
const sha3_rotlH = (h, l, s) => s > 32 ?
|
|
51989
|
-
const sha3_rotlL = (h, l, s) => s > 32 ?
|
|
51990
|
-
|
|
51521
|
+
const sha3_rotlH = (h, l, s) => (s > 32 ? _u64_rotlBH(h, l, s) : _u64_rotlSH(h, l, s));
|
|
51522
|
+
const sha3_rotlL = (h, l, s) => (s > 32 ? _u64_rotlBL(h, l, s) : _u64_rotlSL(h, l, s));
|
|
51523
|
+
/** `keccakf1600` internal function, additionally allows to adjust round count. */
|
|
51991
51524
|
function sha3_keccakP(s, rounds = 24) {
|
|
51992
51525
|
const B = new Uint32Array(5 * 2);
|
|
51993
51526
|
// NOTE: all indices are x2 since we store state as u32 instead of u64 (bigints to slow in js)
|
|
@@ -52031,38 +51564,47 @@ function sha3_keccakP(s, rounds = 24) {
|
|
|
52031
51564
|
s[0] ^= sha3_SHA3_IOTA_H[round];
|
|
52032
51565
|
s[1] ^= sha3_SHA3_IOTA_L[round];
|
|
52033
51566
|
}
|
|
52034
|
-
B
|
|
51567
|
+
clean(B);
|
|
52035
51568
|
}
|
|
52036
|
-
|
|
51569
|
+
/** Keccak sponge function. */
|
|
51570
|
+
class sha3_Keccak extends utils_Hash {
|
|
52037
51571
|
// NOTE: we accept arguments in bytes instead of bits here.
|
|
52038
51572
|
constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {
|
|
52039
51573
|
super();
|
|
51574
|
+
this.pos = 0;
|
|
51575
|
+
this.posOut = 0;
|
|
51576
|
+
this.finished = false;
|
|
51577
|
+
this.destroyed = false;
|
|
51578
|
+
this.enableXOF = false;
|
|
52040
51579
|
this.blockLen = blockLen;
|
|
52041
51580
|
this.suffix = suffix;
|
|
52042
51581
|
this.outputLen = outputLen;
|
|
52043
51582
|
this.enableXOF = enableXOF;
|
|
52044
51583
|
this.rounds = rounds;
|
|
52045
|
-
this.pos = 0;
|
|
52046
|
-
this.posOut = 0;
|
|
52047
|
-
this.finished = false;
|
|
52048
|
-
this.destroyed = false;
|
|
52049
51584
|
// Can be passed from user as dkLen
|
|
52050
|
-
|
|
51585
|
+
anumber(outputLen);
|
|
52051
51586
|
// 1600 = 5x5 matrix of 64bit. 1600 bits === 200 bytes
|
|
52052
|
-
|
|
52053
|
-
|
|
51587
|
+
// 0 < blockLen < 200
|
|
51588
|
+
if (!(0 < blockLen && blockLen < 200))
|
|
51589
|
+
throw new Error('only keccak-f1600 function is supported');
|
|
52054
51590
|
this.state = new Uint8Array(200);
|
|
52055
|
-
this.state32 =
|
|
51591
|
+
this.state32 = utils_u32(this.state);
|
|
51592
|
+
}
|
|
51593
|
+
clone() {
|
|
51594
|
+
return this._cloneInto();
|
|
52056
51595
|
}
|
|
52057
51596
|
keccak() {
|
|
51597
|
+
swap32IfBE(this.state32);
|
|
52058
51598
|
sha3_keccakP(this.state32, this.rounds);
|
|
51599
|
+
swap32IfBE(this.state32);
|
|
52059
51600
|
this.posOut = 0;
|
|
52060
51601
|
this.pos = 0;
|
|
52061
51602
|
}
|
|
52062
51603
|
update(data) {
|
|
52063
|
-
|
|
51604
|
+
aexists(this);
|
|
51605
|
+
data = utils_toBytes(data);
|
|
51606
|
+
abytes(data);
|
|
52064
51607
|
const { blockLen, state } = this;
|
|
52065
|
-
data = esm_utils_toBytes(data);
|
|
52066
51608
|
const len = data.length;
|
|
52067
51609
|
for (let pos = 0; pos < len;) {
|
|
52068
51610
|
const take = Math.min(blockLen - this.pos, len - pos);
|
|
@@ -52086,8 +51628,8 @@ class sha3_Keccak extends esm_utils_Hash {
|
|
|
52086
51628
|
this.keccak();
|
|
52087
51629
|
}
|
|
52088
51630
|
writeInto(out) {
|
|
52089
|
-
|
|
52090
|
-
|
|
51631
|
+
aexists(this, false);
|
|
51632
|
+
abytes(out);
|
|
52091
51633
|
this.finish();
|
|
52092
51634
|
const bufferOut = this.state;
|
|
52093
51635
|
const { blockLen } = this;
|
|
@@ -52108,11 +51650,11 @@ class sha3_Keccak extends esm_utils_Hash {
|
|
|
52108
51650
|
return this.writeInto(out);
|
|
52109
51651
|
}
|
|
52110
51652
|
xof(bytes) {
|
|
52111
|
-
|
|
51653
|
+
anumber(bytes);
|
|
52112
51654
|
return this.xofInto(new Uint8Array(bytes));
|
|
52113
51655
|
}
|
|
52114
51656
|
digestInto(out) {
|
|
52115
|
-
|
|
51657
|
+
aoutput(out, this);
|
|
52116
51658
|
if (this.finished)
|
|
52117
51659
|
throw new Error('digest() was already called');
|
|
52118
51660
|
this.writeInto(out);
|
|
@@ -52124,7 +51666,7 @@ class sha3_Keccak extends esm_utils_Hash {
|
|
|
52124
51666
|
}
|
|
52125
51667
|
destroy() {
|
|
52126
51668
|
this.destroyed = true;
|
|
52127
|
-
this.state
|
|
51669
|
+
clean(this.state);
|
|
52128
51670
|
}
|
|
52129
51671
|
_cloneInto(to) {
|
|
52130
51672
|
const { blockLen, suffix, outputLen, rounds, enableXOF } = this;
|
|
@@ -52142,69 +51684,251 @@ class sha3_Keccak extends esm_utils_Hash {
|
|
|
52142
51684
|
return to;
|
|
52143
51685
|
}
|
|
52144
51686
|
}
|
|
52145
|
-
const sha3_gen = (suffix, blockLen, outputLen) =>
|
|
52146
|
-
|
|
52147
|
-
|
|
52148
|
-
|
|
52149
|
-
|
|
52150
|
-
*/
|
|
52151
|
-
const
|
|
52152
|
-
|
|
52153
|
-
const sha3_sha3_512 = sha3_gen(0x06, 72, 512 / 8);
|
|
52154
|
-
|
|
51687
|
+
const sha3_gen = (suffix, blockLen, outputLen) => createHasher(() => new sha3_Keccak(blockLen, suffix, outputLen));
|
|
51688
|
+
/** SHA3-224 hash function. */
|
|
51689
|
+
const sha3_sha3_224 = /* @__PURE__ */ (() => sha3_gen(0x06, 144, 224 / 8))();
|
|
51690
|
+
/** SHA3-256 hash function. Different from keccak-256. */
|
|
51691
|
+
const sha3_sha3_256 = /* @__PURE__ */ (() => sha3_gen(0x06, 136, 256 / 8))();
|
|
51692
|
+
/** SHA3-384 hash function. */
|
|
51693
|
+
const sha3_sha3_384 = /* @__PURE__ */ (() => sha3_gen(0x06, 104, 384 / 8))();
|
|
51694
|
+
/** SHA3-512 hash function. */
|
|
51695
|
+
const sha3_sha3_512 = /* @__PURE__ */ (() => sha3_gen(0x06, 72, 512 / 8))();
|
|
51696
|
+
/** keccak-224 hash function. */
|
|
51697
|
+
const sha3_keccak_224 = /* @__PURE__ */ (() => sha3_gen(0x01, 144, 224 / 8))();
|
|
51698
|
+
/** keccak-256 hash function. Different from SHA3-256. */
|
|
51699
|
+
const sha3_keccak_256 = /* @__PURE__ */ (() => sha3_gen(0x01, 136, 256 / 8))();
|
|
51700
|
+
/** keccak-384 hash function. */
|
|
51701
|
+
const sha3_keccak_384 = /* @__PURE__ */ (() => sha3_gen(0x01, 104, 384 / 8))();
|
|
51702
|
+
/** keccak-512 hash function. */
|
|
51703
|
+
const sha3_keccak_512 = /* @__PURE__ */ (() => sha3_gen(0x01, 72, 512 / 8))();
|
|
51704
|
+
const sha3_genShake = (suffix, blockLen, outputLen) => createXOFer((opts = {}) => new sha3_Keccak(blockLen, suffix, opts.dkLen === undefined ? outputLen : opts.dkLen, true));
|
|
51705
|
+
/** SHAKE128 XOF with 128-bit security. */
|
|
51706
|
+
const sha3_shake128 = /* @__PURE__ */ (() => sha3_genShake(0x1f, 168, 128 / 8))();
|
|
51707
|
+
/** SHAKE256 XOF with 256-bit security. */
|
|
51708
|
+
const sha3_shake256 = /* @__PURE__ */ (() => sha3_genShake(0x1f, 136, 256 / 8))();
|
|
51709
|
+
//# sourceMappingURL=sha3.js.map
|
|
51710
|
+
;// ./node_modules/@noble/hashes/esm/legacy.js
|
|
52155
51711
|
/**
|
|
52156
|
-
|
|
52157
|
-
|
|
51712
|
+
|
|
51713
|
+
SHA1 (RFC 3174), MD5 (RFC 1321) and RIPEMD160 (RFC 2286) legacy, weak hash functions.
|
|
51714
|
+
Don't use them in a new protocol. What "weak" means:
|
|
51715
|
+
|
|
51716
|
+
- Collisions can be made with 2^18 effort in MD5, 2^60 in SHA1, 2^80 in RIPEMD160.
|
|
51717
|
+
- No practical pre-image attacks (only theoretical, 2^123.4)
|
|
51718
|
+
- HMAC seems kinda ok: https://datatracker.ietf.org/doc/html/rfc6151
|
|
51719
|
+
* @module
|
|
52158
51720
|
*/
|
|
52159
|
-
const sha3_keccak_256 = sha3_gen(0x01, 136, 256 / 8);
|
|
52160
|
-
const sha3_keccak_384 = sha3_gen(0x01, 104, 384 / 8);
|
|
52161
|
-
const sha3_keccak_512 = sha3_gen(0x01, 72, 512 / 8);
|
|
52162
|
-
const sha3_genShake = (suffix, blockLen, outputLen) => esm_utils_wrapXOFConstructorWithOpts((opts = {}) => new sha3_Keccak(blockLen, suffix, opts.dkLen === undefined ? outputLen : opts.dkLen, true));
|
|
52163
|
-
const sha3_shake128 = sha3_genShake(0x1f, 168, 128 / 8);
|
|
52164
|
-
const sha3_shake256 = sha3_genShake(0x1f, 136, 256 / 8);
|
|
52165
|
-
//# sourceMappingURL=sha3.js.map
|
|
52166
|
-
;// ./node_modules/@noble/hashes/esm/ripemd160.js
|
|
52167
51721
|
|
|
52168
51722
|
|
|
52169
|
-
|
|
52170
|
-
|
|
52171
|
-
|
|
52172
|
-
|
|
52173
|
-
|
|
52174
|
-
|
|
52175
|
-
|
|
52176
|
-
|
|
52177
|
-
|
|
52178
|
-
|
|
52179
|
-
|
|
51723
|
+
/** Initial SHA1 state */
|
|
51724
|
+
const SHA1_IV = /* @__PURE__ */ Uint32Array.from([
|
|
51725
|
+
0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0,
|
|
51726
|
+
]);
|
|
51727
|
+
// Reusable temporary buffer
|
|
51728
|
+
const SHA1_W = /* @__PURE__ */ new Uint32Array(80);
|
|
51729
|
+
/** SHA1 legacy hash class. */
|
|
51730
|
+
class SHA1 extends HashMD {
|
|
51731
|
+
constructor() {
|
|
51732
|
+
super(64, 20, 8, false);
|
|
51733
|
+
this.A = SHA1_IV[0] | 0;
|
|
51734
|
+
this.B = SHA1_IV[1] | 0;
|
|
51735
|
+
this.C = SHA1_IV[2] | 0;
|
|
51736
|
+
this.D = SHA1_IV[3] | 0;
|
|
51737
|
+
this.E = SHA1_IV[4] | 0;
|
|
51738
|
+
}
|
|
51739
|
+
get() {
|
|
51740
|
+
const { A, B, C, D, E } = this;
|
|
51741
|
+
return [A, B, C, D, E];
|
|
51742
|
+
}
|
|
51743
|
+
set(A, B, C, D, E) {
|
|
51744
|
+
this.A = A | 0;
|
|
51745
|
+
this.B = B | 0;
|
|
51746
|
+
this.C = C | 0;
|
|
51747
|
+
this.D = D | 0;
|
|
51748
|
+
this.E = E | 0;
|
|
51749
|
+
}
|
|
51750
|
+
process(view, offset) {
|
|
51751
|
+
for (let i = 0; i < 16; i++, offset += 4)
|
|
51752
|
+
SHA1_W[i] = view.getUint32(offset, false);
|
|
51753
|
+
for (let i = 16; i < 80; i++)
|
|
51754
|
+
SHA1_W[i] = rotl(SHA1_W[i - 3] ^ SHA1_W[i - 8] ^ SHA1_W[i - 14] ^ SHA1_W[i - 16], 1);
|
|
51755
|
+
// Compression function main loop, 80 rounds
|
|
51756
|
+
let { A, B, C, D, E } = this;
|
|
51757
|
+
for (let i = 0; i < 80; i++) {
|
|
51758
|
+
let F, K;
|
|
51759
|
+
if (i < 20) {
|
|
51760
|
+
F = _md_Chi(B, C, D);
|
|
51761
|
+
K = 0x5a827999;
|
|
51762
|
+
}
|
|
51763
|
+
else if (i < 40) {
|
|
51764
|
+
F = B ^ C ^ D;
|
|
51765
|
+
K = 0x6ed9eba1;
|
|
51766
|
+
}
|
|
51767
|
+
else if (i < 60) {
|
|
51768
|
+
F = _md_Maj(B, C, D);
|
|
51769
|
+
K = 0x8f1bbcdc;
|
|
51770
|
+
}
|
|
51771
|
+
else {
|
|
51772
|
+
F = B ^ C ^ D;
|
|
51773
|
+
K = 0xca62c1d6;
|
|
51774
|
+
}
|
|
51775
|
+
const T = (rotl(A, 5) + F + E + K + SHA1_W[i]) | 0;
|
|
51776
|
+
E = D;
|
|
51777
|
+
D = C;
|
|
51778
|
+
C = rotl(B, 30);
|
|
51779
|
+
B = A;
|
|
51780
|
+
A = T;
|
|
51781
|
+
}
|
|
51782
|
+
// Add the compressed chunk to the current hash value
|
|
51783
|
+
A = (A + this.A) | 0;
|
|
51784
|
+
B = (B + this.B) | 0;
|
|
51785
|
+
C = (C + this.C) | 0;
|
|
51786
|
+
D = (D + this.D) | 0;
|
|
51787
|
+
E = (E + this.E) | 0;
|
|
51788
|
+
this.set(A, B, C, D, E);
|
|
51789
|
+
}
|
|
51790
|
+
roundClean() {
|
|
51791
|
+
clean(SHA1_W);
|
|
51792
|
+
}
|
|
51793
|
+
destroy() {
|
|
51794
|
+
this.set(0, 0, 0, 0, 0);
|
|
51795
|
+
clean(this.buffer);
|
|
51796
|
+
}
|
|
51797
|
+
}
|
|
51798
|
+
/** SHA1 (RFC 3174) legacy hash function. It was cryptographically broken. */
|
|
51799
|
+
const sha1 = /* @__PURE__ */ createHasher(() => new SHA1());
|
|
51800
|
+
/** Per-round constants */
|
|
51801
|
+
const p32 = /* @__PURE__ */ Math.pow(2, 32);
|
|
51802
|
+
const K = /* @__PURE__ */ Array.from({ length: 64 }, (_, i) => Math.floor(p32 * Math.abs(Math.sin(i + 1))));
|
|
51803
|
+
/** md5 initial state: same as sha1, but 4 u32 instead of 5. */
|
|
51804
|
+
const MD5_IV = /* @__PURE__ */ SHA1_IV.slice(0, 4);
|
|
51805
|
+
// Reusable temporary buffer
|
|
51806
|
+
const MD5_W = /* @__PURE__ */ new Uint32Array(16);
|
|
51807
|
+
/** MD5 legacy hash class. */
|
|
51808
|
+
class MD5 extends HashMD {
|
|
51809
|
+
constructor() {
|
|
51810
|
+
super(64, 16, 8, true);
|
|
51811
|
+
this.A = MD5_IV[0] | 0;
|
|
51812
|
+
this.B = MD5_IV[1] | 0;
|
|
51813
|
+
this.C = MD5_IV[2] | 0;
|
|
51814
|
+
this.D = MD5_IV[3] | 0;
|
|
51815
|
+
}
|
|
51816
|
+
get() {
|
|
51817
|
+
const { A, B, C, D } = this;
|
|
51818
|
+
return [A, B, C, D];
|
|
51819
|
+
}
|
|
51820
|
+
set(A, B, C, D) {
|
|
51821
|
+
this.A = A | 0;
|
|
51822
|
+
this.B = B | 0;
|
|
51823
|
+
this.C = C | 0;
|
|
51824
|
+
this.D = D | 0;
|
|
51825
|
+
}
|
|
51826
|
+
process(view, offset) {
|
|
51827
|
+
for (let i = 0; i < 16; i++, offset += 4)
|
|
51828
|
+
MD5_W[i] = view.getUint32(offset, true);
|
|
51829
|
+
// Compression function main loop, 64 rounds
|
|
51830
|
+
let { A, B, C, D } = this;
|
|
51831
|
+
for (let i = 0; i < 64; i++) {
|
|
51832
|
+
let F, g, s;
|
|
51833
|
+
if (i < 16) {
|
|
51834
|
+
F = _md_Chi(B, C, D);
|
|
51835
|
+
g = i;
|
|
51836
|
+
s = [7, 12, 17, 22];
|
|
51837
|
+
}
|
|
51838
|
+
else if (i < 32) {
|
|
51839
|
+
F = _md_Chi(D, B, C);
|
|
51840
|
+
g = (5 * i + 1) % 16;
|
|
51841
|
+
s = [5, 9, 14, 20];
|
|
51842
|
+
}
|
|
51843
|
+
else if (i < 48) {
|
|
51844
|
+
F = B ^ C ^ D;
|
|
51845
|
+
g = (3 * i + 5) % 16;
|
|
51846
|
+
s = [4, 11, 16, 23];
|
|
51847
|
+
}
|
|
51848
|
+
else {
|
|
51849
|
+
F = C ^ (B | ~D);
|
|
51850
|
+
g = (7 * i) % 16;
|
|
51851
|
+
s = [6, 10, 15, 21];
|
|
51852
|
+
}
|
|
51853
|
+
F = F + A + K[i] + MD5_W[g];
|
|
51854
|
+
A = D;
|
|
51855
|
+
D = C;
|
|
51856
|
+
C = B;
|
|
51857
|
+
B = B + rotl(F, s[i % 4]);
|
|
51858
|
+
}
|
|
51859
|
+
// Add the compressed chunk to the current hash value
|
|
51860
|
+
A = (A + this.A) | 0;
|
|
51861
|
+
B = (B + this.B) | 0;
|
|
51862
|
+
C = (C + this.C) | 0;
|
|
51863
|
+
D = (D + this.D) | 0;
|
|
51864
|
+
this.set(A, B, C, D);
|
|
51865
|
+
}
|
|
51866
|
+
roundClean() {
|
|
51867
|
+
clean(MD5_W);
|
|
51868
|
+
}
|
|
51869
|
+
destroy() {
|
|
51870
|
+
this.set(0, 0, 0, 0);
|
|
51871
|
+
clean(this.buffer);
|
|
51872
|
+
}
|
|
51873
|
+
}
|
|
51874
|
+
/**
|
|
51875
|
+
* MD5 (RFC 1321) legacy hash function. It was cryptographically broken.
|
|
51876
|
+
* MD5 architecture is similar to SHA1, with some differences:
|
|
51877
|
+
* - Reduced output length: 16 bytes (128 bit) instead of 20
|
|
51878
|
+
* - 64 rounds, instead of 80
|
|
51879
|
+
* - Little-endian: could be faster, but will require more code
|
|
51880
|
+
* - Non-linear index selection: huge speed-up for unroll
|
|
51881
|
+
* - Per round constants: more memory accesses, additional speed-up for unroll
|
|
51882
|
+
*/
|
|
51883
|
+
const md5 = /* @__PURE__ */ createHasher(() => new MD5());
|
|
51884
|
+
// RIPEMD-160
|
|
51885
|
+
const Rho160 = /* @__PURE__ */ Uint8Array.from([
|
|
51886
|
+
7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
|
|
51887
|
+
]);
|
|
51888
|
+
const Id160 = /* @__PURE__ */ (() => Uint8Array.from(new Array(16).fill(0).map((_, i) => i)))();
|
|
51889
|
+
const Pi160 = /* @__PURE__ */ (() => Id160.map((i) => (9 * i + 5) % 16))();
|
|
51890
|
+
const idxLR = /* @__PURE__ */ (() => {
|
|
51891
|
+
const L = [Id160];
|
|
51892
|
+
const R = [Pi160];
|
|
51893
|
+
const res = [L, R];
|
|
51894
|
+
for (let i = 0; i < 4; i++)
|
|
51895
|
+
for (let j of res)
|
|
51896
|
+
j.push(j[i].map((k) => Rho160[k]));
|
|
51897
|
+
return res;
|
|
51898
|
+
})();
|
|
51899
|
+
const idxL = /* @__PURE__ */ (() => idxLR[0])();
|
|
51900
|
+
const idxR = /* @__PURE__ */ (() => idxLR[1])();
|
|
51901
|
+
// const [idxL, idxR] = idxLR;
|
|
51902
|
+
const shifts160 = /* @__PURE__ */ [
|
|
52180
51903
|
[11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8],
|
|
52181
51904
|
[12, 13, 11, 15, 6, 9, 9, 7, 12, 15, 11, 13, 7, 8, 7, 7],
|
|
52182
51905
|
[13, 15, 14, 11, 7, 7, 6, 8, 13, 14, 13, 12, 5, 5, 6, 9],
|
|
52183
51906
|
[14, 11, 12, 14, 8, 6, 5, 5, 15, 12, 15, 14, 9, 9, 8, 6],
|
|
52184
51907
|
[15, 12, 13, 13, 9, 5, 8, 6, 14, 11, 12, 11, 8, 6, 5, 5],
|
|
52185
|
-
].map((i) =>
|
|
52186
|
-
const
|
|
52187
|
-
const
|
|
52188
|
-
const
|
|
52189
|
-
|
|
52190
|
-
|
|
52191
|
-
const
|
|
51908
|
+
].map((i) => Uint8Array.from(i));
|
|
51909
|
+
const shiftsL160 = /* @__PURE__ */ idxL.map((idx, i) => idx.map((j) => shifts160[i][j]));
|
|
51910
|
+
const shiftsR160 = /* @__PURE__ */ idxR.map((idx, i) => idx.map((j) => shifts160[i][j]));
|
|
51911
|
+
const Kl160 = /* @__PURE__ */ Uint32Array.from([
|
|
51912
|
+
0x00000000, 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xa953fd4e,
|
|
51913
|
+
]);
|
|
51914
|
+
const Kr160 = /* @__PURE__ */ Uint32Array.from([
|
|
51915
|
+
0x50a28be6, 0x5c4dd124, 0x6d703ef3, 0x7a6d76e9, 0x00000000,
|
|
51916
|
+
]);
|
|
52192
51917
|
// It's called f() in spec.
|
|
52193
|
-
function
|
|
51918
|
+
function ripemd_f(group, x, y, z) {
|
|
52194
51919
|
if (group === 0)
|
|
52195
51920
|
return x ^ y ^ z;
|
|
52196
|
-
|
|
51921
|
+
if (group === 1)
|
|
52197
51922
|
return (x & y) | (~x & z);
|
|
52198
|
-
|
|
51923
|
+
if (group === 2)
|
|
52199
51924
|
return (x | ~y) ^ z;
|
|
52200
|
-
|
|
51925
|
+
if (group === 3)
|
|
52201
51926
|
return (x & z) | (y & ~z);
|
|
52202
|
-
|
|
52203
|
-
return x ^ (y | ~z);
|
|
51927
|
+
return x ^ (y | ~z);
|
|
52204
51928
|
}
|
|
52205
|
-
//
|
|
52206
|
-
const
|
|
52207
|
-
class RIPEMD160 extends
|
|
51929
|
+
// Reusable temporary buffer
|
|
51930
|
+
const BUF_160 = /* @__PURE__ */ new Uint32Array(16);
|
|
51931
|
+
class RIPEMD160 extends HashMD {
|
|
52208
51932
|
constructor() {
|
|
52209
51933
|
super(64, 20, 8, true);
|
|
52210
51934
|
this.h0 = 0x67452301 | 0;
|
|
@@ -52226,43 +51950,58 @@ class RIPEMD160 extends _sha2_SHA2 {
|
|
|
52226
51950
|
}
|
|
52227
51951
|
process(view, offset) {
|
|
52228
51952
|
for (let i = 0; i < 16; i++, offset += 4)
|
|
52229
|
-
|
|
51953
|
+
BUF_160[i] = view.getUint32(offset, true);
|
|
52230
51954
|
// prettier-ignore
|
|
52231
51955
|
let al = this.h0 | 0, ar = al, bl = this.h1 | 0, br = bl, cl = this.h2 | 0, cr = cl, dl = this.h3 | 0, dr = dl, el = this.h4 | 0, er = el;
|
|
52232
51956
|
// Instead of iterating 0 to 80, we split it into 5 groups
|
|
52233
51957
|
// And use the groups in constants, functions, etc. Much simpler
|
|
52234
51958
|
for (let group = 0; group < 5; group++) {
|
|
52235
51959
|
const rGroup = 4 - group;
|
|
52236
|
-
const hbl =
|
|
51960
|
+
const hbl = Kl160[group], hbr = Kr160[group]; // prettier-ignore
|
|
52237
51961
|
const rl = idxL[group], rr = idxR[group]; // prettier-ignore
|
|
52238
|
-
const sl =
|
|
51962
|
+
const sl = shiftsL160[group], sr = shiftsR160[group]; // prettier-ignore
|
|
52239
51963
|
for (let i = 0; i < 16; i++) {
|
|
52240
|
-
const tl = (
|
|
52241
|
-
al = el, el = dl, dl =
|
|
51964
|
+
const tl = (rotl(al + ripemd_f(group, bl, cl, dl) + BUF_160[rl[i]] + hbl, sl[i]) + el) | 0;
|
|
51965
|
+
al = el, el = dl, dl = rotl(cl, 10) | 0, cl = bl, bl = tl; // prettier-ignore
|
|
52242
51966
|
}
|
|
52243
51967
|
// 2 loops are 10% faster
|
|
52244
51968
|
for (let i = 0; i < 16; i++) {
|
|
52245
|
-
const tr = (
|
|
52246
|
-
ar = er, er = dr, dr =
|
|
51969
|
+
const tr = (rotl(ar + ripemd_f(rGroup, br, cr, dr) + BUF_160[rr[i]] + hbr, sr[i]) + er) | 0;
|
|
51970
|
+
ar = er, er = dr, dr = rotl(cr, 10) | 0, cr = br, br = tr; // prettier-ignore
|
|
52247
51971
|
}
|
|
52248
51972
|
}
|
|
52249
51973
|
// Add the compressed chunk to the current hash value
|
|
52250
51974
|
this.set((this.h1 + cl + dr) | 0, (this.h2 + dl + er) | 0, (this.h3 + el + ar) | 0, (this.h4 + al + br) | 0, (this.h0 + bl + cr) | 0);
|
|
52251
51975
|
}
|
|
52252
51976
|
roundClean() {
|
|
52253
|
-
|
|
51977
|
+
clean(BUF_160);
|
|
52254
51978
|
}
|
|
52255
51979
|
destroy() {
|
|
52256
51980
|
this.destroyed = true;
|
|
52257
|
-
this.buffer
|
|
51981
|
+
clean(this.buffer);
|
|
52258
51982
|
this.set(0, 0, 0, 0, 0);
|
|
52259
51983
|
}
|
|
52260
51984
|
}
|
|
52261
51985
|
/**
|
|
52262
|
-
* RIPEMD-160 - a hash function from 1990s.
|
|
52263
|
-
*
|
|
51986
|
+
* RIPEMD-160 - a legacy hash function from 1990s.
|
|
51987
|
+
* * https://homes.esat.kuleuven.be/~bosselae/ripemd160.html
|
|
51988
|
+
* * https://homes.esat.kuleuven.be/~bosselae/ripemd160/pdf/AB-9601/AB-9601.pdf
|
|
51989
|
+
*/
|
|
51990
|
+
const ripemd160 = /* @__PURE__ */ createHasher(() => new RIPEMD160());
|
|
51991
|
+
//# sourceMappingURL=legacy.js.map
|
|
51992
|
+
;// ./node_modules/@noble/hashes/esm/ripemd160.js
|
|
51993
|
+
/**
|
|
51994
|
+
* RIPEMD-160 legacy hash function.
|
|
51995
|
+
* https://homes.esat.kuleuven.be/~bosselae/ripemd160.html
|
|
51996
|
+
* https://homes.esat.kuleuven.be/~bosselae/ripemd160/pdf/AB-9601/AB-9601.pdf
|
|
51997
|
+
* @module
|
|
51998
|
+
* @deprecated
|
|
52264
51999
|
*/
|
|
52265
|
-
|
|
52000
|
+
|
|
52001
|
+
/** @deprecated Use import from `noble/hashes/legacy` module */
|
|
52002
|
+
const ripemd160_RIPEMD160 = RIPEMD160;
|
|
52003
|
+
/** @deprecated Use import from `noble/hashes/legacy` module */
|
|
52004
|
+
const ripemd160_ripemd160 = ripemd160;
|
|
52266
52005
|
//# sourceMappingURL=ripemd160.js.map
|
|
52267
52006
|
;// ./src/gundb/derive.ts
|
|
52268
52007
|
|
|
@@ -52469,7 +52208,7 @@ function deriveP2PKHAddress(publicKey) {
|
|
|
52469
52208
|
// 1. SHA256 hash del public key
|
|
52470
52209
|
const sha256Hash = sha256_sha256(publicKey);
|
|
52471
52210
|
// 2. RIPEMD160 hash del risultato
|
|
52472
|
-
const ripemd160Hash =
|
|
52211
|
+
const ripemd160Hash = ripemd160_ripemd160(sha256Hash);
|
|
52473
52212
|
// 3. Aggiungi version byte (0x00 per mainnet P2PKH)
|
|
52474
52213
|
const versionedHash = new Uint8Array(21);
|
|
52475
52214
|
versionedHash[0] = 0x00; // Mainnet P2PKH version
|
|
@@ -57245,13 +56984,13 @@ function resolveAddress(target, resolver) {
|
|
|
57245
56984
|
const abstract_utils_0n = BigInt(0);
|
|
57246
56985
|
const abstract_utils_1n = BigInt(1);
|
|
57247
56986
|
const utils_2n = BigInt(2);
|
|
57248
|
-
const
|
|
56987
|
+
const utils_u8a = (a) => a instanceof Uint8Array;
|
|
57249
56988
|
const abstract_utils_hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));
|
|
57250
56989
|
/**
|
|
57251
56990
|
* @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'
|
|
57252
56991
|
*/
|
|
57253
56992
|
function abstract_utils_bytesToHex(bytes) {
|
|
57254
|
-
if (!
|
|
56993
|
+
if (!utils_u8a(bytes))
|
|
57255
56994
|
throw new Error('Uint8Array expected');
|
|
57256
56995
|
// pre-caching improves the speed 6x
|
|
57257
56996
|
let hex = '';
|
|
@@ -57295,7 +57034,7 @@ function utils_bytesToNumberBE(bytes) {
|
|
|
57295
57034
|
return utils_hexToNumber(abstract_utils_bytesToHex(bytes));
|
|
57296
57035
|
}
|
|
57297
57036
|
function utils_bytesToNumberLE(bytes) {
|
|
57298
|
-
if (!
|
|
57037
|
+
if (!utils_u8a(bytes))
|
|
57299
57038
|
throw new Error('Uint8Array expected');
|
|
57300
57039
|
return utils_hexToNumber(abstract_utils_bytesToHex(Uint8Array.from(bytes).reverse()));
|
|
57301
57040
|
}
|
|
@@ -57328,7 +57067,7 @@ function utils_ensureBytes(title, hex, expectedLength) {
|
|
|
57328
57067
|
throw new Error(`${title} must be valid hex string, got "${hex}". Cause: ${e}`);
|
|
57329
57068
|
}
|
|
57330
57069
|
}
|
|
57331
|
-
else if (
|
|
57070
|
+
else if (utils_u8a(hex)) {
|
|
57332
57071
|
// Uint8Array.from() instead of hash.slice() because node.js Buffer
|
|
57333
57072
|
// is instance of Uint8Array, and its slice() creates **mutable** copy
|
|
57334
57073
|
res = Uint8Array.from(hex);
|
|
@@ -57348,7 +57087,7 @@ function abstract_utils_concatBytes(...arrays) {
|
|
|
57348
57087
|
const r = new Uint8Array(arrays.reduce((sum, a) => sum + a.length, 0));
|
|
57349
57088
|
let pad = 0; // walk through each item, ensure they have proper type
|
|
57350
57089
|
arrays.forEach((a) => {
|
|
57351
|
-
if (!
|
|
57090
|
+
if (!utils_u8a(a))
|
|
57352
57091
|
throw new Error('Uint8Array expected');
|
|
57353
57092
|
r.set(a, pad);
|
|
57354
57093
|
pad += a.length;
|
|
@@ -72874,33 +72613,33 @@ Object.freeze(computeHmac);
|
|
|
72874
72613
|
|
|
72875
72614
|
// https://homes.esat.kuleuven.be/~bosselae/ripemd160.html
|
|
72876
72615
|
// https://homes.esat.kuleuven.be/~bosselae/ripemd160/pdf/AB-9601/AB-9601.pdf
|
|
72877
|
-
const
|
|
72878
|
-
const
|
|
72879
|
-
const
|
|
72880
|
-
let ripemd160_idxL = [
|
|
72881
|
-
let ripemd160_idxR = [
|
|
72616
|
+
const Rho = /* @__PURE__ */ new Uint8Array([7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8]);
|
|
72617
|
+
const Id = /* @__PURE__ */ Uint8Array.from({ length: 16 }, (_, i) => i);
|
|
72618
|
+
const Pi = /* @__PURE__ */ Id.map((i) => (9 * i + 5) % 16);
|
|
72619
|
+
let ripemd160_idxL = [Id];
|
|
72620
|
+
let ripemd160_idxR = [Pi];
|
|
72882
72621
|
for (let i = 0; i < 4; i++)
|
|
72883
72622
|
for (let j of [ripemd160_idxL, ripemd160_idxR])
|
|
72884
|
-
j.push(j[i].map((k) =>
|
|
72885
|
-
const
|
|
72623
|
+
j.push(j[i].map((k) => Rho[k]));
|
|
72624
|
+
const shifts = /* @__PURE__ */ [
|
|
72886
72625
|
[11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8],
|
|
72887
72626
|
[12, 13, 11, 15, 6, 9, 9, 7, 12, 15, 11, 13, 7, 8, 7, 7],
|
|
72888
72627
|
[13, 15, 14, 11, 7, 7, 6, 8, 13, 14, 13, 12, 5, 5, 6, 9],
|
|
72889
72628
|
[14, 11, 12, 14, 8, 6, 5, 5, 15, 12, 15, 14, 9, 9, 8, 6],
|
|
72890
72629
|
[15, 12, 13, 13, 9, 5, 8, 6, 14, 11, 12, 11, 8, 6, 5, 5],
|
|
72891
72630
|
].map((i) => new Uint8Array(i));
|
|
72892
|
-
const
|
|
72893
|
-
const
|
|
72894
|
-
const
|
|
72631
|
+
const shiftsL = /* @__PURE__ */ ripemd160_idxL.map((idx, i) => idx.map((j) => shifts[i][j]));
|
|
72632
|
+
const shiftsR = /* @__PURE__ */ ripemd160_idxR.map((idx, i) => idx.map((j) => shifts[i][j]));
|
|
72633
|
+
const Kl = /* @__PURE__ */ new Uint32Array([
|
|
72895
72634
|
0x00000000, 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xa953fd4e,
|
|
72896
72635
|
]);
|
|
72897
|
-
const
|
|
72636
|
+
const Kr = /* @__PURE__ */ new Uint32Array([
|
|
72898
72637
|
0x50a28be6, 0x5c4dd124, 0x6d703ef3, 0x7a6d76e9, 0x00000000,
|
|
72899
72638
|
]);
|
|
72900
72639
|
// The rotate left (circular left shift) operation for uint32
|
|
72901
|
-
const
|
|
72640
|
+
const ripemd160_rotl = (word, shift) => (word << shift) | (word >>> (32 - shift));
|
|
72902
72641
|
// It's called f() in spec.
|
|
72903
|
-
function
|
|
72642
|
+
function f(group, x, y, z) {
|
|
72904
72643
|
if (group === 0)
|
|
72905
72644
|
return x ^ y ^ z;
|
|
72906
72645
|
else if (group === 1)
|
|
@@ -72913,8 +72652,8 @@ function ripemd160_f(group, x, y, z) {
|
|
|
72913
72652
|
return x ^ (y | ~z);
|
|
72914
72653
|
}
|
|
72915
72654
|
// Temporary buffer, not used to store anything between runs
|
|
72916
|
-
const
|
|
72917
|
-
class
|
|
72655
|
+
const BUF = /* @__PURE__ */ new Uint32Array(16);
|
|
72656
|
+
class esm_ripemd160_RIPEMD160 extends SHA2 {
|
|
72918
72657
|
constructor() {
|
|
72919
72658
|
super(64, 20, 8, true);
|
|
72920
72659
|
this.h0 = 0x67452301 | 0;
|
|
@@ -72936,31 +72675,31 @@ class ripemd160_RIPEMD160 extends SHA2 {
|
|
|
72936
72675
|
}
|
|
72937
72676
|
process(view, offset) {
|
|
72938
72677
|
for (let i = 0; i < 16; i++, offset += 4)
|
|
72939
|
-
|
|
72678
|
+
BUF[i] = view.getUint32(offset, true);
|
|
72940
72679
|
// prettier-ignore
|
|
72941
72680
|
let al = this.h0 | 0, ar = al, bl = this.h1 | 0, br = bl, cl = this.h2 | 0, cr = cl, dl = this.h3 | 0, dr = dl, el = this.h4 | 0, er = el;
|
|
72942
72681
|
// Instead of iterating 0 to 80, we split it into 5 groups
|
|
72943
72682
|
// And use the groups in constants, functions, etc. Much simpler
|
|
72944
72683
|
for (let group = 0; group < 5; group++) {
|
|
72945
72684
|
const rGroup = 4 - group;
|
|
72946
|
-
const hbl =
|
|
72685
|
+
const hbl = Kl[group], hbr = Kr[group]; // prettier-ignore
|
|
72947
72686
|
const rl = ripemd160_idxL[group], rr = ripemd160_idxR[group]; // prettier-ignore
|
|
72948
|
-
const sl =
|
|
72687
|
+
const sl = shiftsL[group], sr = shiftsR[group]; // prettier-ignore
|
|
72949
72688
|
for (let i = 0; i < 16; i++) {
|
|
72950
|
-
const tl = (
|
|
72951
|
-
al = el, el = dl, dl =
|
|
72689
|
+
const tl = (ripemd160_rotl(al + f(group, bl, cl, dl) + BUF[rl[i]] + hbl, sl[i]) + el) | 0;
|
|
72690
|
+
al = el, el = dl, dl = ripemd160_rotl(cl, 10) | 0, cl = bl, bl = tl; // prettier-ignore
|
|
72952
72691
|
}
|
|
72953
72692
|
// 2 loops are 10% faster
|
|
72954
72693
|
for (let i = 0; i < 16; i++) {
|
|
72955
|
-
const tr = (
|
|
72956
|
-
ar = er, er = dr, dr =
|
|
72694
|
+
const tr = (ripemd160_rotl(ar + f(rGroup, br, cr, dr) + BUF[rr[i]] + hbr, sr[i]) + er) | 0;
|
|
72695
|
+
ar = er, er = dr, dr = ripemd160_rotl(cr, 10) | 0, cr = br, br = tr; // prettier-ignore
|
|
72957
72696
|
}
|
|
72958
72697
|
}
|
|
72959
72698
|
// Add the compressed chunk to the current hash value
|
|
72960
72699
|
this.set((this.h1 + cl + dr) | 0, (this.h2 + dl + er) | 0, (this.h3 + el + ar) | 0, (this.h4 + al + br) | 0, (this.h0 + bl + cr) | 0);
|
|
72961
72700
|
}
|
|
72962
72701
|
roundClean() {
|
|
72963
|
-
|
|
72702
|
+
BUF.fill(0);
|
|
72964
72703
|
}
|
|
72965
72704
|
destroy() {
|
|
72966
72705
|
this.destroyed = true;
|
|
@@ -72972,14 +72711,14 @@ class ripemd160_RIPEMD160 extends SHA2 {
|
|
|
72972
72711
|
* RIPEMD-160 - a hash function from 1990s.
|
|
72973
72712
|
* @param message - msg that would be hashed
|
|
72974
72713
|
*/
|
|
72975
|
-
const
|
|
72714
|
+
const esm_ripemd160_ripemd160 = /* @__PURE__ */ wrapConstructor(() => new esm_ripemd160_RIPEMD160());
|
|
72976
72715
|
//# sourceMappingURL=ripemd160.js.map
|
|
72977
72716
|
;// ./node_modules/ethers/lib.esm/crypto/ripemd160.js
|
|
72978
72717
|
|
|
72979
72718
|
|
|
72980
72719
|
let ripemd160_locked = false;
|
|
72981
72720
|
const _ripemd160 = function (data) {
|
|
72982
|
-
return
|
|
72721
|
+
return esm_ripemd160_ripemd160(data);
|
|
72983
72722
|
};
|
|
72984
72723
|
let __ripemd160 = _ripemd160;
|
|
72985
72724
|
/**
|
|
@@ -76793,15 +76532,15 @@ class Web3ConnectorPlugin extends BasePlugin {
|
|
|
76793
76532
|
}
|
|
76794
76533
|
|
|
76795
76534
|
;// ./node_modules/nostr-tools/node_modules/@noble/curves/node_modules/@noble/hashes/esm/_assert.js
|
|
76796
|
-
function
|
|
76535
|
+
function _assert_number(n) {
|
|
76797
76536
|
if (!Number.isSafeInteger(n) || n < 0)
|
|
76798
76537
|
throw new Error(`Wrong positive integer: ${n}`);
|
|
76799
76538
|
}
|
|
76800
|
-
function
|
|
76539
|
+
function _assert_bool(b) {
|
|
76801
76540
|
if (typeof b !== 'boolean')
|
|
76802
76541
|
throw new Error(`Expected boolean, not ${b}`);
|
|
76803
76542
|
}
|
|
76804
|
-
function
|
|
76543
|
+
function _assert_bytes(b, ...lengths) {
|
|
76805
76544
|
if (!(b instanceof Uint8Array))
|
|
76806
76545
|
throw new Error('Expected Uint8Array');
|
|
76807
76546
|
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
@@ -76810,28 +76549,28 @@ function esm_assert_bytes(b, ...lengths) {
|
|
|
76810
76549
|
function esm_assert_hash(hash) {
|
|
76811
76550
|
if (typeof hash !== 'function' || typeof hash.create !== 'function')
|
|
76812
76551
|
throw new Error('Hash should be wrapped by utils.wrapConstructor');
|
|
76813
|
-
|
|
76814
|
-
|
|
76552
|
+
_assert_number(hash.outputLen);
|
|
76553
|
+
_assert_number(hash.blockLen);
|
|
76815
76554
|
}
|
|
76816
|
-
function
|
|
76555
|
+
function _assert_exists(instance, checkFinished = true) {
|
|
76817
76556
|
if (instance.destroyed)
|
|
76818
76557
|
throw new Error('Hash instance has been destroyed');
|
|
76819
76558
|
if (checkFinished && instance.finished)
|
|
76820
76559
|
throw new Error('Hash#digest() has already been called');
|
|
76821
76560
|
}
|
|
76822
|
-
function
|
|
76823
|
-
|
|
76561
|
+
function _assert_output(out, instance) {
|
|
76562
|
+
_assert_bytes(out);
|
|
76824
76563
|
const min = instance.outputLen;
|
|
76825
76564
|
if (out.length < min) {
|
|
76826
76565
|
throw new Error(`digestInto() expects output buffer of length at least ${min}`);
|
|
76827
76566
|
}
|
|
76828
76567
|
}
|
|
76829
76568
|
|
|
76830
|
-
const
|
|
76831
|
-
/* harmony default export */ const
|
|
76569
|
+
const esm_assert_assert = { number: _assert_number, bool: _assert_bool, bytes: _assert_bytes, hash: esm_assert_hash, exists: _assert_exists, output: _assert_output };
|
|
76570
|
+
/* harmony default export */ const esm_assert = (esm_assert_assert);
|
|
76832
76571
|
//# sourceMappingURL=_assert.js.map
|
|
76833
76572
|
;// ./node_modules/nostr-tools/node_modules/@noble/curves/node_modules/@noble/hashes/esm/crypto.js
|
|
76834
|
-
const
|
|
76573
|
+
const hashes_esm_crypto_crypto = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined;
|
|
76835
76574
|
//# sourceMappingURL=crypto.js.map
|
|
76836
76575
|
;// ./node_modules/nostr-tools/node_modules/@noble/curves/node_modules/@noble/hashes/esm/utils.js
|
|
76837
76576
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
@@ -76844,35 +76583,35 @@ const _noble_hashes_esm_crypto_crypto = typeof globalThis === 'object' && 'crypt
|
|
|
76844
76583
|
|
|
76845
76584
|
const esm_utils_u8a = (a) => a instanceof Uint8Array;
|
|
76846
76585
|
// Cast array to different type
|
|
76847
|
-
const
|
|
76848
|
-
const
|
|
76586
|
+
const esm_utils_u8 = (arr) => new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
76587
|
+
const esm_utils_u32 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
76849
76588
|
// Cast array to view
|
|
76850
|
-
const
|
|
76589
|
+
const esm_utils_createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
76851
76590
|
// The rotate right (circular right shift) operation for uint32
|
|
76852
|
-
const
|
|
76591
|
+
const esm_utils_rotr = (word, shift) => (word << (32 - shift)) | (word >>> shift);
|
|
76853
76592
|
// big-endian hardware is rare. Just in case someone still decides to run hashes:
|
|
76854
76593
|
// early-throw an error because we don't support BE yet.
|
|
76855
|
-
const
|
|
76856
|
-
if (!
|
|
76594
|
+
const esm_utils_isLE = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;
|
|
76595
|
+
if (!esm_utils_isLE)
|
|
76857
76596
|
throw new Error('Non little-endian hardware is not supported');
|
|
76858
|
-
const
|
|
76597
|
+
const esm_utils_hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));
|
|
76859
76598
|
/**
|
|
76860
76599
|
* @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'
|
|
76861
76600
|
*/
|
|
76862
|
-
function
|
|
76601
|
+
function esm_utils_bytesToHex(bytes) {
|
|
76863
76602
|
if (!esm_utils_u8a(bytes))
|
|
76864
76603
|
throw new Error('Uint8Array expected');
|
|
76865
76604
|
// pre-caching improves the speed 6x
|
|
76866
76605
|
let hex = '';
|
|
76867
76606
|
for (let i = 0; i < bytes.length; i++) {
|
|
76868
|
-
hex +=
|
|
76607
|
+
hex += esm_utils_hexes[bytes[i]];
|
|
76869
76608
|
}
|
|
76870
76609
|
return hex;
|
|
76871
76610
|
}
|
|
76872
76611
|
/**
|
|
76873
76612
|
* @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])
|
|
76874
76613
|
*/
|
|
76875
|
-
function
|
|
76614
|
+
function esm_utils_hexToBytes(hex) {
|
|
76876
76615
|
if (typeof hex !== 'string')
|
|
76877
76616
|
throw new Error('hex string expected, got ' + typeof hex);
|
|
76878
76617
|
const len = hex.length;
|
|
@@ -76892,9 +76631,9 @@ function hashes_esm_utils_hexToBytes(hex) {
|
|
|
76892
76631
|
// There is no setImmediate in browser and setTimeout is slow.
|
|
76893
76632
|
// call of async fn will return Promise, which will be fullfiled only on
|
|
76894
76633
|
// next scheduler queue processing step and this is exactly what we need.
|
|
76895
|
-
const
|
|
76634
|
+
const esm_utils_nextTick = async () => { };
|
|
76896
76635
|
// Returns control to thread each 'tick' ms to avoid blocking
|
|
76897
|
-
async function
|
|
76636
|
+
async function esm_utils_asyncLoop(iters, tick, cb) {
|
|
76898
76637
|
let ts = Date.now();
|
|
76899
76638
|
for (let i = 0; i < iters; i++) {
|
|
76900
76639
|
cb(i);
|
|
@@ -76902,14 +76641,14 @@ async function hashes_esm_utils_asyncLoop(iters, tick, cb) {
|
|
|
76902
76641
|
const diff = Date.now() - ts;
|
|
76903
76642
|
if (diff >= 0 && diff < tick)
|
|
76904
76643
|
continue;
|
|
76905
|
-
await
|
|
76644
|
+
await esm_utils_nextTick();
|
|
76906
76645
|
ts += diff;
|
|
76907
76646
|
}
|
|
76908
76647
|
}
|
|
76909
76648
|
/**
|
|
76910
76649
|
* @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
|
|
76911
76650
|
*/
|
|
76912
|
-
function
|
|
76651
|
+
function esm_utils_utf8ToBytes(str) {
|
|
76913
76652
|
if (typeof str !== 'string')
|
|
76914
76653
|
throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
|
|
76915
76654
|
return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
|
|
@@ -76919,9 +76658,9 @@ function hashes_esm_utils_utf8ToBytes(str) {
|
|
|
76919
76658
|
* Warning: when Uint8Array is passed, it would NOT get copied.
|
|
76920
76659
|
* Keep in mind for future mutable operations.
|
|
76921
76660
|
*/
|
|
76922
|
-
function
|
|
76661
|
+
function esm_utils_toBytes(data) {
|
|
76923
76662
|
if (typeof data === 'string')
|
|
76924
|
-
data =
|
|
76663
|
+
data = esm_utils_utf8ToBytes(data);
|
|
76925
76664
|
if (!esm_utils_u8a(data))
|
|
76926
76665
|
throw new Error(`expected Uint8Array, got ${typeof data}`);
|
|
76927
76666
|
return data;
|
|
@@ -76929,7 +76668,7 @@ function hashes_esm_utils_toBytes(data) {
|
|
|
76929
76668
|
/**
|
|
76930
76669
|
* Copies several Uint8Arrays into one.
|
|
76931
76670
|
*/
|
|
76932
|
-
function
|
|
76671
|
+
function esm_utils_concatBytes(...arrays) {
|
|
76933
76672
|
const r = new Uint8Array(arrays.reduce((sum, a) => sum + a.length, 0));
|
|
76934
76673
|
let pad = 0; // walk through each item, ensure they have proper type
|
|
76935
76674
|
arrays.forEach((a) => {
|
|
@@ -76941,37 +76680,37 @@ function hashes_esm_utils_concatBytes(...arrays) {
|
|
|
76941
76680
|
return r;
|
|
76942
76681
|
}
|
|
76943
76682
|
// For runtime check if class implements interface
|
|
76944
|
-
class
|
|
76683
|
+
class esm_utils_Hash {
|
|
76945
76684
|
// Safe version that clones internal state
|
|
76946
76685
|
clone() {
|
|
76947
76686
|
return this._cloneInto();
|
|
76948
76687
|
}
|
|
76949
76688
|
}
|
|
76950
76689
|
const utils_toStr = {}.toString;
|
|
76951
|
-
function
|
|
76690
|
+
function esm_utils_checkOpts(defaults, opts) {
|
|
76952
76691
|
if (opts !== undefined && utils_toStr.call(opts) !== '[object Object]')
|
|
76953
76692
|
throw new Error('Options should be object or undefined');
|
|
76954
76693
|
const merged = Object.assign(defaults, opts);
|
|
76955
76694
|
return merged;
|
|
76956
76695
|
}
|
|
76957
|
-
function
|
|
76958
|
-
const hashC = (msg) => hashCons().update(
|
|
76696
|
+
function esm_utils_wrapConstructor(hashCons) {
|
|
76697
|
+
const hashC = (msg) => hashCons().update(esm_utils_toBytes(msg)).digest();
|
|
76959
76698
|
const tmp = hashCons();
|
|
76960
76699
|
hashC.outputLen = tmp.outputLen;
|
|
76961
76700
|
hashC.blockLen = tmp.blockLen;
|
|
76962
76701
|
hashC.create = () => hashCons();
|
|
76963
76702
|
return hashC;
|
|
76964
76703
|
}
|
|
76965
|
-
function
|
|
76966
|
-
const hashC = (msg, opts) => hashCons(opts).update(
|
|
76704
|
+
function esm_utils_wrapConstructorWithOpts(hashCons) {
|
|
76705
|
+
const hashC = (msg, opts) => hashCons(opts).update(esm_utils_toBytes(msg)).digest();
|
|
76967
76706
|
const tmp = hashCons({});
|
|
76968
76707
|
hashC.outputLen = tmp.outputLen;
|
|
76969
76708
|
hashC.blockLen = tmp.blockLen;
|
|
76970
76709
|
hashC.create = (opts) => hashCons(opts);
|
|
76971
76710
|
return hashC;
|
|
76972
76711
|
}
|
|
76973
|
-
function
|
|
76974
|
-
const hashC = (msg, opts) => hashCons(opts).update(
|
|
76712
|
+
function esm_utils_wrapXOFConstructorWithOpts(hashCons) {
|
|
76713
|
+
const hashC = (msg, opts) => hashCons(opts).update(esm_utils_toBytes(msg)).digest();
|
|
76975
76714
|
const tmp = hashCons({});
|
|
76976
76715
|
hashC.outputLen = tmp.outputLen;
|
|
76977
76716
|
hashC.blockLen = tmp.blockLen;
|
|
@@ -76981,9 +76720,9 @@ function hashes_esm_utils_wrapXOFConstructorWithOpts(hashCons) {
|
|
|
76981
76720
|
/**
|
|
76982
76721
|
* Secure PRNG. Uses `crypto.getRandomValues`, which defers to OS.
|
|
76983
76722
|
*/
|
|
76984
|
-
function
|
|
76985
|
-
if (
|
|
76986
|
-
return
|
|
76723
|
+
function esm_utils_randomBytes(bytesLength = 32) {
|
|
76724
|
+
if (hashes_esm_crypto_crypto && typeof hashes_esm_crypto_crypto.getRandomValues === 'function') {
|
|
76725
|
+
return hashes_esm_crypto_crypto.getRandomValues(new Uint8Array(bytesLength));
|
|
76987
76726
|
}
|
|
76988
76727
|
throw new Error('crypto.getRandomValues must be defined');
|
|
76989
76728
|
}
|
|
@@ -76992,7 +76731,7 @@ function hashes_esm_utils_randomBytes(bytesLength = 32) {
|
|
|
76992
76731
|
|
|
76993
76732
|
|
|
76994
76733
|
// Polyfill for Safari 14
|
|
76995
|
-
function
|
|
76734
|
+
function _sha2_setBigUint64(view, byteOffset, value, isLE) {
|
|
76996
76735
|
if (typeof view.setBigUint64 === 'function')
|
|
76997
76736
|
return view.setBigUint64(byteOffset, value, isLE);
|
|
76998
76737
|
const _32n = BigInt(32);
|
|
@@ -77005,7 +76744,7 @@ function esm_sha2_setBigUint64(view, byteOffset, value, isLE) {
|
|
|
77005
76744
|
view.setUint32(byteOffset + l, wl, isLE);
|
|
77006
76745
|
}
|
|
77007
76746
|
// Base SHA2 class (RFC 6234)
|
|
77008
|
-
class
|
|
76747
|
+
class _sha2_SHA2 extends esm_utils_Hash {
|
|
77009
76748
|
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
77010
76749
|
super();
|
|
77011
76750
|
this.blockLen = blockLen;
|
|
@@ -77017,18 +76756,18 @@ class esm_sha2_SHA2 extends hashes_esm_utils_Hash {
|
|
|
77017
76756
|
this.pos = 0;
|
|
77018
76757
|
this.destroyed = false;
|
|
77019
76758
|
this.buffer = new Uint8Array(blockLen);
|
|
77020
|
-
this.view =
|
|
76759
|
+
this.view = esm_utils_createView(this.buffer);
|
|
77021
76760
|
}
|
|
77022
76761
|
update(data) {
|
|
77023
|
-
|
|
76762
|
+
_assert_exists(this);
|
|
77024
76763
|
const { view, buffer, blockLen } = this;
|
|
77025
|
-
data =
|
|
76764
|
+
data = esm_utils_toBytes(data);
|
|
77026
76765
|
const len = data.length;
|
|
77027
76766
|
for (let pos = 0; pos < len;) {
|
|
77028
76767
|
const take = Math.min(blockLen - this.pos, len - pos);
|
|
77029
76768
|
// Fast path: we have at least one block in input, cast it to view and process
|
|
77030
76769
|
if (take === blockLen) {
|
|
77031
|
-
const dataView =
|
|
76770
|
+
const dataView = esm_utils_createView(data);
|
|
77032
76771
|
for (; blockLen <= len - pos; pos += blockLen)
|
|
77033
76772
|
this.process(dataView, pos);
|
|
77034
76773
|
continue;
|
|
@@ -77046,8 +76785,8 @@ class esm_sha2_SHA2 extends hashes_esm_utils_Hash {
|
|
|
77046
76785
|
return this;
|
|
77047
76786
|
}
|
|
77048
76787
|
digestInto(out) {
|
|
77049
|
-
|
|
77050
|
-
|
|
76788
|
+
_assert_exists(this);
|
|
76789
|
+
_assert_output(out, this);
|
|
77051
76790
|
this.finished = true;
|
|
77052
76791
|
// Padding
|
|
77053
76792
|
// We can avoid allocation of buffer for padding completely if it
|
|
@@ -77068,9 +76807,9 @@ class esm_sha2_SHA2 extends hashes_esm_utils_Hash {
|
|
|
77068
76807
|
// Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that
|
|
77069
76808
|
// You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.
|
|
77070
76809
|
// So we just write lowest 64 bits of that value.
|
|
77071
|
-
|
|
76810
|
+
_sha2_setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
|
|
77072
76811
|
this.process(view, 0);
|
|
77073
|
-
const oview =
|
|
76812
|
+
const oview = esm_utils_createView(out);
|
|
77074
76813
|
const len = this.outputLen;
|
|
77075
76814
|
// NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT
|
|
77076
76815
|
if (len % 4)
|
|
@@ -77109,13 +76848,13 @@ class esm_sha2_SHA2 extends hashes_esm_utils_Hash {
|
|
|
77109
76848
|
// SHA2-256 need to try 2^128 hashes to execute birthday attack.
|
|
77110
76849
|
// BTC network is doing 2^67 hashes/sec as per early 2023.
|
|
77111
76850
|
// Choice: a ? b : c
|
|
77112
|
-
const
|
|
76851
|
+
const sha256_Chi = (a, b, c) => (a & b) ^ (~a & c);
|
|
77113
76852
|
// Majority function, true if any two inpust is true
|
|
77114
|
-
const
|
|
76853
|
+
const sha256_Maj = (a, b, c) => (a & b) ^ (a & c) ^ (b & c);
|
|
77115
76854
|
// Round constants:
|
|
77116
76855
|
// first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311)
|
|
77117
76856
|
// prettier-ignore
|
|
77118
|
-
const
|
|
76857
|
+
const sha256_SHA256_K = /* @__PURE__ */ new Uint32Array([
|
|
77119
76858
|
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
77120
76859
|
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
77121
76860
|
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
@@ -77127,25 +76866,25 @@ const esm_sha256_SHA256_K = /* @__PURE__ */ new Uint32Array([
|
|
|
77127
76866
|
]);
|
|
77128
76867
|
// Initial state (first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19):
|
|
77129
76868
|
// prettier-ignore
|
|
77130
|
-
const
|
|
76869
|
+
const sha256_IV = /* @__PURE__ */ new Uint32Array([
|
|
77131
76870
|
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
|
|
77132
76871
|
]);
|
|
77133
76872
|
// Temporary buffer, not used to store anything between runs
|
|
77134
76873
|
// Named this way because it matches specification.
|
|
77135
|
-
const
|
|
77136
|
-
class esm_sha256_SHA256 extends
|
|
76874
|
+
const sha256_SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
76875
|
+
class esm_sha256_SHA256 extends _sha2_SHA2 {
|
|
77137
76876
|
constructor() {
|
|
77138
76877
|
super(64, 32, 8, false);
|
|
77139
76878
|
// We cannot use array here since array allows indexing by variable
|
|
77140
76879
|
// which means optimizer/compiler cannot use registers.
|
|
77141
|
-
this.A =
|
|
77142
|
-
this.B =
|
|
77143
|
-
this.C =
|
|
77144
|
-
this.D =
|
|
77145
|
-
this.E =
|
|
77146
|
-
this.F =
|
|
77147
|
-
this.G =
|
|
77148
|
-
this.H =
|
|
76880
|
+
this.A = sha256_IV[0] | 0;
|
|
76881
|
+
this.B = sha256_IV[1] | 0;
|
|
76882
|
+
this.C = sha256_IV[2] | 0;
|
|
76883
|
+
this.D = sha256_IV[3] | 0;
|
|
76884
|
+
this.E = sha256_IV[4] | 0;
|
|
76885
|
+
this.F = sha256_IV[5] | 0;
|
|
76886
|
+
this.G = sha256_IV[6] | 0;
|
|
76887
|
+
this.H = sha256_IV[7] | 0;
|
|
77149
76888
|
}
|
|
77150
76889
|
get() {
|
|
77151
76890
|
const { A, B, C, D, E, F, G, H } = this;
|
|
@@ -77165,21 +76904,21 @@ class esm_sha256_SHA256 extends esm_sha2_SHA2 {
|
|
|
77165
76904
|
process(view, offset) {
|
|
77166
76905
|
// Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array
|
|
77167
76906
|
for (let i = 0; i < 16; i++, offset += 4)
|
|
77168
|
-
|
|
76907
|
+
sha256_SHA256_W[i] = view.getUint32(offset, false);
|
|
77169
76908
|
for (let i = 16; i < 64; i++) {
|
|
77170
|
-
const W15 =
|
|
77171
|
-
const W2 =
|
|
77172
|
-
const s0 =
|
|
77173
|
-
const s1 =
|
|
77174
|
-
|
|
76909
|
+
const W15 = sha256_SHA256_W[i - 15];
|
|
76910
|
+
const W2 = sha256_SHA256_W[i - 2];
|
|
76911
|
+
const s0 = esm_utils_rotr(W15, 7) ^ esm_utils_rotr(W15, 18) ^ (W15 >>> 3);
|
|
76912
|
+
const s1 = esm_utils_rotr(W2, 17) ^ esm_utils_rotr(W2, 19) ^ (W2 >>> 10);
|
|
76913
|
+
sha256_SHA256_W[i] = (s1 + sha256_SHA256_W[i - 7] + s0 + sha256_SHA256_W[i - 16]) | 0;
|
|
77175
76914
|
}
|
|
77176
76915
|
// Compression function main loop, 64 rounds
|
|
77177
76916
|
let { A, B, C, D, E, F, G, H } = this;
|
|
77178
76917
|
for (let i = 0; i < 64; i++) {
|
|
77179
|
-
const sigma1 =
|
|
77180
|
-
const T1 = (H + sigma1 +
|
|
77181
|
-
const sigma0 =
|
|
77182
|
-
const T2 = (sigma0 +
|
|
76918
|
+
const sigma1 = esm_utils_rotr(E, 6) ^ esm_utils_rotr(E, 11) ^ esm_utils_rotr(E, 25);
|
|
76919
|
+
const T1 = (H + sigma1 + sha256_Chi(E, F, G) + sha256_SHA256_K[i] + sha256_SHA256_W[i]) | 0;
|
|
76920
|
+
const sigma0 = esm_utils_rotr(A, 2) ^ esm_utils_rotr(A, 13) ^ esm_utils_rotr(A, 22);
|
|
76921
|
+
const T2 = (sigma0 + sha256_Maj(A, B, C)) | 0;
|
|
77183
76922
|
H = G;
|
|
77184
76923
|
G = F;
|
|
77185
76924
|
F = E;
|
|
@@ -77201,7 +76940,7 @@ class esm_sha256_SHA256 extends esm_sha2_SHA2 {
|
|
|
77201
76940
|
this.set(A, B, C, D, E, F, G, H);
|
|
77202
76941
|
}
|
|
77203
76942
|
roundClean() {
|
|
77204
|
-
|
|
76943
|
+
sha256_SHA256_W.fill(0);
|
|
77205
76944
|
}
|
|
77206
76945
|
destroy() {
|
|
77207
76946
|
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
@@ -77227,8 +76966,8 @@ class esm_sha256_SHA224 extends esm_sha256_SHA256 {
|
|
|
77227
76966
|
* SHA2-256 hash function
|
|
77228
76967
|
* @param message - data that would be hashed
|
|
77229
76968
|
*/
|
|
77230
|
-
const esm_sha256_sha256 = /* @__PURE__ */
|
|
77231
|
-
const esm_sha256_sha224 = /* @__PURE__ */
|
|
76969
|
+
const esm_sha256_sha256 = /* @__PURE__ */ esm_utils_wrapConstructor(() => new esm_sha256_SHA256());
|
|
76970
|
+
const esm_sha256_sha224 = /* @__PURE__ */ esm_utils_wrapConstructor(() => new esm_sha256_SHA224());
|
|
77232
76971
|
//# sourceMappingURL=sha256.js.map
|
|
77233
76972
|
;// ./node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/utils.js
|
|
77234
76973
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
@@ -77239,13 +76978,13 @@ const esm_sha256_sha224 = /* @__PURE__ */ hashes_esm_utils_wrapConstructor(() =>
|
|
|
77239
76978
|
const esm_abstract_utils_0n = BigInt(0);
|
|
77240
76979
|
const esm_abstract_utils_1n = BigInt(1);
|
|
77241
76980
|
const abstract_utils_2n = BigInt(2);
|
|
77242
|
-
const
|
|
76981
|
+
const abstract_utils_u8a = (a) => a instanceof Uint8Array;
|
|
77243
76982
|
const esm_abstract_utils_hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));
|
|
77244
76983
|
/**
|
|
77245
76984
|
* @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'
|
|
77246
76985
|
*/
|
|
77247
76986
|
function esm_abstract_utils_bytesToHex(bytes) {
|
|
77248
|
-
if (!
|
|
76987
|
+
if (!abstract_utils_u8a(bytes))
|
|
77249
76988
|
throw new Error('Uint8Array expected');
|
|
77250
76989
|
// pre-caching improves the speed 6x
|
|
77251
76990
|
let hex = '';
|
|
@@ -77289,7 +77028,7 @@ function abstract_utils_bytesToNumberBE(bytes) {
|
|
|
77289
77028
|
return abstract_utils_hexToNumber(esm_abstract_utils_bytesToHex(bytes));
|
|
77290
77029
|
}
|
|
77291
77030
|
function abstract_utils_bytesToNumberLE(bytes) {
|
|
77292
|
-
if (!
|
|
77031
|
+
if (!abstract_utils_u8a(bytes))
|
|
77293
77032
|
throw new Error('Uint8Array expected');
|
|
77294
77033
|
return abstract_utils_hexToNumber(esm_abstract_utils_bytesToHex(Uint8Array.from(bytes).reverse()));
|
|
77295
77034
|
}
|
|
@@ -77322,7 +77061,7 @@ function abstract_utils_ensureBytes(title, hex, expectedLength) {
|
|
|
77322
77061
|
throw new Error(`${title} must be valid hex string, got "${hex}". Cause: ${e}`);
|
|
77323
77062
|
}
|
|
77324
77063
|
}
|
|
77325
|
-
else if (
|
|
77064
|
+
else if (abstract_utils_u8a(hex)) {
|
|
77326
77065
|
// Uint8Array.from() instead of hash.slice() because node.js Buffer
|
|
77327
77066
|
// is instance of Uint8Array, and its slice() creates **mutable** copy
|
|
77328
77067
|
res = Uint8Array.from(hex);
|
|
@@ -77342,7 +77081,7 @@ function esm_abstract_utils_concatBytes(...arrays) {
|
|
|
77342
77081
|
const r = new Uint8Array(arrays.reduce((sum, a) => sum + a.length, 0));
|
|
77343
77082
|
let pad = 0; // walk through each item, ensure they have proper type
|
|
77344
77083
|
arrays.forEach((a) => {
|
|
77345
|
-
if (!
|
|
77084
|
+
if (!abstract_utils_u8a(a))
|
|
77346
77085
|
throw new Error('Uint8Array expected');
|
|
77347
77086
|
r.set(a, pad);
|
|
77348
77087
|
pad += a.length;
|
|
@@ -79306,13 +79045,13 @@ function esm_abstract_hash_to_curve_createHasher(Point, mapToCurve, def) {
|
|
|
79306
79045
|
|
|
79307
79046
|
|
|
79308
79047
|
// HMAC (RFC 2104)
|
|
79309
|
-
class esm_hmac_HMAC extends
|
|
79048
|
+
class esm_hmac_HMAC extends esm_utils_Hash {
|
|
79310
79049
|
constructor(hash, _key) {
|
|
79311
79050
|
super();
|
|
79312
79051
|
this.finished = false;
|
|
79313
79052
|
this.destroyed = false;
|
|
79314
79053
|
esm_assert_hash(hash);
|
|
79315
|
-
const key =
|
|
79054
|
+
const key = esm_utils_toBytes(_key);
|
|
79316
79055
|
this.iHash = hash.create();
|
|
79317
79056
|
if (typeof this.iHash.update !== 'function')
|
|
79318
79057
|
throw new Error('Expected instance of class which extends utils.Hash');
|
|
@@ -79334,13 +79073,13 @@ class esm_hmac_HMAC extends hashes_esm_utils_Hash {
|
|
|
79334
79073
|
pad.fill(0);
|
|
79335
79074
|
}
|
|
79336
79075
|
update(buf) {
|
|
79337
|
-
|
|
79076
|
+
_assert_exists(this);
|
|
79338
79077
|
this.iHash.update(buf);
|
|
79339
79078
|
return this;
|
|
79340
79079
|
}
|
|
79341
79080
|
digestInto(out) {
|
|
79342
|
-
|
|
79343
|
-
|
|
79081
|
+
_assert_exists(this);
|
|
79082
|
+
_assert_bytes(out, this.outputLen);
|
|
79344
79083
|
this.finished = true;
|
|
79345
79084
|
this.iHash.digestInto(out);
|
|
79346
79085
|
this.oHash.update(out);
|
|
@@ -79389,8 +79128,8 @@ esm_hmac_hmac.create = (hash, key) => new esm_hmac_HMAC(hash, key);
|
|
|
79389
79128
|
function esm_shortw_utils_getHash(hash) {
|
|
79390
79129
|
return {
|
|
79391
79130
|
hash,
|
|
79392
|
-
hmac: (key, ...msgs) => esm_hmac_hmac(hash, key,
|
|
79393
|
-
randomBytes:
|
|
79131
|
+
hmac: (key, ...msgs) => esm_hmac_hmac(hash, key, esm_utils_concatBytes(...msgs)),
|
|
79132
|
+
randomBytes: esm_utils_randomBytes,
|
|
79394
79133
|
};
|
|
79395
79134
|
}
|
|
79396
79135
|
function esm_shortw_utils_createCurve(curveDef, defHash) {
|
|
@@ -79545,7 +79284,7 @@ function esm_secp256k1_schnorrGetPublicKey(privateKey) {
|
|
|
79545
79284
|
* Creates Schnorr signature as per BIP340. Verifies itself before returning anything.
|
|
79546
79285
|
* auxRand is optional and is not the sole source of k generation: bad CSPRNG won't be dangerous.
|
|
79547
79286
|
*/
|
|
79548
|
-
function esm_secp256k1_schnorrSign(message, privateKey, auxRand =
|
|
79287
|
+
function esm_secp256k1_schnorrSign(message, privateKey, auxRand = esm_utils_randomBytes(32)) {
|
|
79549
79288
|
const m = abstract_utils_ensureBytes('message', message);
|
|
79550
79289
|
const { bytes: px, scalar: d } = esm_secp256k1_schnorrGetExtPubKey(privateKey); // checks for isWithinCurveOrder
|
|
79551
79290
|
const a = abstract_utils_ensureBytes('auxRand', auxRand, 32); // Auxiliary random data a: a 32-byte array
|
|
@@ -80050,11 +79789,11 @@ const stringToBytes = (type, str) => {
|
|
|
80050
79789
|
const esm_bytes = stringToBytes;
|
|
80051
79790
|
|
|
80052
79791
|
;// ./node_modules/@noble/ciphers/esm/_assert.js
|
|
80053
|
-
function
|
|
79792
|
+
function esm_assert_number(n) {
|
|
80054
79793
|
if (!Number.isSafeInteger(n) || n < 0)
|
|
80055
79794
|
throw new Error(`positive integer expected, not ${n}`);
|
|
80056
79795
|
}
|
|
80057
|
-
function
|
|
79796
|
+
function esm_assert_bool(b) {
|
|
80058
79797
|
if (typeof b !== 'boolean')
|
|
80059
79798
|
throw new Error(`boolean expected, not ${b}`);
|
|
80060
79799
|
}
|
|
@@ -80062,33 +79801,33 @@ function _assert_isBytes(a) {
|
|
|
80062
79801
|
return (a instanceof Uint8Array ||
|
|
80063
79802
|
(a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array'));
|
|
80064
79803
|
}
|
|
80065
|
-
function
|
|
79804
|
+
function esm_assert_bytes(b, ...lengths) {
|
|
80066
79805
|
if (!_assert_isBytes(b))
|
|
80067
79806
|
throw new Error('Uint8Array expected');
|
|
80068
79807
|
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
80069
79808
|
throw new Error(`Uint8Array expected of length ${lengths}, not of length=${b.length}`);
|
|
80070
79809
|
}
|
|
80071
|
-
function
|
|
79810
|
+
function hash(hash) {
|
|
80072
79811
|
if (typeof hash !== 'function' || typeof hash.create !== 'function')
|
|
80073
79812
|
throw new Error('hash must be wrapped by utils.wrapConstructor');
|
|
80074
|
-
|
|
80075
|
-
|
|
79813
|
+
esm_assert_number(hash.outputLen);
|
|
79814
|
+
esm_assert_number(hash.blockLen);
|
|
80076
79815
|
}
|
|
80077
|
-
function
|
|
79816
|
+
function esm_assert_exists(instance, checkFinished = true) {
|
|
80078
79817
|
if (instance.destroyed)
|
|
80079
79818
|
throw new Error('Hash instance has been destroyed');
|
|
80080
79819
|
if (checkFinished && instance.finished)
|
|
80081
79820
|
throw new Error('Hash#digest() has already been called');
|
|
80082
79821
|
}
|
|
80083
|
-
function
|
|
80084
|
-
|
|
79822
|
+
function esm_assert_output(out, instance) {
|
|
79823
|
+
esm_assert_bytes(out);
|
|
80085
79824
|
const min = instance.outputLen;
|
|
80086
79825
|
if (out.length < min) {
|
|
80087
79826
|
throw new Error(`digestInto() expects output buffer of length at least ${min}`);
|
|
80088
79827
|
}
|
|
80089
79828
|
}
|
|
80090
79829
|
|
|
80091
|
-
const ciphers_esm_assert_assert = { number:
|
|
79830
|
+
const ciphers_esm_assert_assert = { number: esm_assert_number, bool: esm_assert_bool, bytes: esm_assert_bytes, hash, exists: esm_assert_exists, output: esm_assert_output };
|
|
80092
79831
|
/* harmony default export */ const ciphers_esm_assert = (ciphers_esm_assert_assert);
|
|
80093
79832
|
//# sourceMappingURL=_assert.js.map
|
|
80094
79833
|
;// ./node_modules/@noble/ciphers/esm/utils.js
|
|
@@ -80111,7 +79850,7 @@ const ciphers_esm_utils_hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_,
|
|
|
80111
79850
|
* @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'
|
|
80112
79851
|
*/
|
|
80113
79852
|
function ciphers_esm_utils_bytesToHex(bytes) {
|
|
80114
|
-
|
|
79853
|
+
esm_assert_bytes(bytes);
|
|
80115
79854
|
// pre-caching improves the speed 6x
|
|
80116
79855
|
let hex = '';
|
|
80117
79856
|
for (let i = 0; i < bytes.length; i++) {
|
|
@@ -80217,7 +79956,7 @@ function ciphers_esm_utils_concatBytes(...arrays) {
|
|
|
80217
79956
|
let sum = 0;
|
|
80218
79957
|
for (let i = 0; i < arrays.length; i++) {
|
|
80219
79958
|
const a = arrays[i];
|
|
80220
|
-
|
|
79959
|
+
esm_assert_bytes(a);
|
|
80221
79960
|
sum += a.length;
|
|
80222
79961
|
}
|
|
80223
79962
|
const res = new Uint8Array(sum);
|
|
@@ -80341,7 +80080,7 @@ class GHASH {
|
|
|
80341
80080
|
this.s3 = 0;
|
|
80342
80081
|
this.finished = false;
|
|
80343
80082
|
key = ciphers_esm_utils_toBytes(key);
|
|
80344
|
-
|
|
80083
|
+
esm_assert_bytes(key, 16);
|
|
80345
80084
|
const kView = ciphers_esm_utils_createView(key);
|
|
80346
80085
|
let k0 = kView.getUint32(0, false);
|
|
80347
80086
|
let k1 = kView.getUint32(4, false);
|
|
@@ -80404,7 +80143,7 @@ class GHASH {
|
|
|
80404
80143
|
}
|
|
80405
80144
|
update(data) {
|
|
80406
80145
|
data = ciphers_esm_utils_toBytes(data);
|
|
80407
|
-
|
|
80146
|
+
esm_assert_exists(this);
|
|
80408
80147
|
const b32 = ciphers_esm_utils_u32(data);
|
|
80409
80148
|
const blocks = Math.floor(data.length / BLOCK_SIZE);
|
|
80410
80149
|
const left = data.length % BLOCK_SIZE;
|
|
@@ -80426,8 +80165,8 @@ class GHASH {
|
|
|
80426
80165
|
}
|
|
80427
80166
|
}
|
|
80428
80167
|
digestInto(out) {
|
|
80429
|
-
|
|
80430
|
-
|
|
80168
|
+
esm_assert_exists(this);
|
|
80169
|
+
esm_assert_output(out, this);
|
|
80431
80170
|
this.finished = true;
|
|
80432
80171
|
const { s0, s1, s2, s3 } = this;
|
|
80433
80172
|
const o32 = ciphers_esm_utils_u32(out);
|
|
@@ -80453,7 +80192,7 @@ class Polyval extends GHASH {
|
|
|
80453
80192
|
}
|
|
80454
80193
|
update(data) {
|
|
80455
80194
|
data = ciphers_esm_utils_toBytes(data);
|
|
80456
|
-
|
|
80195
|
+
esm_assert_exists(this);
|
|
80457
80196
|
const b32 = ciphers_esm_utils_u32(data);
|
|
80458
80197
|
const left = data.length % BLOCK_SIZE;
|
|
80459
80198
|
const blocks = Math.floor(data.length / BLOCK_SIZE);
|
|
@@ -80468,8 +80207,8 @@ class Polyval extends GHASH {
|
|
|
80468
80207
|
return this;
|
|
80469
80208
|
}
|
|
80470
80209
|
digestInto(out) {
|
|
80471
|
-
|
|
80472
|
-
|
|
80210
|
+
esm_assert_exists(this);
|
|
80211
|
+
esm_assert_output(out, this);
|
|
80473
80212
|
this.finished = true;
|
|
80474
80213
|
// tmp ugly hack
|
|
80475
80214
|
const { s0, s1, s2, s3 } = this;
|
|
@@ -80580,7 +80319,7 @@ const xPowers = /* @__PURE__ */ (() => {
|
|
|
80580
80319
|
return p;
|
|
80581
80320
|
})();
|
|
80582
80321
|
function expandKeyLE(key) {
|
|
80583
|
-
|
|
80322
|
+
esm_assert_bytes(key);
|
|
80584
80323
|
const len = key.length;
|
|
80585
80324
|
if (![16, 24, 32].includes(len))
|
|
80586
80325
|
throw new Error(`aes: wrong key size: should be 16, 24 or 32, got: ${len}`);
|
|
@@ -80671,15 +80410,15 @@ function aes_decrypt(xk, s0, s1, s2, s3) {
|
|
|
80671
80410
|
function getDst(len, dst) {
|
|
80672
80411
|
if (!dst)
|
|
80673
80412
|
return new Uint8Array(len);
|
|
80674
|
-
|
|
80413
|
+
esm_assert_bytes(dst);
|
|
80675
80414
|
if (dst.length < len)
|
|
80676
80415
|
throw new Error(`aes: wrong destination length, expected at least ${len}, got: ${dst.length}`);
|
|
80677
80416
|
return dst;
|
|
80678
80417
|
}
|
|
80679
80418
|
// TODO: investigate merging with ctr32
|
|
80680
80419
|
function ctrCounter(xk, nonce, src, dst) {
|
|
80681
|
-
|
|
80682
|
-
|
|
80420
|
+
esm_assert_bytes(nonce, aes_BLOCK_SIZE);
|
|
80421
|
+
esm_assert_bytes(src);
|
|
80683
80422
|
const srcLen = src.length;
|
|
80684
80423
|
dst = getDst(srcLen, dst);
|
|
80685
80424
|
const ctr = nonce;
|
|
@@ -80718,8 +80457,8 @@ function ctrCounter(xk, nonce, src, dst) {
|
|
|
80718
80457
|
// It's possible to do 32le significantly simpler (and probably faster) by using u32.
|
|
80719
80458
|
// But, we need both, and perf bottleneck is in ghash anyway.
|
|
80720
80459
|
function ctr32(xk, isLE, nonce, src, dst) {
|
|
80721
|
-
|
|
80722
|
-
|
|
80460
|
+
esm_assert_bytes(nonce, aes_BLOCK_SIZE);
|
|
80461
|
+
esm_assert_bytes(src);
|
|
80723
80462
|
dst = getDst(src.length, dst);
|
|
80724
80463
|
const ctr = nonce; // write new value to nonce, so it can be re-used
|
|
80725
80464
|
const c32 = ciphers_esm_utils_u32(ctr);
|
|
@@ -80756,8 +80495,8 @@ function ctr32(xk, isLE, nonce, src, dst) {
|
|
|
80756
80495
|
* Requires good IV. Parallelizable. OK, but no MAC.
|
|
80757
80496
|
*/
|
|
80758
80497
|
const ctr = wrapCipher({ blockSize: 16, nonceLength: 16 }, function ctr(key, nonce) {
|
|
80759
|
-
|
|
80760
|
-
|
|
80498
|
+
esm_assert_bytes(key);
|
|
80499
|
+
esm_assert_bytes(nonce, aes_BLOCK_SIZE);
|
|
80761
80500
|
function processCtr(buf, dst) {
|
|
80762
80501
|
const xk = expandKeyLE(key);
|
|
80763
80502
|
const n = nonce.slice();
|
|
@@ -80772,7 +80511,7 @@ const ctr = wrapCipher({ blockSize: 16, nonceLength: 16 }, function ctr(key, non
|
|
|
80772
80511
|
};
|
|
80773
80512
|
});
|
|
80774
80513
|
function validateBlockDecrypt(data) {
|
|
80775
|
-
|
|
80514
|
+
esm_assert_bytes(data);
|
|
80776
80515
|
if (data.length % aes_BLOCK_SIZE !== 0) {
|
|
80777
80516
|
throw new Error(`aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size ${aes_BLOCK_SIZE}`);
|
|
80778
80517
|
}
|
|
@@ -80822,11 +80561,11 @@ function padPCKS(left) {
|
|
|
80822
80561
|
* Dangerous: always map x to y. See [AES Penguin](https://words.filippo.io/the-ecb-penguin/).
|
|
80823
80562
|
*/
|
|
80824
80563
|
const ecb = wrapCipher({ blockSize: 16 }, function ecb(key, opts = {}) {
|
|
80825
|
-
|
|
80564
|
+
esm_assert_bytes(key);
|
|
80826
80565
|
const pcks5 = !opts.disablePadding;
|
|
80827
80566
|
return {
|
|
80828
80567
|
encrypt: (plaintext, dst) => {
|
|
80829
|
-
|
|
80568
|
+
esm_assert_bytes(plaintext);
|
|
80830
80569
|
const { b, o, out: _out } = validateBlockEncrypt(plaintext, pcks5, dst);
|
|
80831
80570
|
const xk = expandKeyLE(key);
|
|
80832
80571
|
let i = 0;
|
|
@@ -80862,8 +80601,8 @@ const ecb = wrapCipher({ blockSize: 16 }, function ecb(key, opts = {}) {
|
|
|
80862
80601
|
* Fragile: needs proper padding. Unauthenticated: needs MAC.
|
|
80863
80602
|
*/
|
|
80864
80603
|
const cbc = wrapCipher({ blockSize: 16, nonceLength: 16 }, function cbc(key, iv, opts = {}) {
|
|
80865
|
-
|
|
80866
|
-
|
|
80604
|
+
esm_assert_bytes(key);
|
|
80605
|
+
esm_assert_bytes(iv, 16);
|
|
80867
80606
|
const pcks5 = !opts.disablePadding;
|
|
80868
80607
|
return {
|
|
80869
80608
|
encrypt: (plaintext, dst) => {
|
|
@@ -80913,8 +80652,8 @@ const cbc = wrapCipher({ blockSize: 16, nonceLength: 16 }, function cbc(key, iv,
|
|
|
80913
80652
|
* Unauthenticated: needs MAC.
|
|
80914
80653
|
*/
|
|
80915
80654
|
const cfb = wrapCipher({ blockSize: 16, nonceLength: 16 }, function cfb(key, iv) {
|
|
80916
|
-
|
|
80917
|
-
|
|
80655
|
+
esm_assert_bytes(key);
|
|
80656
|
+
esm_assert_bytes(iv, 16);
|
|
80918
80657
|
function processCfb(src, isEncrypt, dst) {
|
|
80919
80658
|
const xk = expandKeyLE(key);
|
|
80920
80659
|
const srcLen = src.length;
|
|
@@ -80970,7 +80709,7 @@ function computeTag(fn, isLE, key, data, AAD) {
|
|
|
80970
80709
|
* Be careful: MACs can be forged.
|
|
80971
80710
|
*/
|
|
80972
80711
|
const gcm = wrapCipher({ blockSize: 16, nonceLength: 12, tagLength: 16 }, function gcm(key, nonce, AAD) {
|
|
80973
|
-
|
|
80712
|
+
esm_assert_bytes(nonce);
|
|
80974
80713
|
// Nonce can be pretty much anything (even 1 byte). But smaller nonces less secure.
|
|
80975
80714
|
if (nonce.length === 0)
|
|
80976
80715
|
throw new Error('aes/gcm: empty nonce');
|
|
@@ -81003,7 +80742,7 @@ const gcm = wrapCipher({ blockSize: 16, nonceLength: 12, tagLength: 16 }, functi
|
|
|
81003
80742
|
}
|
|
81004
80743
|
return {
|
|
81005
80744
|
encrypt: (plaintext) => {
|
|
81006
|
-
|
|
80745
|
+
esm_assert_bytes(plaintext);
|
|
81007
80746
|
const { xk, authKey, counter, tagMask } = deriveKeys();
|
|
81008
80747
|
const out = new Uint8Array(plaintext.length + tagLength);
|
|
81009
80748
|
ctr32(xk, false, counter, plaintext, out);
|
|
@@ -81013,7 +80752,7 @@ const gcm = wrapCipher({ blockSize: 16, nonceLength: 12, tagLength: 16 }, functi
|
|
|
81013
80752
|
return out;
|
|
81014
80753
|
},
|
|
81015
80754
|
decrypt: (ciphertext) => {
|
|
81016
|
-
|
|
80755
|
+
esm_assert_bytes(ciphertext);
|
|
81017
80756
|
if (ciphertext.length < tagLength)
|
|
81018
80757
|
throw new Error(`aes/gcm: ciphertext less than tagLen (${tagLength})`);
|
|
81019
80758
|
const { xk, authKey, counter, tagMask } = deriveKeys();
|
|
@@ -81047,10 +80786,10 @@ const siv = wrapCipher({ blockSize: 16, nonceLength: 12, tagLength: 16 }, functi
|
|
|
81047
80786
|
const PLAIN_LIMIT = limit('plaintext', 0, 2 ** 36);
|
|
81048
80787
|
const NONCE_LIMIT = limit('nonce', 12, 12);
|
|
81049
80788
|
const CIPHER_LIMIT = limit('ciphertext', 16, 2 ** 36 + 16);
|
|
81050
|
-
|
|
80789
|
+
esm_assert_bytes(nonce);
|
|
81051
80790
|
NONCE_LIMIT(nonce.length);
|
|
81052
80791
|
if (AAD) {
|
|
81053
|
-
|
|
80792
|
+
esm_assert_bytes(AAD);
|
|
81054
80793
|
AAD_LIMIT(AAD.length);
|
|
81055
80794
|
}
|
|
81056
80795
|
function deriveKeys() {
|
|
@@ -81101,7 +80840,7 @@ const siv = wrapCipher({ blockSize: 16, nonceLength: 12, tagLength: 16 }, functi
|
|
|
81101
80840
|
}
|
|
81102
80841
|
return {
|
|
81103
80842
|
encrypt: (plaintext) => {
|
|
81104
|
-
|
|
80843
|
+
esm_assert_bytes(plaintext);
|
|
81105
80844
|
PLAIN_LIMIT(plaintext.length);
|
|
81106
80845
|
const { encKey, authKey } = deriveKeys();
|
|
81107
80846
|
const tag = _computeTag(encKey, authKey, plaintext);
|
|
@@ -81113,7 +80852,7 @@ const siv = wrapCipher({ blockSize: 16, nonceLength: 12, tagLength: 16 }, functi
|
|
|
81113
80852
|
return out;
|
|
81114
80853
|
},
|
|
81115
80854
|
decrypt: (ciphertext) => {
|
|
81116
|
-
|
|
80855
|
+
esm_assert_bytes(ciphertext);
|
|
81117
80856
|
CIPHER_LIMIT(ciphertext.length);
|
|
81118
80857
|
const tag = ciphertext.subarray(-tagLength);
|
|
81119
80858
|
const { encKey, authKey } = deriveKeys();
|
|
@@ -81133,7 +80872,7 @@ function isBytes32(a) {
|
|
|
81133
80872
|
(a instanceof Uint32Array || a.constructor.name === 'Uint32Array'));
|
|
81134
80873
|
}
|
|
81135
80874
|
function encryptBlock(xk, block) {
|
|
81136
|
-
|
|
80875
|
+
esm_assert_bytes(block, 16);
|
|
81137
80876
|
if (!isBytes32(xk))
|
|
81138
80877
|
throw new Error('_encryptBlock accepts result of expandKeyLE');
|
|
81139
80878
|
const b32 = ciphers_esm_utils_u32(block);
|
|
@@ -81142,7 +80881,7 @@ function encryptBlock(xk, block) {
|
|
|
81142
80881
|
return block;
|
|
81143
80882
|
}
|
|
81144
80883
|
function decryptBlock(xk, block) {
|
|
81145
|
-
|
|
80884
|
+
esm_assert_bytes(block, 16);
|
|
81146
80885
|
if (!isBytes32(xk))
|
|
81147
80886
|
throw new Error('_decryptBlock accepts result of expandKeyLE');
|
|
81148
80887
|
const b32 = ciphers_esm_utils_u32(block);
|
|
@@ -81182,7 +80921,7 @@ class Poly1305 {
|
|
|
81182
80921
|
this.pos = 0;
|
|
81183
80922
|
this.finished = false;
|
|
81184
80923
|
key = ciphers_esm_utils_toBytes(key);
|
|
81185
|
-
|
|
80924
|
+
esm_assert_bytes(key, 32);
|
|
81186
80925
|
const t0 = u8to16(key, 0);
|
|
81187
80926
|
const t1 = u8to16(key, 2);
|
|
81188
80927
|
const t2 = u8to16(key, 4);
|
|
@@ -81361,7 +81100,7 @@ class Poly1305 {
|
|
|
81361
81100
|
}
|
|
81362
81101
|
}
|
|
81363
81102
|
update(data) {
|
|
81364
|
-
|
|
81103
|
+
esm_assert_exists(this);
|
|
81365
81104
|
const { buffer, blockLen } = this;
|
|
81366
81105
|
data = ciphers_esm_utils_toBytes(data);
|
|
81367
81106
|
const len = data.length;
|
|
@@ -81390,8 +81129,8 @@ class Poly1305 {
|
|
|
81390
81129
|
this.pad.fill(0);
|
|
81391
81130
|
}
|
|
81392
81131
|
digestInto(out) {
|
|
81393
|
-
|
|
81394
|
-
|
|
81132
|
+
esm_assert_exists(this);
|
|
81133
|
+
esm_assert_output(out, this);
|
|
81395
81134
|
this.finished = true;
|
|
81396
81135
|
const { buffer, h } = this;
|
|
81397
81136
|
let { pos } = this;
|
|
@@ -81524,19 +81263,19 @@ function createCipher(core, opts) {
|
|
|
81524
81263
|
const { allowShortKeys, extendNonceFn, counterLength, counterRight, rounds } = ciphers_esm_utils_checkOpts({ allowShortKeys: false, counterLength: 8, counterRight: false, rounds: 20 }, opts);
|
|
81525
81264
|
if (typeof core !== 'function')
|
|
81526
81265
|
throw new Error('core must be a function');
|
|
81527
|
-
|
|
81528
|
-
|
|
81529
|
-
|
|
81530
|
-
|
|
81266
|
+
esm_assert_number(counterLength);
|
|
81267
|
+
esm_assert_number(rounds);
|
|
81268
|
+
esm_assert_bool(counterRight);
|
|
81269
|
+
esm_assert_bool(allowShortKeys);
|
|
81531
81270
|
return (key, nonce, data, output, counter = 0) => {
|
|
81532
|
-
|
|
81533
|
-
|
|
81534
|
-
|
|
81271
|
+
esm_assert_bytes(key);
|
|
81272
|
+
esm_assert_bytes(nonce);
|
|
81273
|
+
esm_assert_bytes(data);
|
|
81535
81274
|
const len = data.length;
|
|
81536
81275
|
if (!output)
|
|
81537
81276
|
output = new Uint8Array(len);
|
|
81538
|
-
|
|
81539
|
-
|
|
81277
|
+
esm_assert_bytes(output);
|
|
81278
|
+
esm_assert_number(counter);
|
|
81540
81279
|
if (counter < 0 || counter >= MAX_COUNTER)
|
|
81541
81280
|
throw new Error('arx: counter overflow');
|
|
81542
81281
|
if (output.length < len)
|
|
@@ -81868,14 +81607,14 @@ function chacha_computeTag(fn, key, nonce, data, AAD) {
|
|
|
81868
81607
|
*/
|
|
81869
81608
|
const _poly1305_aead = (xorStream) => (key, nonce, AAD) => {
|
|
81870
81609
|
const tagLength = 16;
|
|
81871
|
-
|
|
81872
|
-
|
|
81610
|
+
esm_assert_bytes(key, 32);
|
|
81611
|
+
esm_assert_bytes(nonce);
|
|
81873
81612
|
return {
|
|
81874
81613
|
encrypt: (plaintext, output) => {
|
|
81875
81614
|
const plength = plaintext.length;
|
|
81876
81615
|
const clength = plength + tagLength;
|
|
81877
81616
|
if (output) {
|
|
81878
|
-
|
|
81617
|
+
esm_assert_bytes(output, clength);
|
|
81879
81618
|
}
|
|
81880
81619
|
else {
|
|
81881
81620
|
output = new Uint8Array(clength);
|
|
@@ -81891,7 +81630,7 @@ const _poly1305_aead = (xorStream) => (key, nonce, AAD) => {
|
|
|
81891
81630
|
if (clength < tagLength)
|
|
81892
81631
|
throw new Error(`encrypted data must be at least ${tagLength} bytes`);
|
|
81893
81632
|
if (output) {
|
|
81894
|
-
|
|
81633
|
+
esm_assert_bytes(output, plength);
|
|
81895
81634
|
}
|
|
81896
81635
|
else {
|
|
81897
81636
|
output = new Uint8Array(plength);
|
|
@@ -81918,128 +81657,52 @@ const chacha20poly1305 = /* @__PURE__ */ wrapCipher({ blockSize: 64, nonceLength
|
|
|
81918
81657
|
*/
|
|
81919
81658
|
const xchacha20poly1305 = /* @__PURE__ */ wrapCipher({ blockSize: 64, nonceLength: 24, tagLength: 16 }, _poly1305_aead(xchacha20));
|
|
81920
81659
|
//# sourceMappingURL=chacha.js.map
|
|
81921
|
-
;// ./node_modules/@noble/hashes/esm/
|
|
81922
|
-
|
|
81923
|
-
|
|
81924
|
-
// HMAC (RFC 2104)
|
|
81925
|
-
class hashes_esm_hmac_HMAC extends esm_utils_Hash {
|
|
81926
|
-
constructor(hash, _key) {
|
|
81927
|
-
super();
|
|
81928
|
-
this.finished = false;
|
|
81929
|
-
this.destroyed = false;
|
|
81930
|
-
esm_assert.hash(hash);
|
|
81931
|
-
const key = esm_utils_toBytes(_key);
|
|
81932
|
-
this.iHash = hash.create();
|
|
81933
|
-
if (typeof this.iHash.update !== 'function')
|
|
81934
|
-
throw new Error('Expected instance of class which extends utils.Hash');
|
|
81935
|
-
this.blockLen = this.iHash.blockLen;
|
|
81936
|
-
this.outputLen = this.iHash.outputLen;
|
|
81937
|
-
const blockLen = this.blockLen;
|
|
81938
|
-
const pad = new Uint8Array(blockLen);
|
|
81939
|
-
// blockLen can be bigger than outputLen
|
|
81940
|
-
pad.set(key.length > blockLen ? hash.create().update(key).digest() : key);
|
|
81941
|
-
for (let i = 0; i < pad.length; i++)
|
|
81942
|
-
pad[i] ^= 0x36;
|
|
81943
|
-
this.iHash.update(pad);
|
|
81944
|
-
// By doing update (processing of first block) of outer hash here we can re-use it between multiple calls via clone
|
|
81945
|
-
this.oHash = hash.create();
|
|
81946
|
-
// Undo internal XOR && apply outer XOR
|
|
81947
|
-
for (let i = 0; i < pad.length; i++)
|
|
81948
|
-
pad[i] ^= 0x36 ^ 0x5c;
|
|
81949
|
-
this.oHash.update(pad);
|
|
81950
|
-
pad.fill(0);
|
|
81951
|
-
}
|
|
81952
|
-
update(buf) {
|
|
81953
|
-
esm_assert.exists(this);
|
|
81954
|
-
this.iHash.update(buf);
|
|
81955
|
-
return this;
|
|
81956
|
-
}
|
|
81957
|
-
digestInto(out) {
|
|
81958
|
-
esm_assert.exists(this);
|
|
81959
|
-
esm_assert.bytes(out, this.outputLen);
|
|
81960
|
-
this.finished = true;
|
|
81961
|
-
this.iHash.digestInto(out);
|
|
81962
|
-
this.oHash.update(out);
|
|
81963
|
-
this.oHash.digestInto(out);
|
|
81964
|
-
this.destroy();
|
|
81965
|
-
}
|
|
81966
|
-
digest() {
|
|
81967
|
-
const out = new Uint8Array(this.oHash.outputLen);
|
|
81968
|
-
this.digestInto(out);
|
|
81969
|
-
return out;
|
|
81970
|
-
}
|
|
81971
|
-
_cloneInto(to) {
|
|
81972
|
-
// Create new instance without calling constructor since key already in state and we don't know it.
|
|
81973
|
-
to || (to = Object.create(Object.getPrototypeOf(this), {}));
|
|
81974
|
-
const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;
|
|
81975
|
-
to = to;
|
|
81976
|
-
to.finished = finished;
|
|
81977
|
-
to.destroyed = destroyed;
|
|
81978
|
-
to.blockLen = blockLen;
|
|
81979
|
-
to.outputLen = outputLen;
|
|
81980
|
-
to.oHash = oHash._cloneInto(to.oHash);
|
|
81981
|
-
to.iHash = iHash._cloneInto(to.iHash);
|
|
81982
|
-
return to;
|
|
81983
|
-
}
|
|
81984
|
-
destroy() {
|
|
81985
|
-
this.destroyed = true;
|
|
81986
|
-
this.oHash.destroy();
|
|
81987
|
-
this.iHash.destroy();
|
|
81988
|
-
}
|
|
81989
|
-
}
|
|
81660
|
+
;// ./node_modules/@noble/hashes/esm/hkdf.js
|
|
81990
81661
|
/**
|
|
81991
|
-
*
|
|
81992
|
-
*
|
|
81993
|
-
* @
|
|
81994
|
-
* @param message - message data
|
|
81662
|
+
* HKDF (RFC 5869): extract + expand in one step.
|
|
81663
|
+
* See https://soatok.blog/2021/11/17/understanding-hkdf/.
|
|
81664
|
+
* @module
|
|
81995
81665
|
*/
|
|
81996
|
-
const hashes_esm_hmac_hmac = (hash, key, message) => new hashes_esm_hmac_HMAC(hash, key).update(message).digest();
|
|
81997
|
-
hashes_esm_hmac_hmac.create = (hash, key) => new hashes_esm_hmac_HMAC(hash, key);
|
|
81998
|
-
//# sourceMappingURL=hmac.js.map
|
|
81999
|
-
;// ./node_modules/@noble/hashes/esm/hkdf.js
|
|
82000
81666
|
|
|
82001
81667
|
|
|
82002
|
-
|
|
82003
|
-
// HKDF (RFC 5869)
|
|
82004
|
-
// https://soatok.blog/2021/11/17/understanding-hkdf/
|
|
82005
81668
|
/**
|
|
82006
|
-
* HKDF-Extract(IKM, salt) -> PRK
|
|
81669
|
+
* HKDF-extract from spec. Less important part. `HKDF-Extract(IKM, salt) -> PRK`
|
|
82007
81670
|
* Arguments position differs from spec (IKM is first one, since it is not optional)
|
|
82008
|
-
* @param hash
|
|
82009
|
-
* @param ikm
|
|
82010
|
-
* @param salt
|
|
82011
|
-
* @returns
|
|
81671
|
+
* @param hash - hash function that would be used (e.g. sha256)
|
|
81672
|
+
* @param ikm - input keying material, the initial key
|
|
81673
|
+
* @param salt - optional salt value (a non-secret random value)
|
|
82012
81674
|
*/
|
|
82013
81675
|
function extract(hash, ikm, salt) {
|
|
82014
|
-
|
|
81676
|
+
ahash(hash);
|
|
82015
81677
|
// NOTE: some libraries treat zero-length array as 'not provided';
|
|
82016
81678
|
// we don't, since we have undefined as 'not provided'
|
|
82017
81679
|
// https://github.com/RustCrypto/KDFs/issues/15
|
|
82018
81680
|
if (salt === undefined)
|
|
82019
|
-
salt = new Uint8Array(hash.outputLen);
|
|
82020
|
-
return
|
|
81681
|
+
salt = new Uint8Array(hash.outputLen);
|
|
81682
|
+
return hmac_hmac(hash, utils_toBytes(salt), utils_toBytes(ikm));
|
|
82021
81683
|
}
|
|
82022
|
-
|
|
82023
|
-
const
|
|
82024
|
-
const EMPTY_BUFFER = new Uint8Array();
|
|
81684
|
+
const HKDF_COUNTER = /* @__PURE__ */ Uint8Array.from([0]);
|
|
81685
|
+
const EMPTY_BUFFER = /* @__PURE__ */ Uint8Array.of();
|
|
82025
81686
|
/**
|
|
82026
|
-
* HKDF-expand from the spec.
|
|
81687
|
+
* HKDF-expand from the spec. The most important part. `HKDF-Expand(PRK, info, L) -> OKM`
|
|
81688
|
+
* @param hash - hash function that would be used (e.g. sha256)
|
|
82027
81689
|
* @param prk - a pseudorandom key of at least HashLen octets (usually, the output from the extract step)
|
|
82028
81690
|
* @param info - optional context and application specific information (can be a zero-length string)
|
|
82029
|
-
* @param length - length of output keying material in
|
|
81691
|
+
* @param length - length of output keying material in bytes
|
|
82030
81692
|
*/
|
|
82031
81693
|
function expand(hash, prk, info, length = 32) {
|
|
82032
|
-
|
|
82033
|
-
|
|
82034
|
-
|
|
81694
|
+
ahash(hash);
|
|
81695
|
+
anumber(length);
|
|
81696
|
+
const olen = hash.outputLen;
|
|
81697
|
+
if (length > 255 * olen)
|
|
82035
81698
|
throw new Error('Length should be <= 255*HashLen');
|
|
82036
|
-
const blocks = Math.ceil(length /
|
|
81699
|
+
const blocks = Math.ceil(length / olen);
|
|
82037
81700
|
if (info === undefined)
|
|
82038
81701
|
info = EMPTY_BUFFER;
|
|
82039
81702
|
// first L(ength) octets of T
|
|
82040
|
-
const okm = new Uint8Array(blocks *
|
|
81703
|
+
const okm = new Uint8Array(blocks * olen);
|
|
82041
81704
|
// Re-use HMAC instance between blocks
|
|
82042
|
-
const HMAC =
|
|
81705
|
+
const HMAC = hmac_hmac.create(hash, prk);
|
|
82043
81706
|
const HMACTmp = HMAC._cloneInto();
|
|
82044
81707
|
const T = new Uint8Array(HMAC.outputLen);
|
|
82045
81708
|
for (let counter = 0; counter < blocks; counter++) {
|
|
@@ -82050,22 +81713,30 @@ function expand(hash, prk, info, length = 32) {
|
|
|
82050
81713
|
.update(info)
|
|
82051
81714
|
.update(HKDF_COUNTER)
|
|
82052
81715
|
.digestInto(T);
|
|
82053
|
-
okm.set(T,
|
|
81716
|
+
okm.set(T, olen * counter);
|
|
82054
81717
|
HMAC._cloneInto(HMACTmp);
|
|
82055
81718
|
}
|
|
82056
81719
|
HMAC.destroy();
|
|
82057
81720
|
HMACTmp.destroy();
|
|
82058
|
-
T
|
|
82059
|
-
HKDF_COUNTER.fill(0);
|
|
81721
|
+
clean(T, HKDF_COUNTER);
|
|
82060
81722
|
return okm.slice(0, length);
|
|
82061
81723
|
}
|
|
82062
81724
|
/**
|
|
82063
|
-
* HKDF (RFC 5869):
|
|
81725
|
+
* HKDF (RFC 5869): derive keys from an initial input.
|
|
81726
|
+
* Combines hkdf_extract + hkdf_expand in one step
|
|
82064
81727
|
* @param hash - hash function that would be used (e.g. sha256)
|
|
82065
81728
|
* @param ikm - input keying material, the initial key
|
|
82066
81729
|
* @param salt - optional salt value (a non-secret random value)
|
|
82067
|
-
* @param info - optional context and application specific information
|
|
82068
|
-
* @param length - length of output keying material in
|
|
81730
|
+
* @param info - optional context and application specific information (can be a zero-length string)
|
|
81731
|
+
* @param length - length of output keying material in bytes
|
|
81732
|
+
* @example
|
|
81733
|
+
* import { hkdf } from '@noble/hashes/hkdf';
|
|
81734
|
+
* import { sha256 } from '@noble/hashes/sha2';
|
|
81735
|
+
* import { randomBytes } from '@noble/hashes/utils';
|
|
81736
|
+
* const inputKey = randomBytes(32);
|
|
81737
|
+
* const salt = randomBytes(32);
|
|
81738
|
+
* const info = 'application-key';
|
|
81739
|
+
* const hk1 = hkdf(sha256, inputKey, salt, info, 32);
|
|
82069
81740
|
*/
|
|
82070
81741
|
const hkdf = (hash, ikm, salt, info, length) => expand(hash, extract(hash, ikm, salt), info, length);
|
|
82071
81742
|
//# sourceMappingURL=hkdf.js.map
|
|
@@ -82127,8 +81798,8 @@ __export(utils_exports, {
|
|
|
82127
81798
|
Queue: () => Queue,
|
|
82128
81799
|
QueueNode: () => QueueNode,
|
|
82129
81800
|
binarySearch: () => binarySearch,
|
|
82130
|
-
bytesToHex: () =>
|
|
82131
|
-
hexToBytes: () =>
|
|
81801
|
+
bytesToHex: () => utils_bytesToHex,
|
|
81802
|
+
hexToBytes: () => utils_hexToBytes,
|
|
82132
81803
|
insertEventIntoAscendingList: () => insertEventIntoAscendingList,
|
|
82133
81804
|
insertEventIntoDescendingList: () => insertEventIntoDescendingList,
|
|
82134
81805
|
normalizeURL: () => normalizeURL,
|
|
@@ -82253,13 +81924,13 @@ var JS = class {
|
|
|
82253
81924
|
return esm_secp256k1_schnorr.utils.randomPrivateKey();
|
|
82254
81925
|
}
|
|
82255
81926
|
getPublicKey(secretKey) {
|
|
82256
|
-
return
|
|
81927
|
+
return utils_bytesToHex(esm_secp256k1_schnorr.getPublicKey(secretKey));
|
|
82257
81928
|
}
|
|
82258
81929
|
finalizeEvent(t, secretKey) {
|
|
82259
81930
|
const event = t;
|
|
82260
|
-
event.pubkey =
|
|
81931
|
+
event.pubkey = utils_bytesToHex(esm_secp256k1_schnorr.getPublicKey(secretKey));
|
|
82261
81932
|
event.id = getEventHash(event);
|
|
82262
|
-
event.sig =
|
|
81933
|
+
event.sig = utils_bytesToHex(esm_secp256k1_schnorr.sign(getEventHash(event), secretKey));
|
|
82263
81934
|
event[verifiedSymbol] = true;
|
|
82264
81935
|
return event;
|
|
82265
81936
|
}
|
|
@@ -82288,7 +81959,7 @@ function serializeEvent(evt) {
|
|
|
82288
81959
|
}
|
|
82289
81960
|
function getEventHash(event) {
|
|
82290
81961
|
let eventHash = sha256_sha256(utf8Encoder.encode(serializeEvent(event)));
|
|
82291
|
-
return
|
|
81962
|
+
return utils_bytesToHex(eventHash);
|
|
82292
81963
|
}
|
|
82293
81964
|
var i = new JS();
|
|
82294
81965
|
var generateSecretKey = i.generateSecretKey;
|
|
@@ -83338,7 +83009,7 @@ function esm_decode(code) {
|
|
|
83338
83009
|
return {
|
|
83339
83010
|
type: "nprofile",
|
|
83340
83011
|
data: {
|
|
83341
|
-
pubkey:
|
|
83012
|
+
pubkey: utils_bytesToHex(tlv[0][0]),
|
|
83342
83013
|
relays: tlv[1] ? tlv[1].map((d) => utf8Decoder.decode(d)) : []
|
|
83343
83014
|
}
|
|
83344
83015
|
};
|
|
@@ -83356,10 +83027,10 @@ function esm_decode(code) {
|
|
|
83356
83027
|
return {
|
|
83357
83028
|
type: "nevent",
|
|
83358
83029
|
data: {
|
|
83359
|
-
id:
|
|
83030
|
+
id: utils_bytesToHex(tlv[0][0]),
|
|
83360
83031
|
relays: tlv[1] ? tlv[1].map((d) => utf8Decoder.decode(d)) : [],
|
|
83361
|
-
author: tlv[2]?.[0] ?
|
|
83362
|
-
kind: tlv[3]?.[0] ? parseInt(
|
|
83032
|
+
author: tlv[2]?.[0] ? utils_bytesToHex(tlv[2][0]) : void 0,
|
|
83033
|
+
kind: tlv[3]?.[0] ? parseInt(utils_bytesToHex(tlv[3][0]), 16) : void 0
|
|
83363
83034
|
}
|
|
83364
83035
|
};
|
|
83365
83036
|
}
|
|
@@ -83379,8 +83050,8 @@ function esm_decode(code) {
|
|
|
83379
83050
|
type: "naddr",
|
|
83380
83051
|
data: {
|
|
83381
83052
|
identifier: utf8Decoder.decode(tlv[0][0]),
|
|
83382
|
-
pubkey:
|
|
83383
|
-
kind: parseInt(
|
|
83053
|
+
pubkey: utils_bytesToHex(tlv[2][0]),
|
|
83054
|
+
kind: parseInt(utils_bytesToHex(tlv[3][0]), 16),
|
|
83384
83055
|
relays: tlv[1] ? tlv[1].map((d) => utf8Decoder.decode(d)) : []
|
|
83385
83056
|
}
|
|
83386
83057
|
};
|
|
@@ -83389,7 +83060,7 @@ function esm_decode(code) {
|
|
|
83389
83060
|
return { type: prefix, data };
|
|
83390
83061
|
case "npub":
|
|
83391
83062
|
case "note":
|
|
83392
|
-
return { type: prefix, data:
|
|
83063
|
+
return { type: prefix, data: utils_bytesToHex(data) };
|
|
83393
83064
|
default:
|
|
83394
83065
|
throw new Error(`unknown prefix ${prefix}`);
|
|
83395
83066
|
}
|
|
@@ -83413,10 +83084,10 @@ function nsecEncode(key) {
|
|
|
83413
83084
|
return esm_encodeBytes("nsec", key);
|
|
83414
83085
|
}
|
|
83415
83086
|
function npubEncode(hex) {
|
|
83416
|
-
return esm_encodeBytes("npub",
|
|
83087
|
+
return esm_encodeBytes("npub", utils_hexToBytes(hex));
|
|
83417
83088
|
}
|
|
83418
83089
|
function noteEncode(hex) {
|
|
83419
|
-
return esm_encodeBytes("note",
|
|
83090
|
+
return esm_encodeBytes("note", utils_hexToBytes(hex));
|
|
83420
83091
|
}
|
|
83421
83092
|
function encodeBech32(prefix, data) {
|
|
83422
83093
|
let words = bech32.toWords(data);
|
|
@@ -83427,7 +83098,7 @@ function esm_encodeBytes(prefix, bytes) {
|
|
|
83427
83098
|
}
|
|
83428
83099
|
function nprofileEncode(profile) {
|
|
83429
83100
|
let data = encodeTLV({
|
|
83430
|
-
0: [
|
|
83101
|
+
0: [utils_hexToBytes(profile.pubkey)],
|
|
83431
83102
|
1: (profile.relays || []).map((url) => utf8Encoder.encode(url))
|
|
83432
83103
|
});
|
|
83433
83104
|
return encodeBech32("nprofile", data);
|
|
@@ -83438,9 +83109,9 @@ function neventEncode(event) {
|
|
|
83438
83109
|
kindArray = integerToUint8Array(event.kind);
|
|
83439
83110
|
}
|
|
83440
83111
|
let data = encodeTLV({
|
|
83441
|
-
0: [
|
|
83112
|
+
0: [utils_hexToBytes(event.id)],
|
|
83442
83113
|
1: (event.relays || []).map((url) => utf8Encoder.encode(url)),
|
|
83443
|
-
2: event.author ? [
|
|
83114
|
+
2: event.author ? [utils_hexToBytes(event.author)] : [],
|
|
83444
83115
|
3: kindArray ? [new Uint8Array(kindArray)] : []
|
|
83445
83116
|
});
|
|
83446
83117
|
return encodeBech32("nevent", data);
|
|
@@ -83451,7 +83122,7 @@ function naddrEncode(addr) {
|
|
|
83451
83122
|
let data = encodeTLV({
|
|
83452
83123
|
0: [utf8Encoder.encode(addr.identifier)],
|
|
83453
83124
|
1: (addr.relays || []).map((url) => utf8Encoder.encode(url)),
|
|
83454
|
-
2: [
|
|
83125
|
+
2: [utils_hexToBytes(addr.pubkey)],
|
|
83455
83126
|
3: [new Uint8Array(kind)]
|
|
83456
83127
|
});
|
|
83457
83128
|
return encodeBech32("naddr", data);
|
|
@@ -83467,7 +83138,7 @@ function encodeTLV(tlv) {
|
|
|
83467
83138
|
entries.push(entry);
|
|
83468
83139
|
});
|
|
83469
83140
|
});
|
|
83470
|
-
return
|
|
83141
|
+
return utils_concatBytes(...entries);
|
|
83471
83142
|
}
|
|
83472
83143
|
|
|
83473
83144
|
// references.ts
|
|
@@ -83570,10 +83241,10 @@ __export(nip04_exports, {
|
|
|
83570
83241
|
|
|
83571
83242
|
|
|
83572
83243
|
function esm_encrypt(secretKey, pubkey, text) {
|
|
83573
|
-
const privkey = secretKey instanceof Uint8Array ?
|
|
83244
|
+
const privkey = secretKey instanceof Uint8Array ? utils_bytesToHex(secretKey) : secretKey;
|
|
83574
83245
|
const key = esm_secp256k1_secp256k1.getSharedSecret(privkey, "02" + pubkey);
|
|
83575
83246
|
const normalizedKey = getNormalizedX(key);
|
|
83576
|
-
let iv = Uint8Array.from(
|
|
83247
|
+
let iv = Uint8Array.from(utils_randomBytes(16));
|
|
83577
83248
|
let plaintext = utf8Encoder.encode(text);
|
|
83578
83249
|
let ciphertext = cbc(normalizedKey, iv).encrypt(plaintext);
|
|
83579
83250
|
let ctb64 = base64.encode(new Uint8Array(ciphertext));
|
|
@@ -83581,7 +83252,7 @@ function esm_encrypt(secretKey, pubkey, text) {
|
|
|
83581
83252
|
return `${ctb64}?iv=${ivb64}`;
|
|
83582
83253
|
}
|
|
83583
83254
|
function esm_decrypt(secretKey, pubkey, data) {
|
|
83584
|
-
const privkey = secretKey instanceof Uint8Array ?
|
|
83255
|
+
const privkey = secretKey instanceof Uint8Array ? utils_bytesToHex(secretKey) : secretKey;
|
|
83585
83256
|
let [ctb64, ivb64] = data.split("?iv=");
|
|
83586
83257
|
let key = esm_secp256k1_secp256k1.getSharedSecret(privkey, "02" + pubkey);
|
|
83587
83258
|
let normalizedKey = getNormalizedX(key);
|
|
@@ -83818,7 +83489,7 @@ function minePow(unsigned, difficulty) {
|
|
|
83818
83489
|
return event;
|
|
83819
83490
|
}
|
|
83820
83491
|
function fastEventHash(evt) {
|
|
83821
|
-
return
|
|
83492
|
+
return utils_bytesToHex(
|
|
83822
83493
|
sha256_sha256(utf8Encoder.encode(JSON.stringify([0, evt.pubkey, evt.created_at, evt.kind, evt.tags, evt.content])))
|
|
83823
83494
|
);
|
|
83824
83495
|
}
|
|
@@ -83895,7 +83566,7 @@ function pad(plaintext) {
|
|
|
83895
83566
|
const unpaddedLen = unpadded.length;
|
|
83896
83567
|
const prefix = writeU16BE(unpaddedLen);
|
|
83897
83568
|
const suffix = new Uint8Array(calcPaddedLen(unpaddedLen) - unpaddedLen);
|
|
83898
|
-
return
|
|
83569
|
+
return utils_concatBytes(prefix, unpadded, suffix);
|
|
83899
83570
|
}
|
|
83900
83571
|
function unpad(padded) {
|
|
83901
83572
|
const unpaddedLen = new DataView(padded.buffer).getUint16(0);
|
|
@@ -83907,8 +83578,8 @@ function unpad(padded) {
|
|
|
83907
83578
|
function hmacAad(key, message, aad) {
|
|
83908
83579
|
if (aad.length !== 32)
|
|
83909
83580
|
throw new Error("AAD associated data must be 32 bytes");
|
|
83910
|
-
const combined =
|
|
83911
|
-
return
|
|
83581
|
+
const combined = utils_concatBytes(aad, message);
|
|
83582
|
+
return hmac_hmac(sha256_sha256, key, combined);
|
|
83912
83583
|
}
|
|
83913
83584
|
function decodePayload(payload) {
|
|
83914
83585
|
if (typeof payload !== "string")
|
|
@@ -83936,12 +83607,12 @@ function decodePayload(payload) {
|
|
|
83936
83607
|
mac: data.subarray(-32)
|
|
83937
83608
|
};
|
|
83938
83609
|
}
|
|
83939
|
-
function encrypt2(plaintext, conversationKey, nonce =
|
|
83610
|
+
function encrypt2(plaintext, conversationKey, nonce = utils_randomBytes(32)) {
|
|
83940
83611
|
const { chacha_key, chacha_nonce, hmac_key } = getMessageKeys(conversationKey, nonce);
|
|
83941
83612
|
const padded = pad(plaintext);
|
|
83942
83613
|
const ciphertext = chacha20(chacha_key, chacha_nonce, padded);
|
|
83943
83614
|
const mac = hmacAad(hmac_key, ciphertext, nonce);
|
|
83944
|
-
return base64.encode(
|
|
83615
|
+
return base64.encode(utils_concatBytes(new Uint8Array([2]), nonce, ciphertext, mac));
|
|
83945
83616
|
}
|
|
83946
83617
|
function decrypt2(payload, conversationKey) {
|
|
83947
83618
|
const { nonce, ciphertext, mac } = decodePayload(payload);
|
|
@@ -84758,7 +84429,7 @@ function validateEventMethodTag(event, method) {
|
|
|
84758
84429
|
}
|
|
84759
84430
|
function hashPayload(payload) {
|
|
84760
84431
|
const hash = sha256_sha256(utf8Encoder.encode(JSON.stringify(payload)));
|
|
84761
|
-
return
|
|
84432
|
+
return utils_bytesToHex(hash);
|
|
84762
84433
|
}
|
|
84763
84434
|
function validateEventPayloadTag(event, payload) {
|
|
84764
84435
|
const payloadTag = event.tags.find((t) => t[0] === "payload");
|
|
@@ -90233,11 +89904,9 @@ class DataBase {
|
|
|
90233
89904
|
async createAliasIndex(username, userPub) {
|
|
90234
89905
|
try {
|
|
90235
89906
|
const aliasNode = this.gun.get(`~@${username}`);
|
|
90236
|
-
|
|
90237
|
-
|
|
90238
|
-
|
|
90239
|
-
})
|
|
90240
|
-
.then();
|
|
89907
|
+
// For Gun.js alias validation to pass, the data must be exactly equal to the key
|
|
89908
|
+
// The key is `~@${username}`, so we store that as the data
|
|
89909
|
+
const ack = await aliasNode.put(`~@${username}`).then();
|
|
90241
89910
|
if (ack.err) {
|
|
90242
89911
|
console.error(`Error creating alias index: ${ack.err}`);
|
|
90243
89912
|
}
|
|
@@ -91106,14 +90775,19 @@ class DataBase {
|
|
|
91106
90775
|
}
|
|
91107
90776
|
}
|
|
91108
90777
|
const createGun = (config) => {
|
|
91109
|
-
|
|
90778
|
+
console.log("Creating Gun instance with config:", config);
|
|
90779
|
+
console.log("Config peers:", config?.peers);
|
|
90780
|
+
const gunInstance = new (gun_default())(config);
|
|
90781
|
+
console.log("Created Gun instance:", gunInstance);
|
|
90782
|
+
console.log("Gun instance opt after creation:", gunInstance?.opt);
|
|
90783
|
+
return gunInstance;
|
|
91110
90784
|
};
|
|
91111
90785
|
|
|
91112
90786
|
/* harmony default export */ const db = ((gun_default()));
|
|
91113
90787
|
|
|
91114
|
-
;// ./src/gundb/
|
|
90788
|
+
;// ./src/gundb/types.ts
|
|
91115
90789
|
/**
|
|
91116
|
-
*
|
|
90790
|
+
* Type definitions for GunDB to replace 'any' usage
|
|
91117
90791
|
*/
|
|
91118
90792
|
|
|
91119
90793
|
|
|
@@ -91618,7 +91292,7 @@ class CoreInitializer {
|
|
|
91618
91292
|
// Setup wallet derivation
|
|
91619
91293
|
this.setupWalletDerivation();
|
|
91620
91294
|
// Initialize RxJS
|
|
91621
|
-
this.core.rx = new RxJS(this.core.
|
|
91295
|
+
this.core.rx = new RxJS(this.core.gun);
|
|
91622
91296
|
// Register built-in plugins
|
|
91623
91297
|
this.registerBuiltinPlugins(config);
|
|
91624
91298
|
// Initialize async components
|
|
@@ -91628,15 +91302,25 @@ class CoreInitializer {
|
|
|
91628
91302
|
* Initialize Gun instance
|
|
91629
91303
|
*/
|
|
91630
91304
|
async initializeGun(config) {
|
|
91305
|
+
console.log("Initialize Gun instance", config);
|
|
91631
91306
|
if (config.gunOptions.authToken) {
|
|
91632
91307
|
restrictedPut((gun_default()), config.gunOptions.authToken);
|
|
91633
91308
|
}
|
|
91634
91309
|
try {
|
|
91635
|
-
if (config.gunInstance) {
|
|
91310
|
+
if (config.gunInstance && config.gunInstance instanceof (gun_default())) {
|
|
91311
|
+
console.log("config.gunInstance", config.gunInstance);
|
|
91636
91312
|
this.core._gun = config.gunInstance;
|
|
91637
91313
|
}
|
|
91638
91314
|
else {
|
|
91315
|
+
console.log("config.gunOptions", config.gunOptions);
|
|
91639
91316
|
this.core._gun = createGun(config.gunOptions);
|
|
91317
|
+
// Explicitly apply peers configuration if not already set
|
|
91318
|
+
if (config.gunOptions?.peers &&
|
|
91319
|
+
Array.isArray(config.gunOptions.peers)) {
|
|
91320
|
+
console.log("Applying peers configuration:", config.gunOptions.peers);
|
|
91321
|
+
this.core._gun.opt({ peers: config.gunOptions.peers });
|
|
91322
|
+
console.log("Peers after explicit application:", this.core._gun?.opt?.peers);
|
|
91323
|
+
}
|
|
91640
91324
|
}
|
|
91641
91325
|
}
|
|
91642
91326
|
catch (error) {
|
|
@@ -91646,7 +91330,8 @@ class CoreInitializer {
|
|
|
91646
91330
|
throw new Error(`Failed to create Gun instance: ${error}`);
|
|
91647
91331
|
}
|
|
91648
91332
|
try {
|
|
91649
|
-
|
|
91333
|
+
console.log("Initialize Gun instance", this.core.gun);
|
|
91334
|
+
this.core.db = new DataBase(this.core.gun, config.gunOptions.scope || "");
|
|
91650
91335
|
this.core._gun = this.core.db.gun;
|
|
91651
91336
|
}
|
|
91652
91337
|
catch (error) {
|
|
@@ -91661,9 +91346,7 @@ class CoreInitializer {
|
|
|
91661
91346
|
*/
|
|
91662
91347
|
async initializeGunUser() {
|
|
91663
91348
|
try {
|
|
91664
|
-
this.core.
|
|
91665
|
-
.user()
|
|
91666
|
-
.recall({ sessionStorage: true });
|
|
91349
|
+
this.core.user = this.core.gun.user().recall({ sessionStorage: true });
|
|
91667
91350
|
}
|
|
91668
91351
|
catch (error) {
|
|
91669
91352
|
if (typeof console !== "undefined" && console.error) {
|
|
@@ -91671,10 +91354,8 @@ class CoreInitializer {
|
|
|
91671
91354
|
}
|
|
91672
91355
|
throw new Error(`Failed to initialize Gun user: ${error}`);
|
|
91673
91356
|
}
|
|
91674
|
-
this.core.
|
|
91675
|
-
this.core.
|
|
91676
|
-
.user()
|
|
91677
|
-
.recall({ sessionStorage: true });
|
|
91357
|
+
this.core.gun.on("auth", (user) => {
|
|
91358
|
+
this.core.user = this.core.gun.user().recall({ sessionStorage: true });
|
|
91678
91359
|
this.core.emit("auth:login", {
|
|
91679
91360
|
userPub: user.pub,
|
|
91680
91361
|
method: "password",
|
|
@@ -91707,7 +91388,7 @@ class CoreInitializer {
|
|
|
91707
91388
|
* Setup wallet derivation
|
|
91708
91389
|
*/
|
|
91709
91390
|
setupWalletDerivation() {
|
|
91710
|
-
this.core.
|
|
91391
|
+
this.core.gun.on("auth", async (user) => {
|
|
91711
91392
|
if (!user)
|
|
91712
91393
|
return;
|
|
91713
91394
|
const priv = user._?.sea?.epriv;
|
|
@@ -91813,7 +91494,7 @@ class CoreInitializer {
|
|
|
91813
91494
|
* @since 2.0.0
|
|
91814
91495
|
*/
|
|
91815
91496
|
class ShogunCore {
|
|
91816
|
-
static API_VERSION = "^
|
|
91497
|
+
static API_VERSION = "^3.0.1";
|
|
91817
91498
|
db;
|
|
91818
91499
|
storage;
|
|
91819
91500
|
provider;
|