Skip to content
This repository was archived by the owner on Dec 10, 2020. It is now read-only.

Commit df2644b

Browse files
authored
Merge pull request #19 from ethereumjs/update-utils
Upgrade ethereumjs-util to 6.x
2 parents f88973e + f032bfc commit df2644b

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
package-lock.json

index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ Ethash.prototype.mkcache = function (cacheSize, seed) {
1717
// console.log('size: ' + cacheSize)
1818
// console.log('seed: ' + seed.toString('hex'))
1919
const n = Math.floor(cacheSize / ethHashUtil.params.HASH_BYTES)
20-
var o = [ethUtil.sha3(seed, 512)]
20+
var o = [ethUtil.keccak(seed, 512)]
2121

2222
var i
2323
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))
2525
}
2626

2727
for (var _ = 0; _ < ethHashUtil.params.CACHE_ROUNDS; _++) {
2828
for (i = 0; i < n; i++) {
2929
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)
3131
}
3232
}
3333

@@ -40,19 +40,19 @@ Ethash.prototype.calcDatasetItem = function (i) {
4040
const r = Math.floor(ethHashUtil.params.HASH_BYTES / ethHashUtil.params.WORD_BYTES)
4141
var mix = new Buffer(this.cache[i % n])
4242
mix.writeInt32LE(mix.readUInt32LE(0) ^ i, 0)
43-
mix = ethUtil.sha3(mix, 512)
43+
mix = ethUtil.keccak(mix, 512)
4444
for (var j = 0; j < ethHashUtil.params.DATASET_PARENTS; j++) {
4545
var cacheIndex = ethHashUtil.fnv(i ^ j, mix.readUInt32LE(j % r * 4))
4646
mix = ethHashUtil.fnvBuffer(mix, this.cache[cacheIndex % n])
4747
}
48-
return ethUtil.sha3(mix, 512)
48+
return ethUtil.keccak(mix, 512)
4949
}
5050

5151
Ethash.prototype.run = function (val, nonce, fullSize) {
5252
fullSize = fullSize || this.fullSize
5353
const n = Math.floor(fullSize / ethHashUtil.params.HASH_BYTES)
5454
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)
5656
const mixhashes = Math.floor(ethHashUtil.params.MIX_BYTES / ethHashUtil.params.HASH_BYTES)
5757
var mix = Buffer.concat(Array(mixhashes).fill(s))
5858

@@ -78,12 +78,12 @@ Ethash.prototype.run = function (val, nonce, fullSize) {
7878

7979
return {
8080
mix: cmix,
81-
hash: ethUtil.sha3(Buffer.concat([s, cmix]))
81+
hash: ethUtil.keccak256(Buffer.concat([s, cmix]))
8282
}
8383
}
8484

8585
Ethash.prototype.cacheHash = function () {
86-
return ethUtil.sha3(Buffer.concat(this.cache))
86+
return ethUtil.keccak256(Buffer.concat(this.cache))
8787
}
8888

8989
Ethash.prototype.headerHash = function (header) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"dependencies": {
3131
"async": "^2.1.2",
3232
"buffer-xor": "^2.0.1",
33-
"ethereumjs-util": "^5.0.1",
33+
"ethereumjs-util": "^6.1.0",
3434
"miller-rabin": "^4.0.0"
3535
},
3636
"devDependencies": {

util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ exports.getEpoc = function (blockNumber) {
5151
*/
5252
exports.getSeed = function (seed, begin, end) {
5353
for (var i = begin; i < end; i++) {
54-
seed = ethUtil.sha3(seed)
54+
seed = ethUtil.keccak256(seed)
5555
}
5656
return seed
5757
}

0 commit comments

Comments
 (0)