@noble/hashes
Advanced tools
Comparing version 0.4.3 to 0.4.4
@@ -1,2 +0,2 @@ | ||
import { Hash, Input } from './utils'; | ||
import { Hash, Input } from './utils.js'; | ||
export declare const SIGMA: Uint8Array; | ||
@@ -3,0 +3,0 @@ export declare type BlakeOpts = { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BLAKE2 = exports.SIGMA = void 0; | ||
const utils_1 = require("./utils"); | ||
const utils_js_1 = require("./utils.js"); | ||
// prettier-ignore | ||
@@ -21,3 +21,3 @@ exports.SIGMA = new Uint8Array([ | ||
]); | ||
class BLAKE2 extends utils_1.Hash { | ||
class BLAKE2 extends utils_js_1.Hash { | ||
constructor(blockLen, outputLen, opts = {}, keyLen, saltLen, persLen) { | ||
@@ -31,5 +31,5 @@ super(); | ||
this.destroyed = false; | ||
(0, utils_1.assertNumber)(blockLen); | ||
(0, utils_1.assertNumber)(outputLen); | ||
(0, utils_1.assertNumber)(keyLen); | ||
(0, utils_js_1.assertNumber)(blockLen); | ||
(0, utils_js_1.assertNumber)(outputLen); | ||
(0, utils_js_1.assertNumber)(keyLen); | ||
if (outputLen < 0 || outputLen > keyLen) | ||
@@ -43,3 +43,3 @@ throw new Error('Blake2: outputLen bigger than keyLen'); | ||
throw new Error(`Personalization should be ${persLen} byte long or undefined`); | ||
this.buffer32 = (0, utils_1.u32)((this.buffer = new Uint8Array(blockLen))); | ||
this.buffer32 = (0, utils_js_1.u32)((this.buffer = new Uint8Array(blockLen))); | ||
} | ||
@@ -56,3 +56,3 @@ update(data) { | ||
throw new Error('digest() was already called'); | ||
data = (0, utils_1.toBytes)(data); | ||
data = (0, utils_js_1.toBytes)(data); | ||
const len = data.length; | ||
@@ -95,3 +95,3 @@ for (let pos = 0; pos < len;) { | ||
this.compress(buffer32, 0, true); | ||
const out32 = (0, utils_1.u32)(out); | ||
const out32 = (0, utils_js_1.u32)(out); | ||
this.get().forEach((v, i) => (out32[i] = v)); | ||
@@ -98,0 +98,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { Hash, Input } from './utils'; | ||
import { Hash, Input } from './utils.js'; | ||
export declare abstract class SHA2<T extends SHA2<T>> extends Hash<T> { | ||
@@ -3,0 +3,0 @@ readonly blockLen: number; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SHA2 = void 0; | ||
const utils_1 = require("./utils"); | ||
const utils_js_1 = require("./utils.js"); | ||
// Polyfill for Safari 14 | ||
@@ -19,3 +19,3 @@ function setBigUint64(view, byteOffset, value, isLE) { | ||
// Base SHA2 class (RFC 6234) | ||
class SHA2 extends utils_1.Hash { | ||
class SHA2 extends utils_js_1.Hash { | ||
constructor(blockLen, outputLen, padOffset, isLE) { | ||
@@ -32,3 +32,3 @@ super(); | ||
this.buffer = new Uint8Array(blockLen); | ||
this.view = (0, utils_1.createView)(this.buffer); | ||
this.view = (0, utils_js_1.createView)(this.buffer); | ||
} | ||
@@ -41,3 +41,3 @@ update(data) { | ||
throw new Error('digest() was already called'); | ||
data = (0, utils_1.toBytes)(data); | ||
data = (0, utils_js_1.toBytes)(data); | ||
const len = data.length; | ||
@@ -48,3 +48,3 @@ for (let pos = 0; pos < len;) { | ||
if (take === blockLen) { | ||
const dataView = (0, utils_1.createView)(data); | ||
const dataView = (0, utils_js_1.createView)(data); | ||
for (; blockLen <= len - pos; pos += blockLen) | ||
@@ -95,3 +95,3 @@ this.process(dataView, pos); | ||
this.process(view, 0); | ||
const oview = (0, utils_1.createView)(out); | ||
const oview = (0, utils_js_1.createView)(out); | ||
this.get().forEach((v, i) => oview.setUint32(4 * i, v, isLE)); | ||
@@ -98,0 +98,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import * as blake2 from './_blake2'; | ||
import * as blake2 from './_blake2.js'; | ||
declare class BLAKE2b extends blake2.BLAKE2<BLAKE2b> { | ||
@@ -43,8 +43,8 @@ private v0l; | ||
export declare const blake2b: { | ||
(msg: import("./utils").Input, opts?: blake2.BlakeOpts | undefined): Uint8Array; | ||
(msg: import("./utils.js").Input, opts?: blake2.BlakeOpts | undefined): Uint8Array; | ||
outputLen: number; | ||
blockLen: number; | ||
create(opts: blake2.BlakeOpts): import("./utils").Hash<BLAKE2b>; | ||
init: (opts: blake2.BlakeOpts) => import("./utils").Hash<BLAKE2b>; | ||
create(opts: blake2.BlakeOpts): import("./utils.js").Hash<BLAKE2b>; | ||
init: (opts: blake2.BlakeOpts) => import("./utils.js").Hash<BLAKE2b>; | ||
}; | ||
export {}; |
@@ -23,5 +23,5 @@ "use strict"; | ||
exports.blake2b = void 0; | ||
const blake2 = __importStar(require("./_blake2")); | ||
const u64 = __importStar(require("./_u64")); | ||
const utils_1 = require("./utils"); | ||
const blake2 = __importStar(require("./_blake2.js")); | ||
const u64 = __importStar(require("./_u64.js")); | ||
const utils_js_1 = require("./utils.js"); | ||
// Same as SHA-512 but LE | ||
@@ -107,3 +107,3 @@ // prettier-ignore | ||
if (opts.salt) { | ||
const salt = (0, utils_1.u32)((0, utils_1.toBytes)(opts.salt)); | ||
const salt = (0, utils_js_1.u32)((0, utils_js_1.toBytes)(opts.salt)); | ||
this.v4l ^= salt[0]; | ||
@@ -115,3 +115,3 @@ this.v4h ^= salt[1]; | ||
if (opts.personalization) { | ||
const pers = (0, utils_1.u32)((0, utils_1.toBytes)(opts.personalization)); | ||
const pers = (0, utils_js_1.u32)((0, utils_js_1.toBytes)(opts.personalization)); | ||
this.v6l ^= pers[0]; | ||
@@ -125,3 +125,3 @@ this.v6h ^= pers[1]; | ||
const tmp = new Uint8Array(this.blockLen); | ||
tmp.set((0, utils_1.toBytes)(opts.key)); | ||
tmp.set((0, utils_js_1.toBytes)(opts.key)); | ||
this.update(tmp); | ||
@@ -209,2 +209,2 @@ } | ||
} | ||
exports.blake2b = (0, utils_1.wrapConstructorWithOpts)((opts) => new BLAKE2b(opts)); | ||
exports.blake2b = (0, utils_js_1.wrapConstructorWithOpts)((opts) => new BLAKE2b(opts)); |
@@ -1,2 +0,2 @@ | ||
import * as blake2 from './_blake2'; | ||
import * as blake2 from './_blake2.js'; | ||
export declare const IV: Uint32Array; | ||
@@ -37,8 +37,8 @@ export declare function compress(s: Uint8Array, offset: number, msg: Uint32Array, rounds: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number): { | ||
export declare const blake2s: { | ||
(msg: import("./utils").Input, opts?: blake2.BlakeOpts | undefined): Uint8Array; | ||
(msg: import("./utils.js").Input, opts?: blake2.BlakeOpts | undefined): Uint8Array; | ||
outputLen: number; | ||
blockLen: number; | ||
create(opts: blake2.BlakeOpts): import("./utils").Hash<BLAKE2s>; | ||
init: (opts: blake2.BlakeOpts) => import("./utils").Hash<BLAKE2s>; | ||
create(opts: blake2.BlakeOpts): import("./utils.js").Hash<BLAKE2s>; | ||
init: (opts: blake2.BlakeOpts) => import("./utils.js").Hash<BLAKE2s>; | ||
}; | ||
export {}; |
@@ -23,5 +23,5 @@ "use strict"; | ||
exports.blake2s = exports.compress = exports.IV = void 0; | ||
const u64 = __importStar(require("./_u64")); | ||
const blake2 = __importStar(require("./_blake2")); | ||
const utils_1 = require("./utils"); | ||
const u64 = __importStar(require("./_u64.js")); | ||
const blake2 = __importStar(require("./_blake2.js")); | ||
const utils_js_1 = require("./utils.js"); | ||
// Initial state: | ||
@@ -37,5 +37,5 @@ // first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19) | ||
a = (a + b + x) | 0; | ||
d = (0, utils_1.rotr)(d ^ a, 16); | ||
d = (0, utils_js_1.rotr)(d ^ a, 16); | ||
c = (c + d) | 0; | ||
b = (0, utils_1.rotr)(b ^ c, 12); | ||
b = (0, utils_js_1.rotr)(b ^ c, 12); | ||
return { a, b, c, d }; | ||
@@ -45,5 +45,5 @@ } | ||
a = (a + b + x) | 0; | ||
d = (0, utils_1.rotr)(d ^ a, 8); | ||
d = (0, utils_js_1.rotr)(d ^ a, 8); | ||
c = (c + d) | 0; | ||
b = (0, utils_1.rotr)(b ^ c, 7); | ||
b = (0, utils_js_1.rotr)(b ^ c, 7); | ||
return { a, b, c, d }; | ||
@@ -90,3 +90,3 @@ } | ||
if (opts.salt) { | ||
const salt = (0, utils_1.u32)((0, utils_1.toBytes)(opts.salt)); | ||
const salt = (0, utils_js_1.u32)((0, utils_js_1.toBytes)(opts.salt)); | ||
this.v4 ^= salt[0]; | ||
@@ -96,3 +96,3 @@ this.v5 ^= salt[1]; | ||
if (opts.personalization) { | ||
const pers = (0, utils_1.u32)((0, utils_1.toBytes)(opts.personalization)); | ||
const pers = (0, utils_js_1.u32)((0, utils_js_1.toBytes)(opts.personalization)); | ||
this.v6 ^= pers[0]; | ||
@@ -104,3 +104,3 @@ this.v7 ^= pers[1]; | ||
const tmp = new Uint8Array(this.blockLen); | ||
tmp.set((0, utils_1.toBytes)(opts.key)); | ||
tmp.set((0, utils_js_1.toBytes)(opts.key)); | ||
this.update(tmp); | ||
@@ -143,2 +143,2 @@ } | ||
} | ||
exports.blake2s = (0, utils_1.wrapConstructorWithOpts)((opts) => new BLAKE2s(opts)); | ||
exports.blake2s = (0, utils_js_1.wrapConstructorWithOpts)((opts) => new BLAKE2s(opts)); |
@@ -1,3 +0,3 @@ | ||
import * as blake2 from './_blake2'; | ||
import { Input, HashXOF } from './utils'; | ||
import * as blake2 from './_blake2.js'; | ||
import { Input, HashXOF } from './utils.js'; | ||
export declare type Blake3Opts = { | ||
@@ -39,5 +39,5 @@ dkLen?: number; | ||
blockLen: number; | ||
create(opts: Blake3Opts): import("./utils").Hash<BLAKE3>; | ||
init: (opts: Blake3Opts) => import("./utils").Hash<BLAKE3>; | ||
create(opts: Blake3Opts): import("./utils.js").Hash<BLAKE3>; | ||
init: (opts: Blake3Opts) => import("./utils.js").Hash<BLAKE3>; | ||
}; | ||
export {}; |
@@ -23,6 +23,6 @@ "use strict"; | ||
exports.blake3 = void 0; | ||
const u64 = __importStar(require("./_u64")); | ||
const blake2 = __importStar(require("./_blake2")); | ||
const blake2s = __importStar(require("./blake2s")); | ||
const utils_1 = require("./utils"); | ||
const u64 = __importStar(require("./_u64.js")); | ||
const blake2 = __importStar(require("./_blake2.js")); | ||
const blake2s = __importStar(require("./blake2s.js")); | ||
const utils_js_1 = require("./utils.js"); | ||
// Flag bitset | ||
@@ -68,10 +68,10 @@ var Flags; | ||
this.outputLen = opts.dkLen === undefined ? 32 : opts.dkLen; | ||
(0, utils_1.assertNumber)(this.outputLen); | ||
(0, utils_js_1.assertNumber)(this.outputLen); | ||
if (opts.key !== undefined && opts.context !== undefined) | ||
throw new Error('Blake3: only key or context can be specified at same time'); | ||
else if (opts.key !== undefined) { | ||
const key = (0, utils_1.toBytes)(opts.key); | ||
const key = (0, utils_js_1.toBytes)(opts.key); | ||
if (key.length !== 32) | ||
throw new Error('Blake3: key should be 32 byte'); | ||
this.IV = (0, utils_1.u32)(key); | ||
this.IV = (0, utils_js_1.u32)(key); | ||
this.flags = flags | Flags.KEYED_HASH; | ||
@@ -83,3 +83,3 @@ } | ||
.digest(); | ||
this.IV = (0, utils_1.u32)(context_key); | ||
this.IV = (0, utils_js_1.u32)(context_key); | ||
this.flags = flags | Flags.DERIVE_KEY_MATERIAL; | ||
@@ -92,3 +92,3 @@ } | ||
this.state = this.IV.slice(); | ||
this.bufferOut = (0, utils_1.u8)(this.bufferOut32); | ||
this.bufferOut = (0, utils_js_1.u8)(this.bufferOut32); | ||
} | ||
@@ -242,3 +242,3 @@ // Unused | ||
xof(bytes) { | ||
(0, utils_1.assertNumber)(bytes); | ||
(0, utils_js_1.assertNumber)(bytes); | ||
return this.xofInto(new Uint8Array(bytes)); | ||
@@ -260,2 +260,2 @@ } | ||
} | ||
exports.blake3 = (0, utils_1.wrapConstructorWithOpts)((opts) => new BLAKE3(opts)); | ||
exports.blake3 = (0, utils_js_1.wrapConstructorWithOpts)((opts) => new BLAKE3(opts)); |
@@ -1,2 +0,2 @@ | ||
import { assertNumber, Hash, toBytes, u32 } from './utils'; | ||
import { assertNumber, Hash, toBytes, u32 } from './utils.js'; | ||
// prettier-ignore | ||
@@ -3,0 +3,0 @@ export const SIGMA = new Uint8Array([ |
@@ -1,2 +0,2 @@ | ||
import { Hash, createView, toBytes } from './utils'; | ||
import { Hash, createView, toBytes } from './utils.js'; | ||
// Polyfill for Safari 14 | ||
@@ -3,0 +3,0 @@ function setBigUint64(view, byteOffset, value, isLE) { |
@@ -1,4 +0,4 @@ | ||
import * as blake2 from './_blake2'; | ||
import * as u64 from './_u64'; | ||
import { toBytes, u32, wrapConstructorWithOpts } from './utils'; | ||
import * as blake2 from './_blake2.js'; | ||
import * as u64 from './_u64.js'; | ||
import { toBytes, u32, wrapConstructorWithOpts } from './utils.js'; | ||
// Same as SHA-512 but LE | ||
@@ -5,0 +5,0 @@ // prettier-ignore |
@@ -1,4 +0,4 @@ | ||
import * as u64 from './_u64'; | ||
import * as blake2 from './_blake2'; | ||
import { rotr, toBytes, wrapConstructorWithOpts, u32 } from './utils'; | ||
import * as u64 from './_u64.js'; | ||
import * as blake2 from './_blake2.js'; | ||
import { rotr, toBytes, wrapConstructorWithOpts, u32 } from './utils.js'; | ||
// Initial state: | ||
@@ -5,0 +5,0 @@ // first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19) |
@@ -1,5 +0,5 @@ | ||
import * as u64 from './_u64'; | ||
import * as blake2 from './_blake2'; | ||
import * as blake2s from './blake2s'; | ||
import { u8, u32, toBytes, wrapConstructorWithOpts, assertNumber } from './utils'; | ||
import * as u64 from './_u64.js'; | ||
import * as blake2 from './_blake2.js'; | ||
import * as blake2s from './blake2s.js'; | ||
import { u8, u32, toBytes, wrapConstructorWithOpts, assertNumber, } from './utils.js'; | ||
// Flag bitset | ||
@@ -6,0 +6,0 @@ var Flags; |
// prettier-ignore | ||
import { assertHash, assertNumber, toBytes } from './utils'; | ||
import { hmac } from './hmac'; | ||
import { assertHash, assertNumber, toBytes } from './utils.js'; | ||
import { hmac } from './hmac.js'; | ||
// HKDF (RFC 5869) | ||
@@ -5,0 +5,0 @@ // HKDF-Extract(IKM, salt) -> PRK NOTE: arguments position differs from spec (IKM is first one, since it is not optional) |
@@ -1,2 +0,2 @@ | ||
import { assertHash, Hash, toBytes } from './utils'; | ||
import { assertHash, Hash, toBytes } from './utils.js'; | ||
// HMAC (RFC 2104) | ||
@@ -3,0 +3,0 @@ class HMAC extends Hash { |
@@ -1,4 +0,4 @@ | ||
import { hmac } from './hmac'; | ||
import { hmac } from './hmac.js'; | ||
// prettier-ignore | ||
import { createView, toBytes, assertNumber, assertHash, checkOpts, asyncLoop } from './utils'; | ||
import { createView, toBytes, assertNumber, assertHash, checkOpts, asyncLoop } from './utils.js'; | ||
// Common prologue and epilogue for sync/async functions | ||
@@ -5,0 +5,0 @@ function pbkdf2Init(hash, _password, _salt, _opts) { |
@@ -1,3 +0,3 @@ | ||
import { SHA2 } from './_sha2'; | ||
import { wrapConstructor } from './utils'; | ||
import { SHA2 } from './_sha2.js'; | ||
import { wrapConstructor } from './utils.js'; | ||
// https://homes.esat.kuleuven.be/~bosselae/ripemd160.html | ||
@@ -4,0 +4,0 @@ // https://homes.esat.kuleuven.be/~bosselae/ripemd160/pdf/AB-9601/AB-9601.pdf |
@@ -1,4 +0,4 @@ | ||
import { sha256 } from './sha256'; | ||
import { pbkdf2 } from './pbkdf2'; | ||
import { assertNumber, asyncLoop, checkOpts, u32 } from './utils'; | ||
import { sha256 } from './sha256.js'; | ||
import { pbkdf2 } from './pbkdf2.js'; | ||
import { assertNumber, asyncLoop, checkOpts, u32 } from './utils.js'; | ||
// Left rotate for uint32 | ||
@@ -5,0 +5,0 @@ const rotl = (a, b) => (a << b) | (a >>> (32 - b)); |
@@ -1,3 +0,3 @@ | ||
import { SHA2 } from './_sha2'; | ||
import { rotr, wrapConstructor } from './utils'; | ||
import { SHA2 } from './_sha2.js'; | ||
import { rotr, wrapConstructor } from './utils.js'; | ||
// Choice: a ? b : c | ||
@@ -4,0 +4,0 @@ const Chi = (a, b, c) => (a & b) ^ (~a & c); |
@@ -1,3 +0,3 @@ | ||
import { toBytes, wrapConstructorWithOpts, assertNumber, u32 } from './utils'; | ||
import { Keccak } from './sha3'; | ||
import { toBytes, wrapConstructorWithOpts, assertNumber, u32, } from './utils.js'; | ||
import { Keccak } from './sha3.js'; | ||
// cSHAKE && KMAC (NIST SP800-185) | ||
@@ -4,0 +4,0 @@ function leftEncode(n) { |
@@ -1,3 +0,3 @@ | ||
import * as u64 from './_u64'; | ||
import { Hash, u32, toBytes, wrapConstructor, wrapConstructorWithOpts, assertNumber, } from './utils'; | ||
import * as u64 from './_u64.js'; | ||
import { Hash, u32, toBytes, wrapConstructor, wrapConstructorWithOpts, assertNumber, } from './utils.js'; | ||
// Various per round constants calculations | ||
@@ -4,0 +4,0 @@ const [SHA3_PI, SHA3_ROTL, _SHA3_IOTA] = [[], [], []]; |
@@ -1,4 +0,4 @@ | ||
import { SHA2 } from './_sha2'; | ||
import * as u64 from './_u64'; | ||
import { wrapConstructor } from './utils'; | ||
import { SHA2 } from './_sha2.js'; | ||
import * as u64 from './_u64.js'; | ||
import { wrapConstructor } from './utils.js'; | ||
// Round contants (first 32 bits of the fractional parts of the cube roots of the first 80 primes 2..409): | ||
@@ -5,0 +5,0 @@ // prettier-ignore |
@@ -1,2 +0,2 @@ | ||
import { CHash, Input } from './utils'; | ||
import { CHash, Input } from './utils.js'; | ||
export declare function hkdf_extract(hash: CHash, ikm: Input, salt?: Input): Uint8Array; | ||
@@ -3,0 +3,0 @@ export declare function hkdf_expand(hash: CHash, prk: Input, // a pseudorandom key of at least HashLen octets (usually, the output from the extract step) |
@@ -5,8 +5,8 @@ "use strict"; | ||
// prettier-ignore | ||
const utils_1 = require("./utils"); | ||
const hmac_1 = require("./hmac"); | ||
const utils_js_1 = require("./utils.js"); | ||
const hmac_js_1 = require("./hmac.js"); | ||
// HKDF (RFC 5869) | ||
// HKDF-Extract(IKM, salt) -> PRK NOTE: arguments position differs from spec (IKM is first one, since it is not optional) | ||
function hkdf_extract(hash, ikm, salt) { | ||
(0, utils_1.assertHash)(hash); | ||
(0, utils_js_1.assertHash)(hash); | ||
// NOTE: some libraries treats zero-length array as 'not provided', we don't, since we have undefined as 'not provided' | ||
@@ -16,3 +16,3 @@ // More info: https://github.com/RustCrypto/KDFs/issues/15 | ||
salt = new Uint8Array(hash.outputLen); // if not provided, it is set to a string of HashLen zeros | ||
return (0, hmac_1.hmac)(hash, (0, utils_1.toBytes)(salt), (0, utils_1.toBytes)(ikm)); | ||
return (0, hmac_js_1.hmac)(hash, (0, utils_js_1.toBytes)(salt), (0, utils_js_1.toBytes)(ikm)); | ||
} | ||
@@ -27,4 +27,4 @@ exports.hkdf_extract = hkdf_extract; | ||
) { | ||
(0, utils_1.assertHash)(hash); | ||
(0, utils_1.assertNumber)(length); | ||
(0, utils_js_1.assertHash)(hash); | ||
(0, utils_js_1.assertNumber)(length); | ||
if (length > 255 * hash.outputLen) | ||
@@ -38,3 +38,3 @@ throw new Error('Length should be <= 255*HashLen'); | ||
// Re-use HMAC instance between blocks | ||
const HMAC = hmac_1.hmac.init(hash, prk); | ||
const HMAC = hmac_js_1.hmac.init(hash, prk); | ||
const HMACTmp = HMAC._cloneInto(); | ||
@@ -41,0 +41,0 @@ const T = new Uint8Array(HMAC.outputLen); |
@@ -1,2 +0,2 @@ | ||
import { Hash, CHash, Input } from './utils'; | ||
import { Hash, CHash, Input } from './utils.js'; | ||
declare class HMAC<T extends Hash<T>> extends Hash<HMAC<T>> { | ||
@@ -3,0 +3,0 @@ oHash: T; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.hmac = void 0; | ||
const utils_1 = require("./utils"); | ||
const utils_js_1 = require("./utils.js"); | ||
// HMAC (RFC 2104) | ||
class HMAC extends utils_1.Hash { | ||
class HMAC extends utils_js_1.Hash { | ||
constructor(hash, _key) { | ||
@@ -11,6 +11,6 @@ super(); | ||
this.destroyed = false; | ||
(0, utils_1.assertHash)(hash); | ||
const key = (0, utils_1.toBytes)(_key); | ||
(0, utils_js_1.assertHash)(hash); | ||
const key = (0, utils_js_1.toBytes)(_key); | ||
this.iHash = hash.create(); | ||
if (!(this.iHash instanceof utils_1.Hash)) | ||
if (!(this.iHash instanceof utils_js_1.Hash)) | ||
throw new TypeError('Expected instance of class which extends utils.Hash'); | ||
@@ -17,0 +17,0 @@ const blockLen = (this.blockLen = this.iHash.blockLen); |
@@ -1,2 +0,2 @@ | ||
import { CHash, Input } from './utils'; | ||
import { CHash, Input } from './utils.js'; | ||
export declare type Pbkdf2Opt = { | ||
@@ -3,0 +3,0 @@ c: number; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.pbkdf2Async = exports.pbkdf2 = void 0; | ||
const hmac_1 = require("./hmac"); | ||
const hmac_js_1 = require("./hmac.js"); | ||
// prettier-ignore | ||
const utils_1 = require("./utils"); | ||
const utils_js_1 = require("./utils.js"); | ||
// Common prologue and epilogue for sync/async functions | ||
function pbkdf2Init(hash, _password, _salt, _opts) { | ||
(0, utils_1.assertHash)(hash); | ||
const opts = (0, utils_1.checkOpts)({ dkLen: 32, asyncTick: 10 }, _opts); | ||
(0, utils_js_1.assertHash)(hash); | ||
const opts = (0, utils_js_1.checkOpts)({ dkLen: 32, asyncTick: 10 }, _opts); | ||
const { c, dkLen, asyncTick } = opts; | ||
(0, utils_1.assertNumber)(c); | ||
(0, utils_1.assertNumber)(dkLen); | ||
(0, utils_1.assertNumber)(asyncTick); | ||
(0, utils_js_1.assertNumber)(c); | ||
(0, utils_js_1.assertNumber)(dkLen); | ||
(0, utils_js_1.assertNumber)(asyncTick); | ||
if (c < 1) | ||
throw new Error('PBKDF2: iterations (c) should be >= 1'); | ||
const password = (0, utils_1.toBytes)(_password); | ||
const salt = (0, utils_1.toBytes)(_salt); | ||
const password = (0, utils_js_1.toBytes)(_password); | ||
const salt = (0, utils_js_1.toBytes)(_salt); | ||
// DK = PBKDF2(PRF, Password, Salt, c, dkLen); | ||
const DK = new Uint8Array(dkLen); | ||
// U1 = PRF(Password, Salt + INT_32_BE(i)) | ||
const PRF = hmac_1.hmac.init(hash, password); | ||
const PRF = hmac_js_1.hmac.init(hash, password); | ||
const PRFSalt = PRF._cloneInto().update(salt); | ||
@@ -38,3 +38,3 @@ return { c, dkLen, asyncTick, DK, PRF, PRFSalt }; | ||
const arr = new Uint8Array(4); | ||
const view = (0, utils_1.createView)(arr); | ||
const view = (0, utils_js_1.createView)(arr); | ||
const u = new Uint8Array(PRF.outputLen); | ||
@@ -64,3 +64,3 @@ // DK = T1 + T2 + ⋯ + Tdklen/hlen | ||
const arr = new Uint8Array(4); | ||
const view = (0, utils_1.createView)(arr); | ||
const view = (0, utils_js_1.createView)(arr); | ||
const u = new Uint8Array(PRF.outputLen); | ||
@@ -76,3 +76,3 @@ // DK = T1 + T2 + ⋯ + Tdklen/hlen | ||
Ti.set(u.subarray(0, Ti.length)); | ||
await (0, utils_1.asyncLoop)(c - 1, asyncTick, (i) => { | ||
await (0, utils_js_1.asyncLoop)(c - 1, asyncTick, (i) => { | ||
// Uc = PRF(Password, Uc−1) | ||
@@ -79,0 +79,0 @@ PRF._cloneInto(prfW).update(u).digestInto(u); |
@@ -1,2 +0,2 @@ | ||
import { SHA2 } from './_sha2'; | ||
import { SHA2 } from './_sha2.js'; | ||
export declare class RIPEMD160 extends SHA2<RIPEMD160> { | ||
@@ -16,7 +16,7 @@ private h0; | ||
export declare const ripemd160: { | ||
(message: import("./utils").Input): Uint8Array; | ||
(message: import("./utils.js").Input): Uint8Array; | ||
outputLen: number; | ||
blockLen: number; | ||
create(): import("./utils").Hash<RIPEMD160>; | ||
init: () => import("./utils").Hash<RIPEMD160>; | ||
create(): import("./utils.js").Hash<RIPEMD160>; | ||
init: () => import("./utils.js").Hash<RIPEMD160>; | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ripemd160 = exports.RIPEMD160 = void 0; | ||
const _sha2_1 = require("./_sha2"); | ||
const utils_1 = require("./utils"); | ||
const _sha2_js_1 = require("./_sha2.js"); | ||
const utils_js_1 = require("./utils.js"); | ||
// https://homes.esat.kuleuven.be/~bosselae/ripemd160.html | ||
@@ -44,3 +44,3 @@ // https://homes.esat.kuleuven.be/~bosselae/ripemd160/pdf/AB-9601/AB-9601.pdf | ||
const BUF = new Uint32Array(16); | ||
class RIPEMD160 extends _sha2_1.SHA2 { | ||
class RIPEMD160 extends _sha2_js_1.SHA2 { | ||
constructor() { | ||
@@ -100,2 +100,2 @@ super(64, 20, 8, true); | ||
exports.RIPEMD160 = RIPEMD160; | ||
exports.ripemd160 = (0, utils_1.wrapConstructor)(() => new RIPEMD160()); | ||
exports.ripemd160 = (0, utils_js_1.wrapConstructor)(() => new RIPEMD160()); |
@@ -1,2 +0,2 @@ | ||
import { Input } from './utils'; | ||
import { Input } from './utils.js'; | ||
export declare type ScryptOpts = { | ||
@@ -3,0 +3,0 @@ N: number; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.scryptAsync = exports.scrypt = void 0; | ||
const sha256_1 = require("./sha256"); | ||
const pbkdf2_1 = require("./pbkdf2"); | ||
const utils_1 = require("./utils"); | ||
const sha256_js_1 = require("./sha256.js"); | ||
const pbkdf2_js_1 = require("./pbkdf2.js"); | ||
const utils_js_1 = require("./utils.js"); | ||
// Left rotate for uint32 | ||
@@ -93,3 +93,3 @@ const rotl = (a, b) => (a << b) | (a >>> (32 - b)); | ||
// Maxmem - 1GB+1KB by default | ||
const opts = (0, utils_1.checkOpts)({ | ||
const opts = (0, utils_js_1.checkOpts)({ | ||
dkLen: 32, | ||
@@ -100,8 +100,8 @@ asyncTick: 10, | ||
const { N, r, p, dkLen, asyncTick, maxmem, onProgress } = opts; | ||
(0, utils_1.assertNumber)(N); | ||
(0, utils_1.assertNumber)(r); | ||
(0, utils_1.assertNumber)(p); | ||
(0, utils_1.assertNumber)(dkLen); | ||
(0, utils_1.assertNumber)(asyncTick); | ||
(0, utils_1.assertNumber)(maxmem); | ||
(0, utils_js_1.assertNumber)(N); | ||
(0, utils_js_1.assertNumber)(r); | ||
(0, utils_js_1.assertNumber)(p); | ||
(0, utils_js_1.assertNumber)(dkLen); | ||
(0, utils_js_1.assertNumber)(asyncTick); | ||
(0, utils_js_1.assertNumber)(maxmem); | ||
if (onProgress !== undefined && typeof onProgress !== 'function') | ||
@@ -128,7 +128,7 @@ throw new Error('progressCb should be function'); | ||
// Since it has only one iteration there is no reason to use async variant | ||
const B = (0, pbkdf2_1.pbkdf2)(sha256_1.sha256, password, salt, { c: 1, dkLen: blockSize * p }); | ||
const B32 = (0, utils_1.u32)(B); | ||
const B = (0, pbkdf2_js_1.pbkdf2)(sha256_js_1.sha256, password, salt, { c: 1, dkLen: blockSize * p }); | ||
const B32 = (0, utils_js_1.u32)(B); | ||
// Re-used between parallel iterations. Array(iterations) of B | ||
const V = (0, utils_1.u32)(new Uint8Array(blockSize * N)); | ||
const tmp = (0, utils_1.u32)(new Uint8Array(blockSize)); | ||
const V = (0, utils_js_1.u32)(new Uint8Array(blockSize * N)); | ||
const tmp = (0, utils_js_1.u32)(new Uint8Array(blockSize)); | ||
let blockMixCb = () => { }; | ||
@@ -150,3 +150,3 @@ if (onProgress) { | ||
function scryptOutput(password, dkLen, B, V, tmp) { | ||
const res = (0, pbkdf2_1.pbkdf2)(sha256_1.sha256, password, B, { c: 1, dkLen }); | ||
const res = (0, pbkdf2_js_1.pbkdf2)(sha256_js_1.sha256, password, B, { c: 1, dkLen }); | ||
B.fill(0); | ||
@@ -188,3 +188,3 @@ V.fill(0); | ||
let pos = 0; | ||
await (0, utils_1.asyncLoop)(N - 1, asyncTick, (i) => { | ||
await (0, utils_js_1.asyncLoop)(N - 1, asyncTick, (i) => { | ||
BlockMix(V, pos, V, (pos += blockSize32), r); // V[i] = BlockMix(V[i-1]); | ||
@@ -195,3 +195,3 @@ blockMixCb(); | ||
blockMixCb(); | ||
await (0, utils_1.asyncLoop)(N, asyncTick, (i) => { | ||
await (0, utils_js_1.asyncLoop)(N, asyncTick, (i) => { | ||
// First u32 of the last 64-byte block (u32 is LE) | ||
@@ -198,0 +198,0 @@ const j = B32[Pi + blockSize32 - 16] % N; // j = Integrify(X) % iterations |
@@ -1,2 +0,2 @@ | ||
import { SHA2 } from './_sha2'; | ||
import { SHA2 } from './_sha2.js'; | ||
declare class SHA256 extends SHA2<SHA256> { | ||
@@ -19,8 +19,8 @@ private A; | ||
export declare const sha256: { | ||
(message: import("./utils").Input): Uint8Array; | ||
(message: import("./utils.js").Input): Uint8Array; | ||
outputLen: number; | ||
blockLen: number; | ||
create(): import("./utils").Hash<SHA256>; | ||
init: () => import("./utils").Hash<SHA256>; | ||
create(): import("./utils.js").Hash<SHA256>; | ||
init: () => import("./utils.js").Hash<SHA256>; | ||
}; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.sha256 = void 0; | ||
const _sha2_1 = require("./_sha2"); | ||
const utils_1 = require("./utils"); | ||
const _sha2_js_1 = require("./_sha2.js"); | ||
const utils_js_1 = require("./utils.js"); | ||
// Choice: a ? b : c | ||
@@ -31,3 +31,3 @@ const Chi = (a, b, c) => (a & b) ^ (~a & c); | ||
const SHA256_W = new Uint32Array(64); | ||
class SHA256 extends _sha2_1.SHA2 { | ||
class SHA256 extends _sha2_js_1.SHA2 { | ||
constructor() { | ||
@@ -68,4 +68,4 @@ super(64, 32, 8, false); | ||
const W2 = SHA256_W[i - 2]; | ||
const s0 = (0, utils_1.rotr)(W15, 7) ^ (0, utils_1.rotr)(W15, 18) ^ (W15 >>> 3); | ||
const s1 = (0, utils_1.rotr)(W2, 17) ^ (0, utils_1.rotr)(W2, 19) ^ (W2 >>> 10); | ||
const s0 = (0, utils_js_1.rotr)(W15, 7) ^ (0, utils_js_1.rotr)(W15, 18) ^ (W15 >>> 3); | ||
const s1 = (0, utils_js_1.rotr)(W2, 17) ^ (0, utils_js_1.rotr)(W2, 19) ^ (W2 >>> 10); | ||
SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0; | ||
@@ -76,5 +76,5 @@ } | ||
for (let i = 0; i < 64; i++) { | ||
const sigma1 = (0, utils_1.rotr)(E, 6) ^ (0, utils_1.rotr)(E, 11) ^ (0, utils_1.rotr)(E, 25); | ||
const sigma1 = (0, utils_js_1.rotr)(E, 6) ^ (0, utils_js_1.rotr)(E, 11) ^ (0, utils_js_1.rotr)(E, 25); | ||
const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0; | ||
const sigma0 = (0, utils_1.rotr)(A, 2) ^ (0, utils_1.rotr)(A, 13) ^ (0, utils_1.rotr)(A, 22); | ||
const sigma0 = (0, utils_js_1.rotr)(A, 2) ^ (0, utils_js_1.rotr)(A, 13) ^ (0, utils_js_1.rotr)(A, 22); | ||
const T2 = (sigma0 + Maj(A, B, C)) | 0; | ||
@@ -109,2 +109,2 @@ H = G; | ||
} | ||
exports.sha256 = (0, utils_1.wrapConstructor)(() => new SHA256()); | ||
exports.sha256 = (0, utils_js_1.wrapConstructor)(() => new SHA256()); |
@@ -1,3 +0,3 @@ | ||
import { Input, Hash, HashXOF } from './utils'; | ||
import { Keccak, ShakeOpts } from './sha3'; | ||
import { Input, Hash, HashXOF } from './utils.js'; | ||
import { Keccak, ShakeOpts } from './sha3.js'; | ||
export declare type cShakeOpts = ShakeOpts & { | ||
@@ -4,0 +4,0 @@ personalization?: Input; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.keccakprg = exports.m14 = exports.k12 = exports.parallelhash256xof = exports.parallelhash128xof = exports.parallelhash256 = exports.parallelhash128 = exports.tuplehash256xof = exports.tuplehash128xof = exports.tuplehash256 = exports.tuplehash128 = exports.kmac256xof = exports.kmac128xof = exports.kmac256 = exports.kmac128 = exports.cshake256 = exports.cshake128 = void 0; | ||
const utils_1 = require("./utils"); | ||
const sha3_1 = require("./sha3"); | ||
const utils_js_1 = require("./utils.js"); | ||
const sha3_js_1 = require("./sha3.js"); | ||
// cSHAKE && KMAC (NIST SP800-185) | ||
@@ -23,3 +23,3 @@ function leftEncode(n) { | ||
} | ||
const toBytesOptional = (buf) => (buf !== undefined ? (0, utils_1.toBytes)(buf) : new Uint8Array([])); | ||
const toBytesOptional = (buf) => (buf !== undefined ? (0, utils_js_1.toBytes)(buf) : new Uint8Array([])); | ||
// NOTE: second modulo is necessary since we don't need to add padding if current element takes whole block | ||
@@ -46,10 +46,10 @@ const getPadding = (len, block) => new Uint8Array((block - (len % block)) % block); | ||
} | ||
const gencShake = (suffix, blockLen, outputLen) => (0, utils_1.wrapConstructorWithOpts)((opts = {}) => cshakePers(new sha3_1.Keccak(blockLen, suffix, opts.dkLen !== undefined ? opts.dkLen : outputLen, true), opts)); | ||
const gencShake = (suffix, blockLen, outputLen) => (0, utils_js_1.wrapConstructorWithOpts)((opts = {}) => cshakePers(new sha3_js_1.Keccak(blockLen, suffix, opts.dkLen !== undefined ? opts.dkLen : outputLen, true), opts)); | ||
exports.cshake128 = gencShake(0x1f, 168, 128 / 8); | ||
exports.cshake256 = gencShake(0x1f, 136, 256 / 8); | ||
class KMAC extends sha3_1.Keccak { | ||
class KMAC extends sha3_js_1.Keccak { | ||
constructor(blockLen, outputLen, enableXOF, key, opts = {}) { | ||
super(blockLen, 0x1f, outputLen, enableXOF); | ||
cshakePers(this, { NISTfn: 'KMAC', personalization: opts.personalization }); | ||
key = (0, utils_1.toBytes)(key); | ||
key = (0, utils_js_1.toBytes)(key); | ||
// 1. newX = bytepad(encode_string(K), 168) || X || right_encode(L). | ||
@@ -74,3 +74,3 @@ const blockLenBytes = leftEncode(this.blockLen); | ||
to.blockLen = this.blockLen; | ||
to.state32 = (0, utils_1.u32)(to.state); | ||
to.state32 = (0, utils_js_1.u32)(to.state); | ||
} | ||
@@ -95,3 +95,3 @@ return super._cloneInto(to); | ||
// Usage: tuple(['ab', 'cd']) != tuple(['a', 'bcd']) | ||
class TupleHash extends sha3_1.Keccak { | ||
class TupleHash extends sha3_js_1.Keccak { | ||
constructor(blockLen, outputLen, enableXOF, opts = {}) { | ||
@@ -102,3 +102,3 @@ super(blockLen, 0x1f, outputLen, enableXOF); | ||
this.update = (data) => { | ||
data = (0, utils_1.toBytes)(data); | ||
data = (0, utils_js_1.toBytes)(data); | ||
super.update(leftEncode(data.length * 8)); | ||
@@ -137,3 +137,3 @@ super.update(data); | ||
exports.tuplehash256xof = genTuple(136, 256 / 8, true); | ||
class ParallelHash extends sha3_1.Keccak { | ||
class ParallelHash extends sha3_js_1.Keccak { | ||
constructor(blockLen, outputLen, leafCons, enableXOF, opts = {}) { | ||
@@ -147,3 +147,3 @@ super(blockLen, 0x1f, outputLen, enableXOF); | ||
B || (B = 8); | ||
(0, utils_1.assertNumber)(B); | ||
(0, utils_js_1.assertNumber)(B); | ||
this.chunkLen = B; | ||
@@ -153,3 +153,3 @@ super.update(leftEncode(B)); | ||
this.update = (data) => { | ||
data = (0, utils_1.toBytes)(data); | ||
data = (0, utils_js_1.toBytes)(data); | ||
const { chunkLen, leafCons } = this; | ||
@@ -222,3 +222,3 @@ for (let pos = 0, len = data.length; pos < len;) { | ||
const EMPTY = new Uint8Array([]); | ||
class KangarooTwelve extends sha3_1.Keccak { | ||
class KangarooTwelve extends sha3_js_1.Keccak { | ||
constructor(blockLen, leafLen, outputLen, rounds, opts) { | ||
@@ -234,3 +234,3 @@ super(blockLen, 0x07, outputLen, true, rounds); | ||
update(data) { | ||
data = (0, utils_1.toBytes)(data); | ||
data = (0, utils_js_1.toBytes)(data); | ||
const { chunkLen, blockLen, leafLen, rounds } = this; | ||
@@ -245,3 +245,3 @@ for (let pos = 0, len = data.length; pos < len;) { | ||
} | ||
this.leafHash = new sha3_1.Keccak(blockLen, 0x0b, leafLen, false, rounds); | ||
this.leafHash = new sha3_js_1.Keccak(blockLen, 0x0b, leafLen, false, rounds); | ||
this.chunksDone++; | ||
@@ -298,10 +298,10 @@ this.chunkPos = 0; | ||
// Default to 32 bytes, so it can be used without opts | ||
exports.k12 = (0, utils_1.wrapConstructorWithOpts)((opts = {}) => new KangarooTwelve(168, 32, opts.dkLen !== undefined ? opts.dkLen : 32, 12, opts)); | ||
exports.k12 = (0, utils_js_1.wrapConstructorWithOpts)((opts = {}) => new KangarooTwelve(168, 32, opts.dkLen !== undefined ? opts.dkLen : 32, 12, opts)); | ||
// MarsupilamiFourteen | ||
exports.m14 = (0, utils_1.wrapConstructorWithOpts)((opts = {}) => new KangarooTwelve(136, 64, opts.dkLen !== undefined ? opts.dkLen : 64, 14, opts)); | ||
exports.m14 = (0, utils_js_1.wrapConstructorWithOpts)((opts = {}) => new KangarooTwelve(136, 64, opts.dkLen !== undefined ? opts.dkLen : 64, 14, opts)); | ||
// https://keccak.team/files/CSF-0.1.pdf | ||
// + https://github.com/XKCP/XKCP/tree/master/lib/high/Keccak/PRG | ||
class KeccakPRG extends sha3_1.Keccak { | ||
class KeccakPRG extends sha3_js_1.Keccak { | ||
constructor(capacity) { | ||
(0, utils_1.assertNumber)(capacity); | ||
(0, utils_js_1.assertNumber)(capacity); | ||
// Rho should be full bytes | ||
@@ -308,0 +308,0 @@ if (capacity < 0 || capacity > 1600 - 10 || (1600 - capacity - 2) % 8) |
@@ -1,2 +0,2 @@ | ||
import { Hash, Input, HashXOF } from './utils'; | ||
import { Hash, Input, HashXOF } from './utils.js'; | ||
export declare function keccakP(s: Uint32Array, rounds?: number): void; | ||
@@ -3,0 +3,0 @@ export declare class Keccak extends Hash<Keccak> implements HashXOF<Keccak> { |
@@ -23,4 +23,4 @@ "use strict"; | ||
exports.shake256 = exports.shake128 = exports.keccak_512 = exports.keccak_384 = exports.keccak_256 = exports.keccak_224 = exports.sha3_512 = exports.sha3_384 = exports.sha3_256 = exports.sha3_224 = exports.Keccak = exports.keccakP = void 0; | ||
const u64 = __importStar(require("./_u64")); | ||
const utils_1 = require("./utils"); | ||
const u64 = __importStar(require("./_u64.js")); | ||
const utils_js_1 = require("./utils.js"); | ||
// Various per round constants calculations | ||
@@ -100,3 +100,3 @@ const [SHA3_PI, SHA3_ROTL, _SHA3_IOTA] = [[], [], []]; | ||
exports.keccakP = keccakP; | ||
class Keccak extends utils_1.Hash { | ||
class Keccak extends utils_js_1.Hash { | ||
// NOTE: we accept arguments in bytes instead of bits here. | ||
@@ -115,3 +115,3 @@ constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) { | ||
// Can be passed from user as dkLen | ||
(0, utils_1.assertNumber)(outputLen); | ||
(0, utils_js_1.assertNumber)(outputLen); | ||
// 1600 = 5x5 matrix of 64bit. 1600 bits === 200 bytes | ||
@@ -121,3 +121,3 @@ if (0 >= this.blockLen || this.blockLen >= 200) | ||
this.state = new Uint8Array(200); | ||
this.state32 = (0, utils_1.u32)(this.state); | ||
this.state32 = (0, utils_js_1.u32)(this.state); | ||
} | ||
@@ -135,3 +135,3 @@ keccak() { | ||
const { blockLen, state } = this; | ||
data = (0, utils_1.toBytes)(data); | ||
data = (0, utils_js_1.toBytes)(data); | ||
const len = data.length; | ||
@@ -182,3 +182,3 @@ for (let pos = 0; pos < len;) { | ||
xof(bytes) { | ||
(0, utils_1.assertNumber)(bytes); | ||
(0, utils_js_1.assertNumber)(bytes); | ||
return this.xofInto(new Uint8Array(bytes)); | ||
@@ -220,3 +220,3 @@ } | ||
exports.Keccak = Keccak; | ||
const gen = (suffix, blockLen, outputLen) => (0, utils_1.wrapConstructor)(() => new Keccak(blockLen, suffix, outputLen)); | ||
const gen = (suffix, blockLen, outputLen) => (0, utils_js_1.wrapConstructor)(() => new Keccak(blockLen, suffix, outputLen)); | ||
exports.sha3_224 = gen(0x06, 144, 224 / 8); | ||
@@ -230,4 +230,4 @@ exports.sha3_256 = gen(0x06, 136, 256 / 8); | ||
exports.keccak_512 = gen(0x01, 72, 512 / 8); | ||
const genShake = (suffix, blockLen, outputLen) => (0, utils_1.wrapConstructorWithOpts)((opts = {}) => new Keccak(blockLen, suffix, opts.dkLen !== undefined ? opts.dkLen : outputLen, true)); | ||
const genShake = (suffix, blockLen, outputLen) => (0, utils_js_1.wrapConstructorWithOpts)((opts = {}) => new Keccak(blockLen, suffix, opts.dkLen !== undefined ? opts.dkLen : outputLen, true)); | ||
exports.shake128 = genShake(0x1f, 168, 128 / 8); | ||
exports.shake256 = genShake(0x1f, 136, 256 / 8); |
@@ -1,2 +0,2 @@ | ||
import { SHA2 } from './_sha2'; | ||
import { SHA2 } from './_sha2.js'; | ||
export declare class SHA512 extends SHA2<SHA512> { | ||
@@ -44,21 +44,21 @@ Ah: number; | ||
export declare const sha512: { | ||
(message: import("./utils").Input): Uint8Array; | ||
(message: import("./utils.js").Input): Uint8Array; | ||
outputLen: number; | ||
blockLen: number; | ||
create(): import("./utils").Hash<SHA512>; | ||
init: () => import("./utils").Hash<SHA512>; | ||
create(): import("./utils.js").Hash<SHA512>; | ||
init: () => import("./utils.js").Hash<SHA512>; | ||
}; | ||
export declare const sha512_256: { | ||
(message: import("./utils").Input): Uint8Array; | ||
(message: import("./utils.js").Input): Uint8Array; | ||
outputLen: number; | ||
blockLen: number; | ||
create(): import("./utils").Hash<SHA512>; | ||
init: () => import("./utils").Hash<SHA512>; | ||
create(): import("./utils.js").Hash<SHA512>; | ||
init: () => import("./utils.js").Hash<SHA512>; | ||
}; | ||
export declare const sha384: { | ||
(message: import("./utils").Input): Uint8Array; | ||
(message: import("./utils.js").Input): Uint8Array; | ||
outputLen: number; | ||
blockLen: number; | ||
create(): import("./utils").Hash<SHA512>; | ||
init: () => import("./utils").Hash<SHA512>; | ||
create(): import("./utils.js").Hash<SHA512>; | ||
init: () => import("./utils.js").Hash<SHA512>; | ||
}; |
@@ -23,5 +23,5 @@ "use strict"; | ||
exports.sha384 = exports.sha512_256 = exports.sha512 = exports.SHA512 = void 0; | ||
const _sha2_1 = require("./_sha2"); | ||
const u64 = __importStar(require("./_u64")); | ||
const utils_1 = require("./utils"); | ||
const _sha2_js_1 = require("./_sha2.js"); | ||
const u64 = __importStar(require("./_u64.js")); | ||
const utils_js_1 = require("./utils.js"); | ||
// Round contants (first 32 bits of the fractional parts of the cube roots of the first 80 primes 2..409): | ||
@@ -54,3 +54,3 @@ // prettier-ignore | ||
const SHA512_W_L = new Uint32Array(80); | ||
class SHA512 extends _sha2_1.SHA2 { | ||
class SHA512 extends _sha2_js_1.SHA2 { | ||
constructor() { | ||
@@ -229,4 +229,4 @@ super(128, 64, 16, false); | ||
} | ||
exports.sha512 = (0, utils_1.wrapConstructor)(() => new SHA512()); | ||
exports.sha512_256 = (0, utils_1.wrapConstructor)(() => new SHA512_256()); | ||
exports.sha384 = (0, utils_1.wrapConstructor)(() => new SHA384()); | ||
exports.sha512 = (0, utils_js_1.wrapConstructor)(() => new SHA512()); | ||
exports.sha512_256 = (0, utils_js_1.wrapConstructor)(() => new SHA512_256()); | ||
exports.sha384 = (0, utils_js_1.wrapConstructor)(() => new SHA384()); |
{ | ||
"name": "@noble/hashes", | ||
"version": "0.4.3", | ||
"version": "0.4.4", | ||
"description": "Fast 0-dependency JS implementation of SHA2, SHA3, RIPEMD, BLAKE2/3, HMAC, HKDF, PBKDF2, Scrypt", | ||
@@ -17,3 +17,4 @@ "directories": { | ||
"build-release": "rollup -c rollup.config.js", | ||
"lint": "prettier --print-width 100 --single-quote --check src", | ||
"lint": "prettier --check 'src/**/*.{js,ts}' 'test/**/*.{js,ts}'", | ||
"format": "prettier --write 'src/**/*.{js,ts}' 'test/**/*.{js,ts}'", | ||
"test": "node test/index.js", | ||
@@ -20,0 +21,0 @@ "test-dos": "node test/slow-dos.test.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
246755
61