2
2
3
3
[ ![ npm version] [ 1 ]] [ 2 ] [ ![ Travis CI] [ 3 ]] [ 4 ] [ ![ license] [ 5 ]] [ 6 ] [ ![ Types] [ 7 ]] [ 8 ]
4
4
5
- This package contains all pure-js cryptographic primitives normally used when
5
+ All pure-js cryptographic primitives normally used when
6
6
developing Javascript / TypeScript applications and tools for Ethereum.
7
7
8
+ ** January 2022 update:** Version 1.0 of the package is out. The module has been completely rewritten:
9
+
10
+ - ** 6x smaller:** 4,000 lines of code instead of 22,438 (with all deps); 185KB instead of 755KB
11
+ - 3 dependencies by one author instead of 38 by 5 authors
12
+ - [ Audited] ( #security ) by an independent security firm
13
+
8
14
The cryptographic primitives included are:
9
15
10
16
* [ Hashes: SHA256, keccak-256, RIPEMD160, BLAKE2b] ( #hashes-sha256-keccak-256-ripemd160-blake2b )
@@ -15,30 +21,16 @@ The cryptographic primitives included are:
15
21
* [ BIP39 Mnemonic phrases] ( #bip39-mnemonic-phrases )
16
22
* [ AES Encryption] ( #aes-encryption )
17
23
18
- ** October 2021 update:** We're releasing ** experimental** version 0.2 of the package.
19
- The module has been completely rewritten:
20
-
21
- - ~ 6x smaller: 4,000 lines of code instead of 22,438 (with all deps); 185KB instead of 755KB
22
- - 3 dependencies (pending an audit) instead of 38
23
- - ** Same functionality** , all old APIs remain the same except for two breaking changes:
24
- 1 . We return ` Uint8Array ` from all methods that worked with ` Buffer ` before.
25
- ` Buffer ` has never been supported in browsers, while ` Uint8Array ` s are supported natively in both
26
- browsers and node.js. See [ Upgrading] ( #upgrading )
27
- 2 . We target runtimes with [ bigint] ( https://caniuse.com/bigint ) support,
28
- which is Chrome 67+, Edge 79+, Firefox 68+, Safari 14+, node.js 10+. If you need to support older runtimes, use
` [email protected] `
29
- 3 . If you've used ` secp256k1 ` , [ rename it to ` secp256k1-compat ` ] ( #legacy-secp256k1-compatibility-layer )
30
- - The new module [ has not been audited yet] ( #security ) , but it's in the process of getting the audit. Use it at your own risk
31
-
32
24
## Usage
33
25
34
26
Use NPM / Yarn in node.js / browser:
35
27
36
28
``` bash
37
29
# NPM
38
- npm install ethereum-cryptography@next
30
+ npm install ethereum-cryptography
39
31
40
32
# Yarn
41
- yarn add ethereum-cryptography@next
33
+ yarn add ethereum-cryptography
42
34
```
43
35
44
36
See [ browser usage] ( #browser-usage ) for information on using the package with major Javascript bundlers. It is
@@ -205,6 +197,9 @@ Note: if you've been using ethereum-cryptography v0.1, it had different API. We'
205
197
206
198
## BIP32 HD Keygen
207
199
200
+ Hierarchical deterministic (HD) wallets that conform to BIP32 standard.
201
+ Also available as standalone package [ micro-bip32] ( https://github.com/paulmillr/micro-bip32 ) .
202
+
208
203
This module exports a single class ` HDKey ` , which should be used like this:
209
204
210
205
``` ts
@@ -283,6 +278,8 @@ function mnemonicToSeedSync(mnemonic: string, passphrase: string = ""): Uint8Arr
283
278
The ` bip39 ` submodule provides functions to generate, validate and use seed
284
279
recovery phrases according to [ BIP39] ( https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki ) .
285
280
281
+ Also available as standalone package [ micro-bip39] ( https://github.com/paulmillr/micro-bip39 ) .
282
+
286
283
``` js
287
284
const { generateMnemonic } = require (" ethereum-cryptography/bip39" );
288
285
const { wordlist } = require (" ethereum-cryptography/bip39/wordlists/english" );
@@ -449,14 +446,16 @@ you found another primitive that is missing.
449
446
450
447
## Upgrading
451
448
452
- Version 0.2 changes from 0.1:
449
+ Version 1.0 changes from 0.1:
450
+
451
+ ** Same functionality** , all old APIs remain the same except for the breaking changes:
453
452
454
- - ** Breaking: ** we target runtimes with [ bigint ] ( https://caniuse.com/bigint ) support,
455
- which is Chrome 67+, Edge 79+, Firefox 68+, Safari 14+, node.js 10+. If you need to support
456
- older runtimes, use ` [email protected] `
457
- - ** Breaking: ** we return ` Uint8Array ` from all methods that worked with ` Buffer ` before.
458
- ` Buffer ` has never been supported in browsers, while ` Uint8Array ` s are supported natively in both
459
- browsers and node.js:
453
+ 1 . We return ` Uint8Array ` from all methods that worked with ` Buffer ` before.
454
+ ` Buffer ` has never been supported in browsers, while ` Uint8Array ` s are supported natively in both
455
+ browsers and node.js. See [ Upgrading ] ( #upgrading )
456
+ 2 . We target runtimes with [ bigint ] ( https://caniuse.com/bigint ) support,
457
+ which is Chrome 67+, Edge 79+, Firefox 68+, Safari 14+, node.js 10+. If you need to support older runtimes, use ` [email protected] `
458
+ 3 . If you've used ` secp256k1 ` , [ rename it to ` secp256k1-compat ` ] ( #legacy-secp256k1-compatibility-layer )
460
459
461
460
```
462
461
const { sha256 } = require("ethereum-cryptography/sha256");
@@ -475,7 +474,7 @@ const hashbo = hashb.toString("hex");
475
474
476
475
## Security
477
476
478
- This library is in the process of getting a security audit.
477
+ Audited by Cure53 on Jan 5, 2022. Check out the audit [ PDF ] ( ./audit/2022-01-05-cure53-audit-nbl2.pdf ) & [ URL ] ( https://cure53.de/pentest-report_hashing-libs.pdf ) .
479
478
480
479
## License
481
480
0 commit comments