diff --git a/tools/canary/canary-test.json b/tools/canary/canary-test.json new file mode 100644 index 0000000..1868d54 --- /dev/null +++ b/tools/canary/canary-test.json @@ -0,0 +1,20 @@ +{ + "version": "0.1", + "alerts": [ + { + "affectedVersions": [ + "io.ethers.app/0.1" + ], + "heading": "Warning", + "text": [ + "This is a test of the **emergency canary** system.", + "This is only a drill.", + "", + "If this had been a real emergency, this would have included the problem and possible solutions.", + "", + "" + ], + "button": "I Agree" + } + ] +} diff --git a/tools/canary/canary.json b/tools/canary/canary.json new file mode 100644 index 0000000..9e73769 --- /dev/null +++ b/tools/canary/canary.json @@ -0,0 +1,5 @@ +{ + "version": "0.1", + "alerts": [ + ] +} diff --git a/tools/canary/canary.raw b/tools/canary/canary.raw new file mode 100644 index 0000000..f184d08 --- /dev/null +++ b/tools/canary/canary.raw @@ -0,0 +1 @@ +0xf86680808080809d7b2276657273696f6e223a22302e31222c22616c65727473223a5b5d7d1ba03f0e5fb1ee9adb9e689b0d1a5ad4566ea91915007b1c43ab59369c40cc82d26fa02a49304771de9f5777cd34cdc5e2098df3027f11f6c1019f00241bdef89f7765 diff --git a/tools/canary/index.js b/tools/canary/index.js new file mode 100644 index 0000000..ef9b94f --- /dev/null +++ b/tools/canary/index.js @@ -0,0 +1,48 @@ +/** + * Canary + * + * The canary file can be uploaded to https://ethers.io/canary.raw + * in the event a serious bug is discovered that users must be warned + * of. + * + * It must be signed with the private key for the address: + * + * 0x70C14080922f091fD7d0E891eB483C9f8464a527 + * + * TODO: This needs to be updated to take a secure password from + * readlineSync rather than the command line. + */ + +var crypto = require('crypto'); +var fs = require('fs'); + +var Wallet = require('ethers-wallet'); + +var jsonFilename = process.argv[2]; +var password = process.argv[3]; +var canaryFilename = process.argv[4]; + +var canaryData = fs.readFileSync(canaryFilename); +canaryData = JSON.stringify(JSON.parse(canaryData)); + +var transaction = { + nonce: '0x00', + gasPrice: '0x00', + gasLimit: '0x00', + value: '0x00', + data: (new Buffer(canaryData)), +} + + +Wallet.decrypt(fs.readFileSync(jsonFilename), new Buffer(password)).then(function(wallet) { + var data = wallet.sign(transaction); + var hash = crypto.createHash('sha256').update(new Buffer(data.substring(2), 'hex')).digest() + + console.log('Address: ' + wallet.address); + console.log('Hash: 0x' + hash.toString('hex')); + console.log('Filename: canary-' + hash.slice(0, 4).toString('hex') + '.hex'); + console.log('Data: ' + data); + +}, function(error) { + console.log(error); +}); diff --git a/tools/canary/package.json b/tools/canary/package.json new file mode 100644 index 0000000..498b42f --- /dev/null +++ b/tools/canary/package.json @@ -0,0 +1,14 @@ +{ + "name": "ethers-canary", + "version": "0.0.1", + "description": "Script to generate and sign the https://ethers.io/canary.raw file.", + "main": "index.js", + "dependencies": { + "ethers-wallet": "1.0.10" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Richard Moore ", + "license": "MIT" +}