File tree Expand file tree Collapse file tree 2 files changed +15
-15
lines changed
packages/ethereum-cryptography-native Expand file tree Collapse file tree 2 files changed +15
-15
lines changed Original file line number Diff line number Diff line change 43
43
},
44
44
"optionalDependencies" : {
45
45
"blake2" : " ^2.0.1" ,
46
+ "keccak" : " ^2.0.0" ,
46
47
"scrypt" : " ^6.0.3" ,
47
- "secp256k1" : " ^3.7.1" ,
48
- "sha3" : " ^1.2.3"
48
+ "secp256k1" : " ^3.7.1"
49
49
},
50
50
"dependencies" : {
51
51
"@types/secp256k1" : " ^3.5.0"
Original file line number Diff line number Diff line change 1
- const SHA3 = require ( "sha3 " ) ;
1
+ const createKeccakHash = require ( "keccak " ) ;
2
2
3
3
export function keccak224 ( msg : Buffer ) : Buffer {
4
- const sha3 = new SHA3 . SHA3Hash ( 224 ) ;
5
- sha3 . update ( msg ) ;
6
- return Buffer . from ( sha3 . digest ( ) , "binary" ) ;
4
+ const hash = createKeccakHash ( "keccak224" ) ;
5
+ hash . update ( msg ) ;
6
+ return Buffer . from ( hash . digest ( ) , "binary" ) ;
7
7
}
8
8
9
9
export function keccak256 ( msg : Buffer ) : Buffer {
10
- const sha3 = new SHA3 . SHA3Hash ( 256 ) ;
11
- sha3 . update ( msg ) ;
12
- return Buffer . from ( sha3 . digest ( ) , "binary" ) ;
10
+ const hash = createKeccakHash ( "keccak256" ) ;
11
+ hash . update ( msg ) ;
12
+ return Buffer . from ( hash . digest ( ) , "binary" ) ;
13
13
}
14
14
15
15
export function keccak384 ( msg : Buffer ) : Buffer {
16
- const sha3 = new SHA3 . SHA3Hash ( 384 ) ;
17
- sha3 . update ( msg ) ;
18
- return Buffer . from ( sha3 . digest ( ) , "binary" ) ;
16
+ const hash = createKeccakHash ( "keccak384" ) ;
17
+ hash . update ( msg ) ;
18
+ return Buffer . from ( hash . digest ( ) , "binary" ) ;
19
19
}
20
20
21
21
export function keccak512 ( msg : Buffer ) : Buffer {
22
- const sha3 = new SHA3 . SHA3Hash ( 512 ) ;
23
- sha3 . update ( msg ) ;
24
- return Buffer . from ( sha3 . digest ( ) , "binary" ) ;
22
+ const hash = createKeccakHash ( "keccak512" ) ;
23
+ hash . update ( msg ) ;
24
+ return Buffer . from ( hash . digest ( ) , "binary" ) ;
25
25
}
You can’t perform that action at this time.
0 commit comments