on master help sign in
auth: use keccak256 to derive token
2fec545tomholford
package-lock.json+14−17
@@ -14239,15 +14239,14 @@
14239 }
14239 }
14240 },
14240 },
14241 "ethereumjs-util": {
14241 "ethereumjs-util": {
14242− "version": "7.1.0",
14242+ "version": "7.1.4",
14243− "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-7.1.0.tgz",
14243+ "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-7.1.4.tgz",
14244− "integrity": "sha512-kR+vhu++mUDARrsMMhsjjzPduRVAeundLGXucGRHF3B4oEltOUspfgCVco4kckucj3FMlLaZHUl9n7/kdmr6Tw==",
14244+ "integrity": "sha512-p6KmuPCX4mZIqsQzXfmSx9Y0l2hqf+VkAiwSisW3UKUFdk8ZkAt+AYaor83z2nSi6CU2zSsXMlD80hAbNEGM0A==",
14245 "requires": {
14245 "requires": {
14246 "@types/bn.js": "^5.1.0",
14246 "@types/bn.js": "^5.1.0",
14247 "bn.js": "^5.1.2",
14247 "bn.js": "^5.1.2",
14248 "create-hash": "^1.1.2",
14248 "create-hash": "^1.1.2",
14249 "ethereum-cryptography": "^0.1.3",
14249 "ethereum-cryptography": "^0.1.3",
14250− "ethjs-util": "0.1.6",
14251 "rlp": "^2.2.4"
14250 "rlp": "^2.2.4"
14252 },
14251 },
14253 "dependencies": {
14252 "dependencies": {
@@ -14311,15 +14310,6 @@
14311 }
14310 }
14312 }
14311 }
14313 },
14312 },
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− },
14323 "event-iterator": {
14313 "event-iterator": {
14324 "version": "1.2.0",
14314 "version": "1.2.0",
14325 "resolved": "https://registry.npmjs.org/event-iterator/-/event-iterator-1.2.0.tgz",
14315 "resolved": "https://registry.npmjs.org/event-iterator/-/event-iterator-1.2.0.tgz",
@@ -28808,11 +28798,18 @@
28808 }
28798 }
28809 },
28799 },
28810 "rlp": {
28800 "rlp": {
28811− "version": "2.2.6",
28801+ "version": "2.2.7",
28812− "resolved": "https://registry.npmjs.org/rlp/-/rlp-2.2.6.tgz",
28802+ "resolved": "https://registry.npmjs.org/rlp/-/rlp-2.2.7.tgz",
28813− "integrity": "sha512-HAfAmL6SDYNWPUOJNrM500x4Thn4PZsEy5pijPh40U9WfNk0z15hUYzO9xVIMAdIHdFtD8CBDHd75Td1g36Mjg==",
28803+ "integrity": "sha512-d5gdPmgQ0Z+AklL2NVXr/IoSjNZFfTVvQWzL/AM2AOcSzYP2xjlb0AC8YyCLc41MSNf6P6QVtjgPdmVtzb+4lQ==",
28814 "requires": {
28804 "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+ }
28816 }
28813 }
28817 },
28814 },
28818 "rn-host-detect": {
28815 "rn-host-detect": {
package.json+1−1
@@ -50,7 +50,7 @@
50 "copy-to-clipboard": "^3.2.0",
50 "copy-to-clipboard": "^3.2.0",
51 "date-fns": "^2.25.0",
51 "date-fns": "^2.25.0",
52 "ethereum-blockies-base64": "^1.0.2",
52 "ethereum-blockies-base64": "^1.0.2",
53− "ethereumjs-util": "^7.0.10",
53+ "ethereumjs-util": "^7.1.4",
54 "file-saver": "^2.0.0",
54 "file-saver": "^2.0.0",
55 "final-form": "^4.18.4",
55 "final-form": "^4.18.4",
56 "final-form-arrays": "^3.0.1",
56 "final-form-arrays": "^3.0.1",
src/lib/authToken.ts+2−3
@@ -1,4 +1,3 @@
1−import { crypto } from 'bitcoinjs-lib';
2import { ecdsaSign } from 'secp256k1';
1import { ecdsaSign } from 'secp256k1';
3import Web3 from 'web3';
2import Web3 from 'web3';
4import { hexToBytes } from 'web3-utils';
3import { hexToBytes } from 'web3-utils';
@@ -9,13 +8,13 @@ import { ledgerSignMessage } from './ledger';
9import { trezorSignMessage } from './trezor';
8import { trezorSignMessage } from './trezor';
10import BridgeWallet from './types/BridgeWallet';
9import BridgeWallet from './types/BridgeWallet';
11import { Hash } from '@urbit/roller-api';
10import { Hash } from '@urbit/roller-api';
11+import { keccak256 } from 'ethereumjs-util';
12
12
13const MESSAGE = 'Bridge Authentication Token';
13const MESSAGE = 'Bridge Authentication Token';
14
14
15function signMessage(privateKey: Buffer) {
15function signMessage(privateKey: Buffer) {
16 const msg = '\x19Ethereum Signed Message:\n' + MESSAGE.length + MESSAGE;
16 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));
19 const { signature } = ecdsaSign(Buffer.from(hashed), privateKey);
18 const { signature } = ecdsaSign(Buffer.from(hashed), privateKey);
20
19
21 // add key recovery parameter
20 // add key recovery parameter