Skip to content

Commit b18a90d

Browse files
committed
Compare against keccak256 from solc-bin/list.json
1 parent ca6c11c commit b18a90d

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

downloadCurrentVersion.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var pkg = require('./package.json');
77
var fs = require('fs');
88
var https = require('https');
99
var MemoryStream = require('memorystream');
10-
var createHash = require('create-hash');
10+
var ethJSUtil = require('ethereumjs-util');
1111

1212
function getVersionList (cb) {
1313
console.log('Retrieving available version list...');
@@ -37,7 +37,7 @@ function downloadBinary (version, expectedHash) {
3737
response.pipe(file);
3838
file.on('finish', function () {
3939
file.close(function () {
40-
var hash = createHash('sha256').update(fs.readFileSync('soljson.js')).digest().toString('hex')
40+
var hash = '0x' + ethJSUtil.sha3(fs.readFileSync('soljson.js')).toString('hex');
4141
if (expectedHash !== hash) {
4242
console.log('Hash mismatch: ' + expectedHash + ' vs ' + hash);
4343
process.exit(1);
@@ -53,5 +53,7 @@ console.log('Downloading correct solidity binary...');
5353
getVersionList(function (list) {
5454
list = JSON.parse(list);
5555
var wanted = pkg.version.match(/^(\d+\.\d+\.\d+)$/)[1];
56-
downloadBinary(list.releases[wanted], pkg.solc["sha256"]);
56+
var releaseFileName = list.releases[wanted];
57+
var expectedHash = list.builds.filter(function (entry) { return entry.path === releaseFileName; })[0].keccak256;
58+
downloadBinary(releaseFileName, expectedHash);
5759
});

package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"yargs": "^4.7.1"
4545
},
4646
"devDependencies": {
47-
"create-hash": "^1.1.3",
47+
"ethereumjs-util": "^5.1.2",
4848
"semistandard": "^11.0.0",
4949
"tape": "^4.5.1",
5050
"tape-spawn": "^1.4.2"
@@ -53,8 +53,5 @@
5353
"ignore": [
5454
"soljson.js"
5555
]
56-
},
57-
"solc": {
58-
"sha256": "a52d6dddca6c3df5a6364cc11f93a6dd1c58e38e8c740f27e39f98e43cdaafce"
5956
}
6057
}

0 commit comments

Comments
 (0)