Socket
Socket
Sign inDemoInstall

@noble/hashes

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@noble/hashes - npm Package Compare versions

Comparing version 1.1.5 to 1.2.0

_assert.js.map

1

_assert.js

@@ -52,1 +52,2 @@ "use strict";

exports.default = assert;
//# sourceMappingURL=_assert.js.map

@@ -109,1 +109,2 @@ "use strict";

exports.BLAKE2 = BLAKE2;
//# sourceMappingURL=_blake2.js.map

@@ -118,1 +118,2 @@ "use strict";

exports.SHA2 = SHA2;
//# sourceMappingURL=_sha2.js.map

@@ -68,1 +68,2 @@ "use strict";

exports.default = u64;
//# sourceMappingURL=_u64.js.map

@@ -192,1 +192,2 @@ "use strict";

exports.blake2b = (0, utils_js_1.wrapConstructorWithOpts)((opts) => new BLAKE2b(opts));
//# sourceMappingURL=blake2b.js.map

@@ -124,1 +124,2 @@ "use strict";

exports.blake2s = (0, utils_js_1.wrapConstructorWithOpts)((opts) => new BLAKE2s(opts));
//# sourceMappingURL=blake2s.js.map

@@ -240,1 +240,2 @@ "use strict";

exports.blake3 = (0, utils_js_1.wrapConstructorWithOpts)((opts) => new BLAKE3(opts));
//# sourceMappingURL=blake3.js.map

@@ -9,1 +9,2 @@ "use strict";

};
//# sourceMappingURL=crypto.js.map

@@ -8,1 +8,2 @@ "use strict";

};
//# sourceMappingURL=cryptoBrowser.js.map

11

eskdf.js

@@ -10,3 +10,5 @@ "use strict";

const utils_js_1 = require("./utils.js");
// A tiny KDF for various applications like AES key-gen
// A tiny KDF for various applications like AES key-gen.
// Uses HKDF in a non-standard way, so it's not "KDF-secure", only "PRF-secure".
// Which is good enough: assume sha2-256 retained preimage resistance.
const SCRYPT_FACTOR = 2 ** 19;

@@ -142,6 +144,4 @@ const PBKDF2_FACTOR = 2 ** 17;

(0, _assert_js_1.bytes)(seed, 32);
// Validates protocol & accountId
const { salt, info } = getSaltInfo(protocol, accountId);
// Validates options
const keyLength = getKeyLength(options);
const { salt, info } = getSaltInfo(protocol, accountId); // validate protocol & accountId
const keyLength = getKeyLength(options); // validate options
const key = (0, hkdf_js_1.hkdf)(sha256_js_1.sha256, seed, salt, info, keyLength);

@@ -164,1 +164,2 @@ // Modulus has already been validated

exports.eskdf = eskdf;
//# sourceMappingURL=eskdf.js.map

@@ -43,1 +43,2 @@ export function number(n) {

export default assert;
//# sourceMappingURL=_assert.js.map

@@ -105,1 +105,2 @@ import assert from './_assert.js';

}
//# sourceMappingURL=_blake2.js.map

@@ -114,1 +114,2 @@ import assert from './_assert.js';

}
//# sourceMappingURL=_sha2.js.map

@@ -61,1 +61,2 @@ const U32_MASK64 = BigInt(2 ** 32 - 1);

export default u64;
//# sourceMappingURL=_u64.js.map

@@ -189,1 +189,2 @@ import { BLAKE2, SIGMA } from './_blake2.js';

export const blake2b = wrapConstructorWithOpts((opts) => new BLAKE2b(opts));
//# sourceMappingURL=blake2b.js.map

@@ -120,1 +120,2 @@ import { BLAKE2, SIGMA } from './_blake2.js';

export const blake2s = wrapConstructorWithOpts((opts) => new BLAKE2s(opts));
//# sourceMappingURL=blake2s.js.map

@@ -237,1 +237,2 @@ import assert from './_assert.js';

export const blake3 = wrapConstructorWithOpts((opts) => new BLAKE3(opts));
//# sourceMappingURL=blake3.js.map

@@ -6,1 +6,2 @@ import * as nodeCrypto from 'crypto';

};
//# sourceMappingURL=crypto.js.map

@@ -5,1 +5,2 @@ export const crypto = {

};
//# sourceMappingURL=cryptoBrowser.js.map

@@ -7,3 +7,5 @@ import { bytes as assertBytes } from './_assert.js';

import { bytesToHex, createView, hexToBytes, toBytes } from './utils.js';
// A tiny KDF for various applications like AES key-gen
// A tiny KDF for various applications like AES key-gen.
// Uses HKDF in a non-standard way, so it's not "KDF-secure", only "PRF-secure".
// Which is good enough: assume sha2-256 retained preimage resistance.
const SCRYPT_FACTOR = 2 ** 19;

@@ -136,6 +138,4 @@ const PBKDF2_FACTOR = 2 ** 17;

assertBytes(seed, 32);
// Validates protocol & accountId
const { salt, info } = getSaltInfo(protocol, accountId);
// Validates options
const keyLength = getKeyLength(options);
const { salt, info } = getSaltInfo(protocol, accountId); // validate protocol & accountId
const keyLength = getKeyLength(options); // validate options
const key = hkdf(sha256, seed, salt, info, keyLength);

@@ -157,1 +157,2 @@ // Modulus has already been validated

}
//# sourceMappingURL=eskdf.js.map

@@ -72,1 +72,2 @@ import assert from './_assert.js';

export const hkdf = (hash, ikm, salt, info, length) => expand(hash, extract(hash, ikm, salt), info, length);
//# sourceMappingURL=hkdf.js.map

@@ -77,1 +77,2 @@ import assert from './_assert.js';

hmac.create = (hash, key) => new HMAC(hash, key);
//# sourceMappingURL=hmac.js.map
"use strict";
throw new Error('noble-hashes have no entry-point: consult README for usage');
//# sourceMappingURL=index.js.map

@@ -86,1 +86,2 @@ import assert from './_assert.js';

}
//# sourceMappingURL=pbkdf2.js.map

@@ -100,1 +100,2 @@ import { SHA2 } from './_sha2.js';

export const ripemd160 = wrapConstructor(() => new RIPEMD160());
//# sourceMappingURL=ripemd160.js.map

@@ -218,1 +218,2 @@ import assert from './_assert.js';

}
//# sourceMappingURL=scrypt.js.map
import { SHA2 } from './_sha2.js';
import { wrapConstructor } from './utils.js';
// SHA1 was cryptographically broken, however, it was not broken for cases like HMAC.
// Don't use it for a new protocol.
// SHA1 was cryptographically broken.
// It is still widely used in legacy apps. Don't use it for a new protocol.
// RFC 3174

@@ -85,1 +85,2 @@ const rotl = (word, shift) => (word << shift) | ((word >>> (32 - shift)) >>> 0);

export const sha1 = wrapConstructor(() => new SHA1());
//# sourceMappingURL=sha1.js.map

@@ -124,1 +124,2 @@ import { SHA2 } from './_sha2.js';

export const sha224 = wrapConstructor(() => new SHA224());
//# sourceMappingURL=sha256.js.map

@@ -1,2 +0,2 @@

import { number as assertNumber } from './_assert';
import { number as assertNumber } from './_assert.js';
import { toBytes, wrapConstructorWithOpts, u32 } from './utils.js';

@@ -347,1 +347,2 @@ import { Keccak } from './sha3.js';

export const keccakprg = (capacity = 254) => new KeccakPRG(capacity);
//# sourceMappingURL=sha3-addons.js.map

@@ -206,1 +206,2 @@ import assert from './_assert.js';

export const shake256 = genShake(0x1f, 136, 256 / 8);
//# sourceMappingURL=sha3.js.map

@@ -231,1 +231,2 @@ import { SHA2 } from './_sha2.js';

export const sha384 = wrapConstructor(() => new SHA384());
//# sourceMappingURL=sha512.js.map

@@ -143,1 +143,2 @@ /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */

}
//# sourceMappingURL=utils.js.map

@@ -78,1 +78,2 @@ "use strict";

exports.hkdf = hkdf;
//# sourceMappingURL=hkdf.js.map

@@ -81,1 +81,2 @@ "use strict";

exports.hmac.create = (hash, key) => new HMAC(hash, key);
//# sourceMappingURL=hmac.js.map
"use strict";
throw new Error('noble-hashes have no entry-point: consult README for usage');
//# sourceMappingURL=index.js.map
{
"name": "@noble/hashes",
"version": "1.1.5",
"version": "1.2.0",
"description": "Audited & minimal 0-dependency JS implementation of SHA2, SHA3, RIPEMD, BLAKE2/3, HMAC, HKDF, PBKDF2, Scrypt",

@@ -8,5 +8,5 @@ "files": [

"/*.d.ts",
"/*.js.map",
"esm",
"!rollup.config.js",
"!rollup.js"
"src/*.ts"
],

@@ -17,5 +17,5 @@ "scripts": {

"bench:install": "cd test/benchmark && npm install && cd ../../",
"build": "tsc && tsc -p tsconfig.esm.json",
"build:release": "rollup -c rollup.config.js",
"build:clean": "rm *.d.ts *.js",
"build": "npm run build:clean; tsc && tsc -p tsconfig.esm.json",
"build:release": "rollup -c build/rollup.config.js",
"build:clean": "rm *.{js,d.ts,js.map} esm/*.{js,js.map}",
"lint": "prettier --check 'src/**/*.{js,ts}' 'test/**/*.{js,ts}'",

@@ -71,2 +71,7 @@ "format": "prettier --write 'src/**/*.{js,ts}' 'test/**/*.{js,ts}'",

},
"./argon2": {
"types": "./argon2.d.ts",
"import": "./esm/argon2.js",
"default": "./argon2.js"
},
"./blake2b": {

@@ -73,0 +78,0 @@ "types": "./blake2b.d.ts",

@@ -91,1 +91,2 @@ "use strict";

exports.pbkdf2Async = pbkdf2Async;
//# sourceMappingURL=pbkdf2.js.map

@@ -7,3 +7,3 @@ # noble-hashes ![Node CI](https://github.com/paulmillr/noble-hashes/workflows/Node%20CI/badge.svg) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

- 🔒 [**Audited**](#security) by an independent security firm: no vulnerabilities have been found
- 🔻 Helps JS bundlers with lack of entry point, ensures small size of your app
- 🔻 Tree-shaking-friendly: there is no entry point, which ensures small size of your app
- 🔁 No unrolled loops: makes it easier to verify and reduces source code size up to 5x

@@ -15,3 +15,3 @@ - 🏎 Ultra-fast, hand-optimized for caveats of JS engines

- 🦘 SHA3 supports Keccak, TupleHash, KangarooTwelve and MarsupilamiFourteen
- 🪶 Just 2.3k lines / 14KB gzipped. SHA256-only is 240 lines / 3KB gzipped
- 🪶 Just 3.4k lines / 17KB gzipped. SHA256-only is 240 lines / 3KB gzipped

@@ -29,5 +29,5 @@ The library's initial development was funded by [Ethereum Foundation](https://ethereum.org/).

- Check out [homepage](https://paulmillr.com/noble/) & all libraries:
[secp256k1](https://github.com/paulmillr/noble-secp256k1),
[curves](https://github.com/paulmillr/noble-curves) ([secp256k1](https://github.com/paulmillr/noble-secp256k1),
[ed25519](https://github.com/paulmillr/noble-ed25519),
[bls12-381](https://github.com/paulmillr/noble-bls12-381),
[bls12-381](https://github.com/paulmillr/noble-bls12-381)),
[hashes](https://github.com/paulmillr/noble-hashes)

@@ -47,38 +47,34 @@

import { sha256 } from '@noble/hashes/sha256';
console.log(sha256(new Uint8Array([1, 2, 3])));
// Uint8Array(32) [3, 144, 88, 198, 242, 192, 203, 73, ...]
console.log(sha256(new Uint8Array([1, 2, 3]))); // Uint8Array(32) [3, 144, 88, 198, 242...]
// you could also pass strings that will be UTF8-encoded to Uint8Array
console.log(sha256('abc'))); // == sha256(new TextEncoder().encode('abc'))
console.log(sha256('abc')); // == sha256(new TextEncoder().encode('abc'))
// sha384 is here, because it uses same internals as sha512
const { sha512, sha512_256, sha384 } = require('@noble/hashes/sha512');
import { sha512, sha512_256, sha384 } from '@noble/hashes/sha512';
// prettier-ignore
const {
import {
sha3_224, sha3_256, sha3_384, sha3_512,
keccak_224, keccak_256, keccak_384, keccak_512,
shake128, shake256
} = require('@noble/hashes/sha3');
} from '@noble/hashes/sha3';
// prettier-ignore
const {
import {
cshake128, cshake256, kmac128, kmac256,
k12, m14,
tuplehash256, parallelhash256, keccakprg
} = require('@noble/hashes/sha3-addons');
const { ripemd160 } = require('@noble/hashes/ripemd160');
const { blake3 } = require('@noble/hashes/blake3');
const { blake2b } = require('@noble/hashes/blake2b');
const { blake2s } = require('@noble/hashes/blake2s');
const { hmac } = require('@noble/hashes/hmac');
const { hkdf } = require('@noble/hashes/hkdf');
const { pbkdf2, pbkdf2Async } = require('@noble/hashes/pbkdf2');
const { scrypt, scryptAsync } = require('@noble/hashes/scrypt');
} from '@noble/hashes/sha3-addons';
import { ripemd160 } from '@noble/hashes/ripemd160';
import { blake3 } from '@noble/hashes/blake3';
import { blake2b } from '@noble/hashes/blake2b';
import { blake2s } from '@noble/hashes/blake2s';
import { hmac } from '@noble/hashes/hmac';
import { hkdf } from '@noble/hashes/hkdf';
import { pbkdf2, pbkdf2Async } from '@noble/hashes/pbkdf2';
import { scrypt, scryptAsync } from '@noble/hashes/scrypt';
// legacy, still relevant for HMAC
const { sha1 } = require('@noble/hashes/sha1');
import { sha1 } from '@noble/hashes/sha1'; // legacy
// small utility method that converts bytes to hex
const { bytesToHex as toHex } = require('@noble/hashes/utils');
console.log(toHex(sha256('abc')));
// ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
import { bytesToHex as toHex } from '@noble/hashes/utils';
console.log(toHex(sha256('abc'))); // ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
```

@@ -370,2 +366,13 @@

##### Argon2
There's experimental argon2 RFC 9106 implementation. It may be removed at any time.
```ts
import { argon2d, argon2i, argon2id } from '@noble/hashes/scrypt';
const password = 'password';
const salt = 'salt';
const result = argon2id(password, salt, { t: 2, m: 65536, p: 1 });
```
##### ESKDF

@@ -395,5 +402,5 @@

console.log(kdf.fingerprint);
const key = kdf.deriveChildKey('aes', 0);
const key = kdf.deriveChildKey('aes', 0, { keyLength: 16 });
const ecc = kdf.deriveChildKey('ecc', 0, { modulus: 2n ** 252n - 27742317777372353535851937790883648493n })
const key1 = kdf.deriveChildKey('aes', 0);
const key2 = kdf.deriveChildKey('aes', 0, { keyLength: 16 });
const ecc1 = kdf.deriveChildKey('ecc', 0, { modulus: 2n ** 252n - 27742317777372353535851937790883648493n })
kdf.expire();

@@ -482,3 +489,3 @@ ```

1. Clone the repository.
1. Clone the repository
2. `npm install` to install build dependencies like TypeScript

@@ -485,0 +492,0 @@ 3. `npm run build` to compile TypeScript code

@@ -104,1 +104,2 @@ "use strict";

exports.ripemd160 = (0, utils_js_1.wrapConstructor)(() => new RIPEMD160());
//# sourceMappingURL=ripemd160.js.map

@@ -223,1 +223,2 @@ "use strict";

exports.scryptAsync = scryptAsync;
//# sourceMappingURL=scrypt.js.map

@@ -6,4 +6,4 @@ "use strict";

const utils_js_1 = require("./utils.js");
// SHA1 was cryptographically broken, however, it was not broken for cases like HMAC.
// Don't use it for a new protocol.
// SHA1 was cryptographically broken.
// It is still widely used in legacy apps. Don't use it for a new protocol.
// RFC 3174

@@ -89,1 +89,2 @@ const rotl = (word, shift) => (word << shift) | ((word >>> (32 - shift)) >>> 0);

exports.sha1 = (0, utils_js_1.wrapConstructor)(() => new SHA1());
//# sourceMappingURL=sha1.js.map

@@ -127,1 +127,2 @@ "use strict";

exports.sha224 = (0, utils_js_1.wrapConstructor)(() => new SHA224());
//# sourceMappingURL=sha256.js.map
"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 _assert_1 = require("./_assert");
const _assert_js_1 = require("./_assert.js");
const utils_js_1 = require("./utils.js");

@@ -143,3 +143,3 @@ const sha3_js_1 = require("./sha3.js");

B || (B = 8);
(0, _assert_1.number)(B);
(0, _assert_js_1.number)(B);
this.chunkLen = B;

@@ -296,3 +296,3 @@ super.update(leftEncode(B));

constructor(capacity) {
(0, _assert_1.number)(capacity);
(0, _assert_js_1.number)(capacity);
// Rho should be full bytes

@@ -353,1 +353,2 @@ if (capacity < 0 || capacity > 1600 - 10 || (1600 - capacity - 2) % 8)

exports.keccakprg = keccakprg;
//# sourceMappingURL=sha3-addons.js.map

@@ -211,1 +211,2 @@ "use strict";

exports.shake256 = genShake(0x1f, 136, 256 / 8);
//# sourceMappingURL=sha3.js.map

@@ -235,1 +235,2 @@ "use strict";

exports.sha384 = (0, utils_js_1.wrapConstructor)(() => new SHA384());
//# sourceMappingURL=sha512.js.map

@@ -162,1 +162,2 @@ "use strict";

exports.randomBytes = randomBytes;
//# sourceMappingURL=utils.js.map
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc