Skip to content
This repository has been archived by the owner on Feb 26, 2020. It is now read-only.

Check if hashes match after downloading Parity #188

Open
axelchalon opened this issue Aug 4, 2018 · 1 comment
Open

Check if hashes match after downloading Parity #188

axelchalon opened this issue Aug 4, 2018 · 1 comment

Comments

@axelchalon
Copy link
Contributor

Should prevent #119
The sha256 hash of the binary is provided in the json response that we get the Parity binary URL from. We might want to use streams for checking the hashes. Would be similar to:

function checkHashMatch (expectedHash, path) {
return new Promise((resolve, reject) => {
const hasher = keccak256.create();
const fileReadStream = fs.createReadStream(path);
fileReadStream.on('end', () => {
const actualHash = hasher.hex();
if (actualHash !== expectedHash) {
reject(`Hashes don't match: expected ${expectedHash}, got ${actualHash}`);
} else {
resolve();
}
});
fileReadStream.on('data', (chunk) => {
hasher.update(chunk);
});
});
}

@axelchalon
Copy link
Contributor Author

axelchalon commented Aug 4, 2018

We already implement this check when downloading Parity in fether (and we'll soon check for interrupted downloads: openethereum/fether#173)

https://github.com/paritytech/fether/blob/cf01b3f713bfb85d04bc4c3e061420aca1ac22e3/packages/parity-electron/src/fetchParity.ts#L107-L117

This happens in the @parity/electron package of the fether repo. This package will soon be moved to paritytech/js-libs, so we can simply wait for this to happen and then use this library in Parity UI.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant