/
opt
/
canhelp
/
node_modules
/
@noble
/
hashes
/
/opt/canhelp/node_modules/@noble/hashes
mkdir
upload
Name
Size
Mode
Actions
src/
-
0755
rm
argon2.d.ts
1498
0644
edit
dl
rm
argon2.d.ts.map
1137
0644
edit
dl
rm
argon2.js
16308
0644
edit
dl
rm
argon2.js.map
21113
0644
edit
dl
rm
blake1.d.ts
3624
0644
edit
dl
rm
blake1.d.ts.map
3743
0644
edit
dl
rm
blake1.js
19433
0644
edit
dl
rm
blake1.js.map
28454
0644
edit
dl
rm
blake2.d.ts
3907
0644
edit
dl
rm
blake2.d.ts.map
4103
0644
edit
dl
rm
blake2.js
16895
0644
edit
dl
rm
blake2.js.map
25543
0644
edit
dl
rm
blake3.d.ts
1837
0644
edit
dl
rm
blake3.d.ts.map
1296
0644
edit
dl
rm
blake3.js
9627
0644
edit
dl
rm
blake3.js.map
10753
0644
edit
dl
rm
eskdf.d.ts
1752
0644
edit
dl
rm
eskdf.d.ts.map
902
0644
edit
dl
rm
eskdf.js
6550
0644
edit
dl
rm
eskdf.js.map
6007
0644
edit
dl
rm
hkdf.d.ts
1996
0644
edit
dl
rm
hkdf.d.ts.map
553
0644
edit
dl
rm
hkdf.js
3538
0644
edit
dl
rm
hkdf.js.map
2147
0644
edit
dl
rm
hmac.d.ts
1090
0644
edit
dl
rm
hmac.d.ts.map
934
0644
edit
dl
rm
hmac.js
2992
0644
edit
dl
rm
hmac.js.map
3067
0644
edit
dl
rm
index.d.ts
46
0644
edit
dl
rm
index.d.ts.map
101
0644
edit
dl
rm
index.js
1162
0644
edit
dl
rm
index.js.map
180
0644
edit
dl
rm
legacy.d.ts
2579
0644
edit
dl
rm
legacy.d.ts.map
1888
0644
edit
dl
rm
legacy.js
9763
0644
edit
dl
rm
legacy.js.map
13498
0644
edit
dl
rm
LICENSE
1109
0644
edit
dl
rm
package.json
2799
0644
edit
dl
rm
pbkdf2.d.ts
1194
0644
edit
dl
rm
pbkdf2.d.ts.map
576
0644
edit
dl
rm
pbkdf2.js
3898
0644
edit
dl
rm
pbkdf2.js.map
4050
0644
edit
dl
rm
README.md
24015
0644
edit
dl
rm
scrypt.d.ts
1337
0644
edit
dl
rm
scrypt.d.ts.map
658
0644
edit
dl
rm
scrypt.js
9720
0644
edit
dl
rm
scrypt.js.map
12136
0644
edit
dl
rm
sha2.d.ts
6512
0644
edit
dl
rm
sha2.d.ts.map
6359
0644
edit
dl
rm
sha2.js
16773
0644
edit
dl
rm
sha2.js.map
20062
0644
edit
dl
rm
sha3-addons.d.ts
6232
0644
edit
dl
rm
sha3-addons.d.ts.map
4419
0644
edit
dl
rm
sha3-addons.js
17028
0644
edit
dl
rm
sha3-addons.js.map
17483
0644
edit
dl
rm
sha3.d.ts
2325
0644
edit
dl
rm
sha3.d.ts.map
1933
0644
edit
dl
rm
sha3.js
9199
0644
edit
dl
rm
sha3.js.map
10690
0644
edit
dl
rm
utils.d.ts
6128
0644
edit
dl
rm
utils.d.ts.map
4117
0644
edit
dl
rm
utils.js
9356
0644
edit
dl
rm
utils.js.map
9127
0644
edit
dl
rm
webcrypto.d.ts
2718
0644
edit
dl
rm
webcrypto.d.ts.map
1099
0644
edit
dl
rm
webcrypto.js
5090
0644
edit
dl
rm
webcrypto.js.map
3969
0644
edit
dl
rm
_blake.d.ts
474
0644
edit
dl
rm
_blake.d.ts.map
553
0644
edit
dl
rm
_blake.js
1661
0644
edit
dl
rm
_blake.js.map
3628
0644
edit
dl
rm
_md.d.ts
1968
0644
edit
dl
rm
_md.d.ts.map
1518
0644
edit
dl
rm
_md.js
5615
0644
edit
dl
rm
_md.js.map
5065
0644
edit
dl
rm
_u64.d.ts
3129
0644
edit
dl
rm
_u64.d.ts.map
4314
0644
edit
dl
rm
_u64.js
3081
0644
edit
dl
rm
_u64.js.map
5045
0644
edit
dl
rm
Edit:
/opt/canhelp/node_modules/@noble/hashes/sha3.js
(9199B)
/** * SHA3 (keccak) hash function, based on a new "Sponge function" design. * Different from older hashes, the internal state is bigger than output size. * * Check out [FIPS-202](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf), * [Website](https://keccak.team/keccak.html), * [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). * * Check out `sha3-addons` module for cSHAKE, k12, and others. * @module */ import { rotlBH, rotlBL, rotlSH, rotlSL, split } from "./_u64.js"; // prettier-ignore import { abytes, aexists, anumber, aoutput, clean, createHasher, oidNist, swap32IfBE, u32 } from "./utils.js"; // No __PURE__ annotations in sha3 header: // EVERYTHING is in fact used on every export. // Various per round constants calculations const _0n = BigInt(0); const _1n = BigInt(1); const _2n = BigInt(2); const _7n = BigInt(7); const _256n = BigInt(256); const _0x71n = BigInt(0x71); const SHA3_PI = []; const SHA3_ROTL = []; const _SHA3_IOTA = []; // no pure annotation: var is always used for (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) { // Pi [x, y] = [y, (2 * x + 3 * y) % 5]; SHA3_PI.push(2 * (5 * y + x)); // Rotational SHA3_ROTL.push((((round + 1) * (round + 2)) / 2) % 64); // Iota let t = _0n; for (let j = 0; j < 7; j++) { R = ((R << _1n) ^ ((R >> _7n) * _0x71n)) % _256n; if (R & _2n) t ^= _1n << ((_1n << BigInt(j)) - _1n); } _SHA3_IOTA.push(t); } const IOTAS = split(_SHA3_IOTA, true); const SHA3_IOTA_H = IOTAS[0]; const SHA3_IOTA_L = IOTAS[1]; // Left rotation (without 0, 32, 64) const rotlH = (h, l, s) => (s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s)); const rotlL = (h, l, s) => (s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s)); /** `keccakf1600` internal function, additionally allows to adjust round count. */ export function keccakP(s, rounds = 24) { const B = new Uint32Array(5 * 2); // NOTE: all indices are x2 since we store state as u32 instead of u64 (bigints to slow in js) for (let round = 24 - rounds; round < 24; round++) { // Theta θ for (let x = 0; x < 10; x++) B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40]; for (let x = 0; x < 10; x += 2) { const idx1 = (x + 8) % 10; const idx0 = (x + 2) % 10; const B0 = B[idx0]; const B1 = B[idx0 + 1]; const Th = rotlH(B0, B1, 1) ^ B[idx1]; const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1]; for (let y = 0; y < 50; y += 10) { s[x + y] ^= Th; s[x + y + 1] ^= Tl; } } // Rho (ρ) and Pi (π) let curH = s[2]; let curL = s[3]; for (let t = 0; t < 24; t++) { const shift = SHA3_ROTL[t]; const Th = rotlH(curH, curL, shift); const Tl = rotlL(curH, curL, shift); const PI = SHA3_PI[t]; curH = s[PI]; curL = s[PI + 1]; s[PI] = Th; s[PI + 1] = Tl; } // Chi (χ) for (let y = 0; y < 50; y += 10) { for (let x = 0; x < 10; x++) B[x] = s[y + x]; for (let x = 0; x < 10; x++) s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10]; } // Iota (ι) s[0] ^= SHA3_IOTA_H[round]; s[1] ^= SHA3_IOTA_L[round]; } clean(B); } /** Keccak sponge function. */ export class Keccak { state; pos = 0; posOut = 0; finished = false; state32; destroyed = false; blockLen; suffix; outputLen; enableXOF = false; rounds; // NOTE: we accept arguments in bytes instead of bits here. constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) { this.blockLen = blockLen; this.suffix = suffix; this.outputLen = outputLen; this.enableXOF = enableXOF; this.rounds = rounds; // Can be passed from user as dkLen anumber(outputLen, 'outputLen'); // 1600 = 5x5 matrix of 64bit. 1600 bits === 200 bytes // 0 < blockLen < 200 if (!(0 < blockLen && blockLen < 200)) throw new Error('only keccak-f1600 function is supported'); this.state = new Uint8Array(200); this.state32 = u32(this.state); } clone() { return this._cloneInto(); } keccak() { swap32IfBE(this.state32); keccakP(this.state32, this.rounds); swap32IfBE(this.state32); this.posOut = 0; this.pos = 0; } update(data) { aexists(this); abytes(data); const { blockLen, state } = this; const len = data.length; for (let pos = 0; pos < len;) { const take = Math.min(blockLen - this.pos, len - pos); for (let i = 0; i < take; i++) state[this.pos++] ^= data[pos++]; if (this.pos === blockLen) this.keccak(); } return this; } finish() { if (this.finished) return; this.finished = true; const { state, suffix, pos, blockLen } = this; // Do the padding state[pos] ^= suffix; if ((suffix & 0x80) !== 0 && pos === blockLen - 1) this.keccak(); state[blockLen - 1] ^= 0x80; this.keccak(); } writeInto(out) { aexists(this, false); abytes(out); this.finish(); const bufferOut = this.state; const { blockLen } = this; for (let pos = 0, len = out.length; pos < len;) { if (this.posOut >= blockLen) this.keccak(); const take = Math.min(blockLen - this.posOut, len - pos); out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos); this.posOut += take; pos += take; } return out; } xofInto(out) { // Sha3/Keccak usage with XOF is probably mistake, only SHAKE instances can do XOF if (!this.enableXOF) throw new Error('XOF is not possible for this instance'); return this.writeInto(out); } xof(bytes) { anumber(bytes); return this.xofInto(new Uint8Array(bytes)); } digestInto(out) { aoutput(out, this); if (this.finished) throw new Error('digest() was already called'); this.writeInto(out); this.destroy(); return out; } digest() { return this.digestInto(new Uint8Array(this.outputLen)); } destroy() { this.destroyed = true; clean(this.state); } _cloneInto(to) { const { blockLen, suffix, outputLen, rounds, enableXOF } = this; to ||= new Keccak(blockLen, suffix, outputLen, enableXOF, rounds); to.state32.set(this.state32); to.pos = this.pos; to.posOut = this.posOut; to.finished = this.finished; to.rounds = rounds; // Suffix can change in cSHAKE to.suffix = suffix; to.outputLen = outputLen; to.enableXOF = enableXOF; to.destroyed = this.destroyed; return to; } } const genKeccak = (suffix, blockLen, outputLen, info = {}) => createHasher(() => new Keccak(blockLen, suffix, outputLen), info); /** SHA3-224 hash function. */ export const sha3_224 = /* @__PURE__ */ genKeccak(0x06, 144, 28, /* @__PURE__ */ oidNist(0x07)); /** SHA3-256 hash function. Different from keccak-256. */ export const sha3_256 = /* @__PURE__ */ genKeccak(0x06, 136, 32, /* @__PURE__ */ oidNist(0x08)); /** SHA3-384 hash function. */ export const sha3_384 = /* @__PURE__ */ genKeccak(0x06, 104, 48, /* @__PURE__ */ oidNist(0x09)); /** SHA3-512 hash function. */ export const sha3_512 = /* @__PURE__ */ genKeccak(0x06, 72, 64, /* @__PURE__ */ oidNist(0x0a)); /** keccak-224 hash function. */ export const keccak_224 = /* @__PURE__ */ genKeccak(0x01, 144, 28); /** keccak-256 hash function. Different from SHA3-256. */ export const keccak_256 = /* @__PURE__ */ genKeccak(0x01, 136, 32); /** keccak-384 hash function. */ export const keccak_384 = /* @__PURE__ */ genKeccak(0x01, 104, 48); /** keccak-512 hash function. */ export const keccak_512 = /* @__PURE__ */ genKeccak(0x01, 72, 64); const genShake = (suffix, blockLen, outputLen, info = {}) => createHasher((opts = {}) => new Keccak(blockLen, suffix, opts.dkLen === undefined ? outputLen : opts.dkLen, true), info); /** SHAKE128 XOF with 128-bit security. */ export const shake128 = /* @__PURE__ */ genShake(0x1f, 168, 16, /* @__PURE__ */ oidNist(0x0b)); /** SHAKE256 XOF with 256-bit security. */ export const shake256 = /* @__PURE__ */ genShake(0x1f, 136, 32, /* @__PURE__ */ oidNist(0x0c)); /** SHAKE128 XOF with 256-bit output (NIST version). */ export const shake128_32 = /* @__PURE__ */ genShake(0x1f, 168, 32, /* @__PURE__ */ oidNist(0x0b)); /** SHAKE256 XOF with 512-bit output (NIST version). */ export const shake256_64 = /* @__PURE__ */ genShake(0x1f, 136, 64, /* @__PURE__ */ oidNist(0x0c)); //# sourceMappingURL=sha3.js.map
Save
cmd:
run