on master help sign in
auth: use keccak256 to derive token
commit2fec545be11196713a51ad2ffdcc8171f168bb8b authortomholford <tomholford@users.noreply.github.com> dateTue 22 Feb 2022, 19:07 (5 years ago) parent8914f70
3 files changed+17−21
package-lock.json+14−17 package.json+1−1 src/lib/authToken.ts+2−3
package-lock.json+14−17
@@ -14239,15 +14239,14 @@
1423914239 }
1424014240 },
1424114241 "ethereumjs-util": {
14242− "version": "7.1.0",
14243− "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-7.1.0.tgz",
14244− "integrity": "sha512-kR+vhu++mUDARrsMMhsjjzPduRVAeundLGXucGRHF3B4oEltOUspfgCVco4kckucj3FMlLaZHUl9n7/kdmr6Tw==",
14242+ "version": "7.1.4",
14243+ "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-7.1.4.tgz",
14244+ "integrity": "sha512-p6KmuPCX4mZIqsQzXfmSx9Y0l2hqf+VkAiwSisW3UKUFdk8ZkAt+AYaor83z2nSi6CU2zSsXMlD80hAbNEGM0A==",
1424514245 "requires": {
1424614246 "@types/bn.js": "^5.1.0",
1424714247 "bn.js": "^5.1.2",
1424814248 "create-hash": "^1.1.2",
1424914249 "ethereum-cryptography": "^0.1.3",
14250− "ethjs-util": "0.1.6",
1425114250 "rlp": "^2.2.4"
1425214251 },
1425314252 "dependencies": {
@@ -14311,15 +14310,6 @@
1431114310 }
1431214311 }
1431314312 },
14314− "ethjs-util": {
14315− "version": "0.1.6",
14316− "resolved": "https://registry.npmjs.org/ethjs-util/-/ethjs-util-0.1.6.tgz",
14317− "integrity": "sha512-CUnVOQq7gSpDHZVVrQW8ExxUETWrnrvXYvYz55wOU8Uj4VCgw56XC2B/fVqQN+f7gmrnRHSLVnFAwsCuNwji8w==",
14318− "requires": {
14319− "is-hex-prefixed": "1.0.0",
14320− "strip-hex-prefix": "1.0.0"
14321− }
14322− },
1432314313 "event-iterator": {
1432414314 "version": "1.2.0",
1432514315 "resolved": "https://registry.npmjs.org/event-iterator/-/event-iterator-1.2.0.tgz",
@@ -28808,11 +28798,18 @@
2880828798 }
2880928799 },
2881028800 "rlp": {
28811− "version": "2.2.6",
28812− "resolved": "https://registry.npmjs.org/rlp/-/rlp-2.2.6.tgz",
28813− "integrity": "sha512-HAfAmL6SDYNWPUOJNrM500x4Thn4PZsEy5pijPh40U9WfNk0z15hUYzO9xVIMAdIHdFtD8CBDHd75Td1g36Mjg==",
28801+ "version": "2.2.7",
28802+ "resolved": "https://registry.npmjs.org/rlp/-/rlp-2.2.7.tgz",
28803+ "integrity": "sha512-d5gdPmgQ0Z+AklL2NVXr/IoSjNZFfTVvQWzL/AM2AOcSzYP2xjlb0AC8YyCLc41MSNf6P6QVtjgPdmVtzb+4lQ==",
2881428804 "requires": {
28815− "bn.js": "^4.11.1"
28805+ "bn.js": "^5.2.0"
28806+ },
28807+ "dependencies": {
28808+ "bn.js": {
28809+ "version": "5.2.0",
28810+ "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.0.tgz",
28811+ "integrity": "sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw=="
28812+ }
2881628813 }
2881728814 },
2881828815 "rn-host-detect": {
package.json+1−1
@@ -50,7 +50,7 @@
5050 "copy-to-clipboard": "^3.2.0",
5151 "date-fns": "^2.25.0",
5252 "ethereum-blockies-base64": "^1.0.2",
53− "ethereumjs-util": "^7.0.10",
53+ "ethereumjs-util": "^7.1.4",
5454 "file-saver": "^2.0.0",
5555 "final-form": "^4.18.4",
5656 "final-form-arrays": "^3.0.1",
src/lib/authToken.ts+2−3
@@ -1,4 +1,3 @@
1−import { crypto } from 'bitcoinjs-lib';
21import { ecdsaSign } from 'secp256k1';
32import Web3 from 'web3';
43import { hexToBytes } from 'web3-utils';
@@ -9,13 +8,13 @@ import { ledgerSignMessage } from './ledger';
98import { trezorSignMessage } from './trezor';
109import BridgeWallet from './types/BridgeWallet';
1110import { Hash } from '@urbit/roller-api';
11+import { keccak256 } from 'ethereumjs-util';
1212
1313const MESSAGE = 'Bridge Authentication Token';
1414
1515function signMessage(privateKey: Buffer) {
1616 const msg = '\x19Ethereum Signed Message:\n' + MESSAGE.length + MESSAGE;
17− // #ecdsaSign requires a 32-byte buffer, hence sha256
18− const hashed = crypto.sha256(Buffer.from(msg));
17+ const hashed = keccak256(Buffer.from(msg));
1918 const { signature } = ecdsaSign(Buffer.from(hashed), privateKey);
2019
2120 // add key recovery parameter