@@ -17,17 +17,17 @@ Ethash.prototype.mkcache = function (cacheSize, seed) {
17
17
// console.log('size: ' + cacheSize)
18
18
// console.log('seed: ' + seed.toString('hex'))
19
19
const n = Math . floor ( cacheSize / ethHashUtil . params . HASH_BYTES )
20
- var o = [ ethUtil . sha3 ( seed , 512 ) ]
20
+ var o = [ ethUtil . keccak ( seed , 512 ) ]
21
21
22
22
var i
23
23
for ( i = 1 ; i < n ; i ++ ) {
24
- o . push ( ethUtil . sha3 ( o [ o . length - 1 ] , 512 ) )
24
+ o . push ( ethUtil . keccak ( o [ o . length - 1 ] , 512 ) )
25
25
}
26
26
27
27
for ( var _ = 0 ; _ < ethHashUtil . params . CACHE_ROUNDS ; _ ++ ) {
28
28
for ( i = 0 ; i < n ; i ++ ) {
29
29
var v = o [ i ] . readUInt32LE ( 0 ) % n
30
- o [ i ] = ethUtil . sha3 ( xor ( o [ ( i - 1 + n ) % n ] , o [ v ] ) , 512 )
30
+ o [ i ] = ethUtil . keccak ( xor ( o [ ( i - 1 + n ) % n ] , o [ v ] ) , 512 )
31
31
}
32
32
}
33
33
@@ -40,19 +40,19 @@ Ethash.prototype.calcDatasetItem = function (i) {
40
40
const r = Math . floor ( ethHashUtil . params . HASH_BYTES / ethHashUtil . params . WORD_BYTES )
41
41
var mix = new Buffer ( this . cache [ i % n ] )
42
42
mix . writeInt32LE ( mix . readUInt32LE ( 0 ) ^ i , 0 )
43
- mix = ethUtil . sha3 ( mix , 512 )
43
+ mix = ethUtil . keccak ( mix , 512 )
44
44
for ( var j = 0 ; j < ethHashUtil . params . DATASET_PARENTS ; j ++ ) {
45
45
var cacheIndex = ethHashUtil . fnv ( i ^ j , mix . readUInt32LE ( j % r * 4 ) )
46
46
mix = ethHashUtil . fnvBuffer ( mix , this . cache [ cacheIndex % n ] )
47
47
}
48
- return ethUtil . sha3 ( mix , 512 )
48
+ return ethUtil . keccak ( mix , 512 )
49
49
}
50
50
51
51
Ethash . prototype . run = function ( val , nonce , fullSize ) {
52
52
fullSize = fullSize || this . fullSize
53
53
const n = Math . floor ( fullSize / ethHashUtil . params . HASH_BYTES )
54
54
const w = Math . floor ( ethHashUtil . params . MIX_BYTES / ethHashUtil . params . WORD_BYTES )
55
- const s = ethUtil . sha3 ( Buffer . concat ( [ val , ethHashUtil . bufReverse ( nonce ) ] ) , 512 )
55
+ const s = ethUtil . keccak ( Buffer . concat ( [ val , ethHashUtil . bufReverse ( nonce ) ] ) , 512 )
56
56
const mixhashes = Math . floor ( ethHashUtil . params . MIX_BYTES / ethHashUtil . params . HASH_BYTES )
57
57
var mix = Buffer . concat ( Array ( mixhashes ) . fill ( s ) )
58
58
@@ -78,12 +78,12 @@ Ethash.prototype.run = function (val, nonce, fullSize) {
78
78
79
79
return {
80
80
mix : cmix ,
81
- hash : ethUtil . sha3 ( Buffer . concat ( [ s , cmix ] ) )
81
+ hash : ethUtil . keccak256 ( Buffer . concat ( [ s , cmix ] ) )
82
82
}
83
83
}
84
84
85
85
Ethash . prototype . cacheHash = function ( ) {
86
- return ethUtil . sha3 ( Buffer . concat ( this . cache ) )
86
+ return ethUtil . keccak256 ( Buffer . concat ( this . cache ) )
87
87
}
88
88
89
89
Ethash . prototype . headerHash = function ( header ) {
0 commit comments