Skip to content

Commit 063ba25

Browse files
committed
Use NAPI-based keccak instead of js-sha3
1 parent 03f8b75 commit 063ba25

File tree

4 files changed

+17
-52
lines changed

4 files changed

+17
-52
lines changed

packages/ethereum-cryptography/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
"pure/**/*.d.ts.map"
5050
],
5151
"browser": {
52-
"./keccak.js": "./pure/keccak.js",
5352
"./scrypt.js": "./pure/scrypt.js",
5453
"./ripemd160.js": "./pure/ripemd160.js",
5554
"./secp256k1.js": "./pure/secp256k1.js",
@@ -128,7 +127,7 @@
128127
"create-hmac": "^1.1.7",
129128
"elliptic": "^6.4.1",
130129
"hash.js": "^1.1.7",
131-
"js-sha3": "^0.8.0",
130+
"keccak": "^3.0.0",
132131
"pbkdf2": "^3.0.17",
133132
"randombytes": "^2.1.0",
134133
"safe-buffer": "^5.1.2",
Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
import * as keccakPure from "./pure/keccak";
1+
import { createHashFunction } from "./hash-utils";
22

3-
let keccakModule: typeof keccakPure;
3+
const createKeccakHash = require("keccak");
44

5-
try {
6-
// tslint:disable-next-line no-implicit-dependencies
7-
keccakModule = require("ethereum-cryptography-native/keccak");
8-
} catch {
9-
keccakModule = require("./pure/keccak");
10-
}
5+
export const keccak224 = createHashFunction(() =>
6+
createKeccakHash("keccak224")
7+
);
118

12-
export const keccak224 = keccakModule.keccak224;
13-
export const keccak256 = keccakModule.keccak256;
14-
export const keccak384 = keccakModule.keccak384;
15-
export const keccak512 = keccakModule.keccak512;
9+
export const keccak256 = createHashFunction(() =>
10+
createKeccakHash("keccak256")
11+
);
12+
13+
export const keccak384 = createHashFunction(() =>
14+
createKeccakHash("keccak384")
15+
);
16+
17+
export const keccak512 = createHashFunction(() =>
18+
createKeccakHash("keccak512")
19+
);

packages/ethereum-cryptography/src/pure/keccak.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

packages/ethereum-cryptography/test/pure/keccak.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)