on master help sign in
deps: upgrade @ethereumjs/utils
08b1cbftomholford
package-lock.json+5−2
@@ -11,6 +11,7 @@
11 "dependencies": {
11 "dependencies": {
12 "@ethereumjs/common": "^3.0.0",
12 "@ethereumjs/common": "^3.0.0",
13 "@ethereumjs/tx": "^4.0.0",
13 "@ethereumjs/tx": "^4.0.0",
14+ "@ethereumjs/util": "^8.0.0",
14 "@ledgerhq/hw-transport-u2f": "^5.36.0-deprecated",
15 "@ledgerhq/hw-transport-u2f": "^5.36.0-deprecated",
15 "@metamask/detect-provider": "^1.2.0",
16 "@metamask/detect-provider": "^1.2.0",
16 "@reach/disclosure": "^0.15.0",
17 "@reach/disclosure": "^0.15.0",
@@ -47,7 +48,6 @@
47 "copy-to-clipboard": "^3.2.0",
48 "copy-to-clipboard": "^3.2.0",
48 "date-fns": "^2.25.0",
49 "date-fns": "^2.25.0",
49 "ethereum-blockies-base64": "^1.0.2",
50 "ethereum-blockies-base64": "^1.0.2",
50− "ethereumjs-util": "^7.1.4",
51 "file-saver": "^2.0.0",
51 "file-saver": "^2.0.0",
52 "final-form": "^4.18.4",
52 "final-form": "^4.18.4",
53 "final-form-arrays": "^3.0.1",
53 "final-form-arrays": "^3.0.1",
@@ -1145,7 +1145,8 @@
1145 },
1145 },
1146 "node_modules/@ethereumjs/util": {
1146 "node_modules/@ethereumjs/util": {
1147 "version": "8.0.0",
1147 "version": "8.0.0",
1148− "license": "MPL-2.0",
1148+ "resolved": "https://registry.npmjs.org/@ethereumjs/util/-/util-8.0.0.tgz",
1149+ "integrity": "sha512-Zz/Ovar0VU/CaYHLvigBTjG5PmkG0OzjvRjjoXRJbJcdWJoTCN2N4BYgoCBOZomKjaAT4ABpQ7wer6ZFOglvjg==",
1149 "dependencies": {
1150 "dependencies": {
1150 "@ethereumjs/rlp": "^4.0.0-beta.2",
1151 "@ethereumjs/rlp": "^4.0.0-beta.2",
1151 "ethereum-cryptography": "^1.1.2"
1152 "ethereum-cryptography": "^1.1.2"
@@ -14248,6 +14249,8 @@
14248 },
14249 },
14249 "@ethereumjs/util": {
14250 "@ethereumjs/util": {
14250 "version": "8.0.0",
14251 "version": "8.0.0",
14252+ "resolved": "https://registry.npmjs.org/@ethereumjs/util/-/util-8.0.0.tgz",
14253+ "integrity": "sha512-Zz/Ovar0VU/CaYHLvigBTjG5PmkG0OzjvRjjoXRJbJcdWJoTCN2N4BYgoCBOZomKjaAT4ABpQ7wer6ZFOglvjg==",
14251 "requires": {
14254 "requires": {
14252 "@ethereumjs/rlp": "^4.0.0-beta.2",
14255 "@ethereumjs/rlp": "^4.0.0-beta.2",
14253 "ethereum-cryptography": "^1.1.2"
14256 "ethereum-cryptography": "^1.1.2"
package.json+1−1
@@ -17,6 +17,7 @@
17 "dependencies": {
17 "dependencies": {
18 "@ethereumjs/common": "^3.0.0",
18 "@ethereumjs/common": "^3.0.0",
19 "@ethereumjs/tx": "^4.0.0",
19 "@ethereumjs/tx": "^4.0.0",
20+ "@ethereumjs/util": "^8.0.0",
20 "@ledgerhq/hw-transport-u2f": "^5.36.0-deprecated",
21 "@ledgerhq/hw-transport-u2f": "^5.36.0-deprecated",
21 "@metamask/detect-provider": "^1.2.0",
22 "@metamask/detect-provider": "^1.2.0",
22 "@reach/disclosure": "^0.15.0",
23 "@reach/disclosure": "^0.15.0",
@@ -53,7 +54,6 @@
53 "copy-to-clipboard": "^3.2.0",
54 "copy-to-clipboard": "^3.2.0",
54 "date-fns": "^2.25.0",
55 "date-fns": "^2.25.0",
55 "ethereum-blockies-base64": "^1.0.2",
56 "ethereum-blockies-base64": "^1.0.2",
56− "ethereumjs-util": "^7.1.4",
57 "file-saver": "^2.0.0",
57 "file-saver": "^2.0.0",
58 "final-form": "^4.18.4",
58 "final-form": "^4.18.4",
59 "final-form-arrays": "^3.0.1",
59 "final-form-arrays": "^3.0.1",
src/lib/authToken.ts+13−4
@@ -3,11 +3,10 @@ import { ecdsaSign } from 'secp256k1';
3import Web3 from 'web3';
3import Web3 from 'web3';
4import { hexToBytes } from 'web3-utils';
4import { hexToBytes } from 'web3-utils';
5import WalletConnect from '@walletconnect/client';
5import WalletConnect from '@walletconnect/client';
6−
6+import { hashPersonalMessage } from '@ethereumjs/util';
7import { WALLET_TYPES } from './constants';
7import { WALLET_TYPES } from './constants';
8import BridgeWallet from './types/BridgeWallet';
8import BridgeWallet from './types/BridgeWallet';
9import { Hash } from '@urbit/roller-api';
9import { Hash } from '@urbit/roller-api';
10−import { keccak256 } from 'ethereumjs-util';
11
10
12const MESSAGE = 'Bridge Authentication Token';
11const MESSAGE = 'Bridge Authentication Token';
13
12
@@ -15,12 +14,22 @@ function signMessage(privateKey: Buffer, useLegacyTokenSigning = false) {
15 const msg = '\x19Ethereum Signed Message:\n' + MESSAGE.length + MESSAGE;
14 const msg = '\x19Ethereum Signed Message:\n' + MESSAGE.length + MESSAGE;
16 const hashed = useLegacyTokenSigning
15 const hashed = useLegacyTokenSigning
17 ? crypto.sha256(Buffer.from(msg))
16 ? crypto.sha256(Buffer.from(msg))
18− : keccak256(Buffer.from(msg));
17+ : hashPersonalMessage(Buffer.from(MESSAGE)) // msg prefix is handled by lib
18+
19+ const hashAry = new Uint8Array(hashed.buffer);
19− const { signature } = ecdsaSign(Buffer.from(hashed), privateKey);
20+ const { signature, recid: _recid } = ecdsaSign(hashAry, privateKey);
20
21
21 // add key recovery parameter
22 // add key recovery parameter
22 const ethSignature = new Uint8Array(65);
23 const ethSignature = new Uint8Array(65);
23 ethSignature.set(signature);
24 ethSignature.set(signature);
25+
26+ // https://eips.ethereum.org/EIPS/eip-155
27+ // This method for setting the recovery parameter is the "legacy" way of doing
28+ // so; and in fact, does not match up with output of Metamask / Brave Wallet.
29+ // MM uses 28 instead of 27.
30+ // TODO: Should we bring this up to latest standard? The problem is, users
31+ // who have set network keys or generated invites with an older token will
32+ // not be able to rederive them
24 const v = (ethSignature[32] & 1) + 27;
33 const v = (ethSignature[32] & 1) + 27;
25 ethSignature[64] = v;
34 ethSignature[64] = v;
26
35
src/lib/utils/address.ts+2−2
@@ -1,5 +1,5 @@
1import { isAddress, toChecksumAddress } from 'web3-utils';
1import { isAddress, toChecksumAddress } from 'web3-utils';
2−import { pubToAddress } from 'ethereumjs-util';
2+import { pubToAddress } from '@ethereumjs/util';
3import { ETH_ZERO_ADDR, ETH_ZERO_ADDR_SHORT } from 'lib/constants';
3import { ETH_ZERO_ADDR, ETH_ZERO_ADDR_SHORT } from 'lib/constants';
4
4
5export const stripHexPrefix = (hex: string) => {
5export const stripHexPrefix = (hex: string) => {
@@ -30,5 +30,5 @@ export const eqAddr = (addr0: string, addr1: string) =>
30 : toChecksumAddress(addr0) === toChecksumAddress(addr1);
30 : toChecksumAddress(addr0) === toChecksumAddress(addr1);
31
31
32export const publicToAddress = (publicKey: Buffer): string => {
32export const publicToAddress = (publicKey: Buffer): string => {
33− return '0x' + pubToAddress(Buffer.from(publicKey), true).toString('hex');
33+ return '0x' + pubToAddress(publicKey, true).toString('hex');
34};
34};
src/views/Release/TransferForm.tsx+1−1
@@ -14,7 +14,7 @@ import { useStarReleaseCache } from 'store/starRelease';
14import { useWallet } from 'store/wallet';
14import { useWallet } from 'store/wallet';
15import { eqAddr, isZeroAddress } from 'lib/utils/address';
15import { eqAddr, isZeroAddress } from 'lib/utils/address';
16import { useTransferLockup } from './useTransferLockup';
16import { useTransferLockup } from './useTransferLockup';
17−import { isValidAddress } from 'ethereumjs-util';
17+import { isValidAddress } from '@ethereumjs/util';
18import { getLockupKind } from 'lib/starRelease';
18import { getLockupKind } from 'lib/starRelease';
19
19
20interface TransferFormProps {
20interface TransferFormProps {