Merge pull request #269 from status-im/eth-pm-eip-712

This commit is contained in:
Franck Royer 2021-08-19 11:22:05 +10:00 committed by GitHub
commit e0d2b3d525
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 538 additions and 84 deletions

View File

@ -13,8 +13,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
- Renamed `discover.getStatusFleetNodes` to `discovery.getBootstrapNodes`; - Renamed `discover.getStatusFleetNodes` to `discovery.getBootstrapNodes`;
Changed the API to allow retrieval of bootstrap nodes from other sources. Changed the API to allow retrieval of bootstrap nodes from other sources.
- Examples: Renamed `eth-dm` to `eth-pm`: "Direct Message" can lead to confusion with "Direct Connection" that - Examples: Renamed `eth-dm` to `eth-pm`; "Direct Message" can lead to confusion with "Direct Connection" that
refers to low latency network connections. refers to low latency network connections.
- Examples (eth-pm): Use sign typed data EIP-712 instead of personal sign.
### Removed ### Removed
- Examples (cli-chat): The focus of this library is Web environment; - Examples (cli-chat): The focus of this library is Web environment;

View File

@ -3,7 +3,6 @@ import '@ethersproject/shims';
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import './App.css'; import './App.css';
import { Waku } from 'js-waku'; import { Waku } from 'js-waku';
import { Signer } from '@ethersproject/abstract-signer';
import { Message } from './messaging/Messages'; import { Message } from './messaging/Messages';
import 'fontsource-roboto'; import 'fontsource-roboto';
import { AppBar, IconButton, Toolbar, Typography } from '@material-ui/core'; import { AppBar, IconButton, Toolbar, Typography } from '@material-ui/core';
@ -67,7 +66,6 @@ const useStyles = makeStyles({
function App() { function App() {
const [waku, setWaku] = useState<Waku>(); const [waku, setWaku] = useState<Waku>();
const [signer, setSigner] = useState<Signer>();
const [provider, setProvider] = useState<Web3Provider>(); const [provider, setProvider] = useState<Web3Provider>();
const [encPublicKey, setEncPublicKey] = useState<Uint8Array>(); const [encPublicKey, setEncPublicKey] = useState<Uint8Array>();
const [publicKeys, setPublicKeys] = useState<Map<string, Uint8Array>>( const [publicKeys, setPublicKeys] = useState<Map<string, Uint8Array>>(
@ -193,7 +191,6 @@ function App() {
<ConnectWallet <ConnectWallet
setProvider={setProvider} setProvider={setProvider}
setAddress={setAddress} setAddress={setAddress}
setSigner={setSigner}
/> />
</fieldset> </fieldset>
<fieldset> <fieldset>
@ -204,7 +201,6 @@ function App() {
address={address} address={address}
/> />
<BroadcastPublicKey <BroadcastPublicKey
signer={signer}
address={address} address={address}
encryptionPublicKey={encPublicKey} encryptionPublicKey={encPublicKey}
waku={waku} waku={waku}

View File

@ -3,13 +3,11 @@ import React from 'react';
import { createPublicKeyMessage } from './crypto'; import { createPublicKeyMessage } from './crypto';
import { PublicKeyMessage } from './messaging/wire'; import { PublicKeyMessage } from './messaging/wire';
import { WakuMessage, Waku } from 'js-waku'; import { WakuMessage, Waku } from 'js-waku';
import { Signer } from '@ethersproject/abstract-signer';
import { PublicKeyContentTopic } from './waku'; import { PublicKeyContentTopic } from './waku';
interface Props { interface Props {
encryptionPublicKey: Uint8Array | undefined; encryptionPublicKey: Uint8Array | undefined;
waku: Waku | undefined; waku: Waku | undefined;
signer: Signer | undefined;
address: string | undefined; address: string | undefined;
providerRequest: providerRequest:
| ((request: { method: string; params?: Array<any> }) => Promise<any>) | ((request: { method: string; params?: Array<any> }) => Promise<any>)
@ -17,7 +15,6 @@ interface Props {
} }
export default function BroadcastPublicKey({ export default function BroadcastPublicKey({
signer,
encryptionPublicKey, encryptionPublicKey,
address, address,
waku, waku,
@ -25,18 +22,12 @@ export default function BroadcastPublicKey({
}: Props) { }: Props) {
const broadcastPublicKey = () => { const broadcastPublicKey = () => {
if (!encryptionPublicKey) return; if (!encryptionPublicKey) return;
if (!signer) return;
if (!address) return; if (!address) return;
if (!waku) return; if (!waku) return;
if (!providerRequest) return; if (!providerRequest) return;
console.log('Creating Public Key Message'); console.log('Creating Public Key Message');
createPublicKeyMessage( createPublicKeyMessage(address, encryptionPublicKey, providerRequest)
signer,
address,
encryptionPublicKey,
providerRequest
)
.then((msg) => { .then((msg) => {
console.log('Public Key Message created'); console.log('Public Key Message created');
encodePublicKeyWakuMessage(msg) encodePublicKeyWakuMessage(msg)
@ -63,7 +54,7 @@ export default function BroadcastPublicKey({
variant="contained" variant="contained"
color="primary" color="primary"
onClick={broadcastPublicKey} onClick={broadcastPublicKey}
disabled={!encryptionPublicKey || !waku || !signer} disabled={!encryptionPublicKey || !waku || !address || !providerRequest}
> >
Broadcast Encryption Public Key Broadcast Encryption Public Key
</Button> </Button>

View File

@ -1,6 +1,5 @@
import { Button } from '@material-ui/core'; import { Button } from '@material-ui/core';
import React from 'react'; import React from 'react';
import { Signer } from '@ethersproject/abstract-signer';
import { ethers } from 'ethers'; import { ethers } from 'ethers';
import { Web3Provider } from '@ethersproject/providers/src.ts/web3-provider'; import { Web3Provider } from '@ethersproject/providers/src.ts/web3-provider';
@ -8,15 +7,10 @@ declare let window: any;
interface Props { interface Props {
setAddress: (address: string) => void; setAddress: (address: string) => void;
setSigner: (signer: Signer) => void;
setProvider: (provider: Web3Provider) => void; setProvider: (provider: Web3Provider) => void;
} }
export default function ConnectWallet({ export default function ConnectWallet({ setAddress, setProvider }: Props) {
setAddress,
setSigner,
setProvider,
}: Props) {
const connectWallet = () => { const connectWallet = () => {
try { try {
window.ethereum window.ethereum
@ -25,7 +19,6 @@ export default function ConnectWallet({
const _provider = new ethers.providers.Web3Provider(window.ethereum); const _provider = new ethers.providers.Web3Provider(window.ethereum);
setAddress(accounts[0]); setAddress(accounts[0]);
setProvider(_provider); setProvider(_provider);
setSigner(_provider.getSigner());
}); });
} catch (e) { } catch (e) {
console.error('No web3 provider available'); console.error('No web3 provider available');

View File

@ -1,6 +1,5 @@
import '@ethersproject/shims'; import '@ethersproject/shims';
import { Signer } from '@ethersproject/abstract-signer';
import { PublicKeyMessage } from './messaging/wire'; import { PublicKeyMessage } from './messaging/wire';
import { hexToBuf, equalByteArrays, bufToHex } from 'js-waku/lib/utils'; import { hexToBuf, equalByteArrays, bufToHex } from 'js-waku/lib/utils';
import * as sigUtil from 'eth-sig-util'; import * as sigUtil from 'eth-sig-util';
@ -11,7 +10,6 @@ import * as sigUtil from 'eth-sig-util';
* Ethereum Address holder. * Ethereum Address holder.
*/ */
export async function createPublicKeyMessage( export async function createPublicKeyMessage(
web3Signer: Signer,
address: string, address: string,
encryptionPublicKey: Uint8Array, encryptionPublicKey: Uint8Array,
providerRequest: (request: { providerRequest: (request: {
@ -74,7 +72,7 @@ export async function signEncryptionKey(
const msgParams = buildMsgParams(encryptionPublicKey, fromAddress); const msgParams = buildMsgParams(encryptionPublicKey, fromAddress);
const result = await providerRequest({ const result = await providerRequest({
method: 'eth_signTypedData_v4', method: 'eth_signTypedData_v3',
params: [fromAddress, msgParams], params: [fromAddress, msgParams],
from: fromAddress, from: fromAddress,
}); });

View File

@ -5,6 +5,7 @@
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "eth-pm",
"version": "0.1.0", "version": "0.1.0",
"dependencies": { "dependencies": {
"@material-ui/core": "^4.11.4", "@material-ui/core": "^4.11.4",
@ -15,6 +16,7 @@
"@types/jest": "^26.0.15", "@types/jest": "^26.0.15",
"@types/react": "^17.0.0", "@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0", "@types/react-dom": "^17.0.0",
"eth-sig-util": "^3.0.1",
"ethers": "^5.2.0", "ethers": "^5.2.0",
"fontsource-roboto": "^4.0.0", "fontsource-roboto": "^4.0.0",
"js-waku": "../../build/main", "js-waku": "../../build/main",
@ -4174,6 +4176,14 @@
"@babel/types": "^7.3.0" "@babel/types": "^7.3.0"
} }
}, },
"node_modules/@types/bn.js": {
"version": "4.11.6",
"resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-4.11.6.tgz",
"integrity": "sha512-pqr857jrp2kPuO9uRjZ3PwnJTjoQy+fcdxvBTvHm6dkmEL9q+hDD/2j/0ELOBPtPnS8LjCX0gI9nbl8lVkadpg==",
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/eslint": { "node_modules/@types/eslint": {
"version": "7.2.13", "version": "7.2.13",
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-7.2.13.tgz", "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-7.2.13.tgz",
@ -4275,6 +4285,14 @@
"resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz",
"integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==" "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA=="
}, },
"node_modules/@types/pbkdf2": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/@types/pbkdf2/-/pbkdf2-3.1.0.tgz",
"integrity": "sha512-Cf63Rv7jCQ0LaL8tNXmEyqTHuIJxRdlS5vMh1mj5voN4+QFhVZnlZruezqpWYDiJ8UTzhP0VmeLXCmBk66YrMQ==",
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/prettier": { "node_modules/@types/prettier": {
"version": "2.3.0", "version": "2.3.0",
"resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.3.0.tgz", "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.3.0.tgz",
@ -4329,6 +4347,14 @@
"resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.1.tgz", "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.1.tgz",
"integrity": "sha512-EaCxbanVeyxDRTQBkdLb3Bvl/HK7PBK6UJjsSixB0iHKoWxE5uu2Q/DgtpOhPIojN0Zl1whvOd7PoHs2P0s5eA==" "integrity": "sha512-EaCxbanVeyxDRTQBkdLb3Bvl/HK7PBK6UJjsSixB0iHKoWxE5uu2Q/DgtpOhPIojN0Zl1whvOd7PoHs2P0s5eA=="
}, },
"node_modules/@types/secp256k1": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/@types/secp256k1/-/secp256k1-4.0.3.tgz",
"integrity": "sha512-Da66lEIFeIz9ltsdMZcpQvmrmmoqrfju8pm1BH8WbYjZSwUgCwXLb9C+9XYogwBITnbsSaMdVPb2ekf7TV+03w==",
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/source-list-map": { "node_modules/@types/source-list-map": {
"version": "0.1.2", "version": "0.1.2",
"resolved": "https://registry.npmjs.org/@types/source-list-map/-/source-list-map-0.1.2.tgz", "resolved": "https://registry.npmjs.org/@types/source-list-map/-/source-list-map-0.1.2.tgz",
@ -5887,6 +5913,14 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/base-x": {
"version": "3.0.8",
"resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.8.tgz",
"integrity": "sha512-Rl/1AWP4J/zRrk54hhlxH4drNxPJXYUaKffODVI53/dAsV4t9fBxyxYKAVPU1XBHxYwOWP9h9H0hM2MVw4YfJA==",
"dependencies": {
"safe-buffer": "^5.0.1"
}
},
"node_modules/base/node_modules/define-property": { "node_modules/base/node_modules/define-property": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz",
@ -5967,6 +6001,11 @@
"file-uri-to-path": "1.0.0" "file-uri-to-path": "1.0.0"
} }
}, },
"node_modules/blakejs": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/blakejs/-/blakejs-1.1.1.tgz",
"integrity": "sha512-bLG6PHOCZJKNshTjGRBvET0vTciwQE6zFKOKKXPDJfwFBd4Ac0yBfPZqcGvGJap50l7ktvlpFqc2jGVaUgbJgg=="
},
"node_modules/bluebird": { "node_modules/bluebird": {
"version": "3.7.2", "version": "3.7.2",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz",
@ -6173,6 +6212,24 @@
"url": "https://opencollective.com/browserslist" "url": "https://opencollective.com/browserslist"
} }
}, },
"node_modules/bs58": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz",
"integrity": "sha1-vhYedsNU9veIrkBx9j806MTwpCo=",
"dependencies": {
"base-x": "^3.0.2"
}
},
"node_modules/bs58check": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/bs58check/-/bs58check-2.1.2.tgz",
"integrity": "sha512-0TS1jicxdU09dwJMNZtVAfzPi6Q6QeN0pM1Fkzrjn+XYHvzMKPU3pHVpva+769iNVSfIYWf7LJ6WR+BuuMf8cA==",
"dependencies": {
"bs58": "^4.0.0",
"create-hash": "^1.1.0",
"safe-buffer": "^5.1.2"
}
},
"node_modules/bser": { "node_modules/bser": {
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/bser/-/bser-2.1.1.tgz", "resolved": "https://registry.npmjs.org/bser/-/bser-2.1.1.tgz",
@ -9676,6 +9733,76 @@
"node": ">= 0.6" "node": ">= 0.6"
} }
}, },
"node_modules/eth-sig-util": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-3.0.1.tgz",
"integrity": "sha512-0Us50HiGGvZgjtWTyAI/+qTzYPMLy5Q451D0Xy68bxq1QMWdoOddDwGvsqcFT27uohKgalM9z/yxplyt+mY2iQ==",
"dependencies": {
"ethereumjs-abi": "^0.6.8",
"ethereumjs-util": "^5.1.1",
"tweetnacl": "^1.0.3",
"tweetnacl-util": "^0.15.0"
}
},
"node_modules/ethereum-cryptography": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/ethereum-cryptography/-/ethereum-cryptography-0.1.3.tgz",
"integrity": "sha512-w8/4x1SGGzc+tO97TASLja6SLd3fRIK2tLVcV2Gx4IB21hE19atll5Cq9o3d0ZmAYC/8aw0ipieTSiekAea4SQ==",
"dependencies": {
"@types/pbkdf2": "^3.0.0",
"@types/secp256k1": "^4.0.1",
"blakejs": "^1.1.0",
"browserify-aes": "^1.2.0",
"bs58check": "^2.1.2",
"create-hash": "^1.2.0",
"create-hmac": "^1.1.7",
"hash.js": "^1.1.7",
"keccak": "^3.0.0",
"pbkdf2": "^3.0.17",
"randombytes": "^2.1.0",
"safe-buffer": "^5.1.2",
"scrypt-js": "^3.0.0",
"secp256k1": "^4.0.1",
"setimmediate": "^1.0.5"
}
},
"node_modules/ethereumjs-abi": {
"version": "0.6.8",
"resolved": "https://registry.npmjs.org/ethereumjs-abi/-/ethereumjs-abi-0.6.8.tgz",
"integrity": "sha512-Tx0r/iXI6r+lRsdvkFDlut0N08jWMnKRZ6Gkq+Nmw75lZe4e6o3EkSnkaBP5NF6+m5PTGAr9JP43N3LyeoglsA==",
"dependencies": {
"bn.js": "^4.11.8",
"ethereumjs-util": "^6.0.0"
}
},
"node_modules/ethereumjs-abi/node_modules/ethereumjs-util": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-6.2.1.tgz",
"integrity": "sha512-W2Ktez4L01Vexijrm5EB6w7dg4n/TgpoYU4avuT5T3Vmnw/eCRtiBrJfQYS/DCSvDIOLn2k57GcHdeBcgVxAqw==",
"dependencies": {
"@types/bn.js": "^4.11.3",
"bn.js": "^4.11.0",
"create-hash": "^1.1.2",
"elliptic": "^6.5.2",
"ethereum-cryptography": "^0.1.3",
"ethjs-util": "0.1.6",
"rlp": "^2.2.3"
}
},
"node_modules/ethereumjs-util": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.1.tgz",
"integrity": "sha512-v3kT+7zdyCm1HIqWlLNrHGqHGLpGYIhjeHxQjnDXjLT2FyGJDsd3LWMYUo7pAFRrk86CR3nUJfhC81CCoJNNGQ==",
"dependencies": {
"bn.js": "^4.11.0",
"create-hash": "^1.1.2",
"elliptic": "^6.5.2",
"ethereum-cryptography": "^0.1.3",
"ethjs-util": "^0.1.3",
"rlp": "^2.0.0",
"safe-buffer": "^5.1.1"
}
},
"node_modules/ethers": { "node_modules/ethers": {
"version": "5.3.1", "version": "5.3.1",
"resolved": "https://registry.npmjs.org/ethers/-/ethers-5.3.1.tgz", "resolved": "https://registry.npmjs.org/ethers/-/ethers-5.3.1.tgz",
@ -9723,6 +9850,19 @@
"@ethersproject/wordlists": "5.3.0" "@ethersproject/wordlists": "5.3.0"
} }
}, },
"node_modules/ethjs-util": {
"version": "0.1.6",
"resolved": "https://registry.npmjs.org/ethjs-util/-/ethjs-util-0.1.6.tgz",
"integrity": "sha512-CUnVOQq7gSpDHZVVrQW8ExxUETWrnrvXYvYz55wOU8Uj4VCgw56XC2B/fVqQN+f7gmrnRHSLVnFAwsCuNwji8w==",
"dependencies": {
"is-hex-prefixed": "1.0.0",
"strip-hex-prefix": "1.0.0"
},
"engines": {
"node": ">=6.5.0",
"npm": ">=3"
}
},
"node_modules/eventemitter3": { "node_modules/eventemitter3": {
"version": "4.0.7", "version": "4.0.7",
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz", "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz",
@ -12144,6 +12284,15 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/is-hex-prefixed": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-hex-prefixed/-/is-hex-prefixed-1.0.0.tgz",
"integrity": "sha1-fY035q135dEnFIkTxXPggtd39VQ=",
"engines": {
"node": ">=6.5.0",
"npm": ">=3"
}
},
"node_modules/is-in-browser": { "node_modules/is-in-browser": {
"version": "1.1.3", "version": "1.1.3",
"resolved": "https://registry.npmjs.org/is-in-browser/-/is-in-browser-1.1.3.tgz", "resolved": "https://registry.npmjs.org/is-in-browser/-/is-in-browser-1.1.3.tgz",
@ -13643,6 +13792,19 @@
"node": ">=4.0" "node": ">=4.0"
} }
}, },
"node_modules/keccak": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/keccak/-/keccak-3.0.1.tgz",
"integrity": "sha512-epq90L9jlFWCW7+pQa6JOnKn2Xgl2mtI664seYR6MHskvI9agt7AnDqmAlp9TqU4/caMYbA08Hi5DMZAl5zdkA==",
"hasInstallScript": true,
"dependencies": {
"node-addon-api": "^2.0.0",
"node-gyp-build": "^4.2.0"
},
"engines": {
"node": ">=10.0.0"
}
},
"node_modules/killable": { "node_modules/killable": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/killable/-/killable-1.0.1.tgz", "resolved": "https://registry.npmjs.org/killable/-/killable-1.0.1.tgz",
@ -14422,6 +14584,11 @@
"tslib": "^2.0.3" "tslib": "^2.0.3"
} }
}, },
"node_modules/node-addon-api": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz",
"integrity": "sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA=="
},
"node_modules/node-forge": { "node_modules/node-forge": {
"version": "0.10.0", "version": "0.10.0",
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.10.0.tgz", "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.10.0.tgz",
@ -14430,6 +14597,16 @@
"node": ">= 6.0.0" "node": ">= 6.0.0"
} }
}, },
"node_modules/node-gyp-build": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.2.3.tgz",
"integrity": "sha512-MN6ZpzmfNCRM+3t57PTJHgHyw/h4OWnZ6mR8P5j/uZtqQr46RRuDE/P+g3n0YR/AiYXeWixZZzaip77gdICfRg==",
"bin": {
"node-gyp-build": "bin.js",
"node-gyp-build-optional": "optional.js",
"node-gyp-build-test": "build-test.js"
}
},
"node_modules/node-int64": { "node_modules/node-int64": {
"version": "0.4.0", "version": "0.4.0",
"resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz",
@ -18371,6 +18548,17 @@
"inherits": "^2.0.1" "inherits": "^2.0.1"
} }
}, },
"node_modules/rlp": {
"version": "2.2.6",
"resolved": "https://registry.npmjs.org/rlp/-/rlp-2.2.6.tgz",
"integrity": "sha512-HAfAmL6SDYNWPUOJNrM500x4Thn4PZsEy5pijPh40U9WfNk0z15hUYzO9xVIMAdIHdFtD8CBDHd75Td1g36Mjg==",
"dependencies": {
"bn.js": "^4.11.1"
},
"bin": {
"rlp": "bin/rlp"
}
},
"node_modules/rollup": { "node_modules/rollup": {
"version": "1.32.1", "version": "1.32.1",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-1.32.1.tgz", "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.32.1.tgz",
@ -18864,6 +19052,20 @@
"resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-3.0.1.tgz", "resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-3.0.1.tgz",
"integrity": "sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA==" "integrity": "sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA=="
}, },
"node_modules/secp256k1": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-4.0.2.tgz",
"integrity": "sha512-UDar4sKvWAksIlfX3xIaQReADn+WFnHvbVujpcbr+9Sf/69odMwy2MUsz5CKLQgX9nsIyrjuxL2imVyoNHa3fg==",
"hasInstallScript": true,
"dependencies": {
"elliptic": "^6.5.2",
"node-addon-api": "^2.0.0",
"node-gyp-build": "^4.2.0"
},
"engines": {
"node": ">=10.0.0"
}
},
"node_modules/select-hose": { "node_modules/select-hose": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/select-hose/-/select-hose-2.0.0.tgz", "resolved": "https://registry.npmjs.org/select-hose/-/select-hose-2.0.0.tgz",
@ -19937,6 +20139,18 @@
"node": ">=6" "node": ">=6"
} }
}, },
"node_modules/strip-hex-prefix": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/strip-hex-prefix/-/strip-hex-prefix-1.0.0.tgz",
"integrity": "sha1-DF8VX+8RUTczd96du1iNoFUA428=",
"dependencies": {
"is-hex-prefixed": "1.0.0"
},
"engines": {
"node": ">=6.5.0",
"npm": ">=3"
}
},
"node_modules/strip-indent": { "node_modules/strip-indent": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-3.0.0.tgz", "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-3.0.0.tgz",
@ -20742,6 +20956,16 @@
"resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz", "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz",
"integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=" "integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY="
}, },
"node_modules/tweetnacl": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz",
"integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw=="
},
"node_modules/tweetnacl-util": {
"version": "0.15.1",
"resolved": "https://registry.npmjs.org/tweetnacl-util/-/tweetnacl-util-0.15.1.tgz",
"integrity": "sha512-RKJBIj8lySrShN4w6i/BonWp2Z/uxwC3h4y7xsRrpP59ZboCd0GpEVsOnMDYLMmKBpYhb5TgHzZXy7wTfYFBRw=="
},
"node_modules/type": { "node_modules/type": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz",
@ -25898,6 +26122,14 @@
"@babel/types": "^7.3.0" "@babel/types": "^7.3.0"
} }
}, },
"@types/bn.js": {
"version": "4.11.6",
"resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-4.11.6.tgz",
"integrity": "sha512-pqr857jrp2kPuO9uRjZ3PwnJTjoQy+fcdxvBTvHm6dkmEL9q+hDD/2j/0ELOBPtPnS8LjCX0gI9nbl8lVkadpg==",
"requires": {
"@types/node": "*"
}
},
"@types/eslint": { "@types/eslint": {
"version": "7.2.13", "version": "7.2.13",
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-7.2.13.tgz", "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-7.2.13.tgz",
@ -25999,6 +26231,14 @@
"resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz",
"integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==" "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA=="
}, },
"@types/pbkdf2": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/@types/pbkdf2/-/pbkdf2-3.1.0.tgz",
"integrity": "sha512-Cf63Rv7jCQ0LaL8tNXmEyqTHuIJxRdlS5vMh1mj5voN4+QFhVZnlZruezqpWYDiJ8UTzhP0VmeLXCmBk66YrMQ==",
"requires": {
"@types/node": "*"
}
},
"@types/prettier": { "@types/prettier": {
"version": "2.3.0", "version": "2.3.0",
"resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.3.0.tgz", "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.3.0.tgz",
@ -26053,6 +26293,14 @@
"resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.1.tgz", "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.1.tgz",
"integrity": "sha512-EaCxbanVeyxDRTQBkdLb3Bvl/HK7PBK6UJjsSixB0iHKoWxE5uu2Q/DgtpOhPIojN0Zl1whvOd7PoHs2P0s5eA==" "integrity": "sha512-EaCxbanVeyxDRTQBkdLb3Bvl/HK7PBK6UJjsSixB0iHKoWxE5uu2Q/DgtpOhPIojN0Zl1whvOd7PoHs2P0s5eA=="
}, },
"@types/secp256k1": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/@types/secp256k1/-/secp256k1-4.0.3.tgz",
"integrity": "sha512-Da66lEIFeIz9ltsdMZcpQvmrmmoqrfju8pm1BH8WbYjZSwUgCwXLb9C+9XYogwBITnbsSaMdVPb2ekf7TV+03w==",
"requires": {
"@types/node": "*"
}
},
"@types/source-list-map": { "@types/source-list-map": {
"version": "0.1.2", "version": "0.1.2",
"resolved": "https://registry.npmjs.org/@types/source-list-map/-/source-list-map-0.1.2.tgz", "resolved": "https://registry.npmjs.org/@types/source-list-map/-/source-list-map-0.1.2.tgz",
@ -27286,6 +27534,14 @@
} }
} }
}, },
"base-x": {
"version": "3.0.8",
"resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.8.tgz",
"integrity": "sha512-Rl/1AWP4J/zRrk54hhlxH4drNxPJXYUaKffODVI53/dAsV4t9fBxyxYKAVPU1XBHxYwOWP9h9H0hM2MVw4YfJA==",
"requires": {
"safe-buffer": "^5.0.1"
}
},
"base64-js": { "base64-js": {
"version": "1.5.1", "version": "1.5.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
@ -27332,6 +27588,11 @@
"file-uri-to-path": "1.0.0" "file-uri-to-path": "1.0.0"
} }
}, },
"blakejs": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/blakejs/-/blakejs-1.1.1.tgz",
"integrity": "sha512-bLG6PHOCZJKNshTjGRBvET0vTciwQE6zFKOKKXPDJfwFBd4Ac0yBfPZqcGvGJap50l7ktvlpFqc2jGVaUgbJgg=="
},
"bluebird": { "bluebird": {
"version": "3.7.2", "version": "3.7.2",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz",
@ -27522,6 +27783,24 @@
"node-releases": "^1.1.71" "node-releases": "^1.1.71"
} }
}, },
"bs58": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz",
"integrity": "sha1-vhYedsNU9veIrkBx9j806MTwpCo=",
"requires": {
"base-x": "^3.0.2"
}
},
"bs58check": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/bs58check/-/bs58check-2.1.2.tgz",
"integrity": "sha512-0TS1jicxdU09dwJMNZtVAfzPi6Q6QeN0pM1Fkzrjn+XYHvzMKPU3pHVpva+769iNVSfIYWf7LJ6WR+BuuMf8cA==",
"requires": {
"bs58": "^4.0.0",
"create-hash": "^1.1.0",
"safe-buffer": "^5.1.2"
}
},
"bser": { "bser": {
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/bser/-/bser-2.1.1.tgz", "resolved": "https://registry.npmjs.org/bser/-/bser-2.1.1.tgz",
@ -30212,6 +30491,78 @@
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
"integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc="
}, },
"eth-sig-util": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-3.0.1.tgz",
"integrity": "sha512-0Us50HiGGvZgjtWTyAI/+qTzYPMLy5Q451D0Xy68bxq1QMWdoOddDwGvsqcFT27uohKgalM9z/yxplyt+mY2iQ==",
"requires": {
"ethereumjs-abi": "^0.6.8",
"ethereumjs-util": "^5.1.1",
"tweetnacl": "^1.0.3",
"tweetnacl-util": "^0.15.0"
}
},
"ethereum-cryptography": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/ethereum-cryptography/-/ethereum-cryptography-0.1.3.tgz",
"integrity": "sha512-w8/4x1SGGzc+tO97TASLja6SLd3fRIK2tLVcV2Gx4IB21hE19atll5Cq9o3d0ZmAYC/8aw0ipieTSiekAea4SQ==",
"requires": {
"@types/pbkdf2": "^3.0.0",
"@types/secp256k1": "^4.0.1",
"blakejs": "^1.1.0",
"browserify-aes": "^1.2.0",
"bs58check": "^2.1.2",
"create-hash": "^1.2.0",
"create-hmac": "^1.1.7",
"hash.js": "^1.1.7",
"keccak": "^3.0.0",
"pbkdf2": "^3.0.17",
"randombytes": "^2.1.0",
"safe-buffer": "^5.1.2",
"scrypt-js": "^3.0.0",
"secp256k1": "^4.0.1",
"setimmediate": "^1.0.5"
}
},
"ethereumjs-abi": {
"version": "0.6.8",
"resolved": "https://registry.npmjs.org/ethereumjs-abi/-/ethereumjs-abi-0.6.8.tgz",
"integrity": "sha512-Tx0r/iXI6r+lRsdvkFDlut0N08jWMnKRZ6Gkq+Nmw75lZe4e6o3EkSnkaBP5NF6+m5PTGAr9JP43N3LyeoglsA==",
"requires": {
"bn.js": "^4.11.8",
"ethereumjs-util": "^6.0.0"
},
"dependencies": {
"ethereumjs-util": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-6.2.1.tgz",
"integrity": "sha512-W2Ktez4L01Vexijrm5EB6w7dg4n/TgpoYU4avuT5T3Vmnw/eCRtiBrJfQYS/DCSvDIOLn2k57GcHdeBcgVxAqw==",
"requires": {
"@types/bn.js": "^4.11.3",
"bn.js": "^4.11.0",
"create-hash": "^1.1.2",
"elliptic": "^6.5.2",
"ethereum-cryptography": "^0.1.3",
"ethjs-util": "0.1.6",
"rlp": "^2.2.3"
}
}
}
},
"ethereumjs-util": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.1.tgz",
"integrity": "sha512-v3kT+7zdyCm1HIqWlLNrHGqHGLpGYIhjeHxQjnDXjLT2FyGJDsd3LWMYUo7pAFRrk86CR3nUJfhC81CCoJNNGQ==",
"requires": {
"bn.js": "^4.11.0",
"create-hash": "^1.1.2",
"elliptic": "^6.5.2",
"ethereum-cryptography": "^0.1.3",
"ethjs-util": "^0.1.3",
"rlp": "^2.0.0",
"safe-buffer": "^5.1.1"
}
},
"ethers": { "ethers": {
"version": "5.3.1", "version": "5.3.1",
"resolved": "https://registry.npmjs.org/ethers/-/ethers-5.3.1.tgz", "resolved": "https://registry.npmjs.org/ethers/-/ethers-5.3.1.tgz",
@ -30249,6 +30600,15 @@
"@ethersproject/wordlists": "5.3.0" "@ethersproject/wordlists": "5.3.0"
} }
}, },
"ethjs-util": {
"version": "0.1.6",
"resolved": "https://registry.npmjs.org/ethjs-util/-/ethjs-util-0.1.6.tgz",
"integrity": "sha512-CUnVOQq7gSpDHZVVrQW8ExxUETWrnrvXYvYz55wOU8Uj4VCgw56XC2B/fVqQN+f7gmrnRHSLVnFAwsCuNwji8w==",
"requires": {
"is-hex-prefixed": "1.0.0",
"strip-hex-prefix": "1.0.0"
}
},
"eventemitter3": { "eventemitter3": {
"version": "4.0.7", "version": "4.0.7",
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz", "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz",
@ -32150,6 +32510,11 @@
"is-extglob": "^2.1.1" "is-extglob": "^2.1.1"
} }
}, },
"is-hex-prefixed": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-hex-prefixed/-/is-hex-prefixed-1.0.0.tgz",
"integrity": "sha1-fY035q135dEnFIkTxXPggtd39VQ="
},
"is-in-browser": { "is-in-browser": {
"version": "1.1.3", "version": "1.1.3",
"resolved": "https://registry.npmjs.org/is-in-browser/-/is-in-browser-1.1.3.tgz", "resolved": "https://registry.npmjs.org/is-in-browser/-/is-in-browser-1.1.3.tgz",
@ -33301,6 +33666,15 @@
"object.assign": "^4.1.2" "object.assign": "^4.1.2"
} }
}, },
"keccak": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/keccak/-/keccak-3.0.1.tgz",
"integrity": "sha512-epq90L9jlFWCW7+pQa6JOnKn2Xgl2mtI664seYR6MHskvI9agt7AnDqmAlp9TqU4/caMYbA08Hi5DMZAl5zdkA==",
"requires": {
"node-addon-api": "^2.0.0",
"node-gyp-build": "^4.2.0"
}
},
"killable": { "killable": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/killable/-/killable-1.0.1.tgz", "resolved": "https://registry.npmjs.org/killable/-/killable-1.0.1.tgz",
@ -33928,11 +34302,21 @@
"tslib": "^2.0.3" "tslib": "^2.0.3"
} }
}, },
"node-addon-api": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz",
"integrity": "sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA=="
},
"node-forge": { "node-forge": {
"version": "0.10.0", "version": "0.10.0",
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.10.0.tgz", "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.10.0.tgz",
"integrity": "sha512-PPmu8eEeG9saEUvI97fm4OYxXVB6bFvyNTyiUOBichBpFG8A1Ljw3bY62+5oOjDEMHRnd0Y7HQ+x7uzxOzC6JA==" "integrity": "sha512-PPmu8eEeG9saEUvI97fm4OYxXVB6bFvyNTyiUOBichBpFG8A1Ljw3bY62+5oOjDEMHRnd0Y7HQ+x7uzxOzC6JA=="
}, },
"node-gyp-build": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.2.3.tgz",
"integrity": "sha512-MN6ZpzmfNCRM+3t57PTJHgHyw/h4OWnZ6mR8P5j/uZtqQr46RRuDE/P+g3n0YR/AiYXeWixZZzaip77gdICfRg=="
},
"node-int64": { "node-int64": {
"version": "0.4.0", "version": "0.4.0",
"resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz",
@ -37038,6 +37422,14 @@
"inherits": "^2.0.1" "inherits": "^2.0.1"
} }
}, },
"rlp": {
"version": "2.2.6",
"resolved": "https://registry.npmjs.org/rlp/-/rlp-2.2.6.tgz",
"integrity": "sha512-HAfAmL6SDYNWPUOJNrM500x4Thn4PZsEy5pijPh40U9WfNk0z15hUYzO9xVIMAdIHdFtD8CBDHd75Td1g36Mjg==",
"requires": {
"bn.js": "^4.11.1"
}
},
"rollup": { "rollup": {
"version": "1.32.1", "version": "1.32.1",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-1.32.1.tgz", "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.32.1.tgz",
@ -37399,6 +37791,16 @@
"resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-3.0.1.tgz", "resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-3.0.1.tgz",
"integrity": "sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA==" "integrity": "sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA=="
}, },
"secp256k1": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-4.0.2.tgz",
"integrity": "sha512-UDar4sKvWAksIlfX3xIaQReADn+WFnHvbVujpcbr+9Sf/69odMwy2MUsz5CKLQgX9nsIyrjuxL2imVyoNHa3fg==",
"requires": {
"elliptic": "^6.5.2",
"node-addon-api": "^2.0.0",
"node-gyp-build": "^4.2.0"
}
},
"select-hose": { "select-hose": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/select-hose/-/select-hose-2.0.0.tgz", "resolved": "https://registry.npmjs.org/select-hose/-/select-hose-2.0.0.tgz",
@ -38312,6 +38714,14 @@
"resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz",
"integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==" "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA=="
}, },
"strip-hex-prefix": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/strip-hex-prefix/-/strip-hex-prefix-1.0.0.tgz",
"integrity": "sha1-DF8VX+8RUTczd96du1iNoFUA428=",
"requires": {
"is-hex-prefixed": "1.0.0"
}
},
"strip-indent": { "strip-indent": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-3.0.0.tgz", "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-3.0.0.tgz",
@ -38937,6 +39347,16 @@
"resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz", "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz",
"integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=" "integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY="
}, },
"tweetnacl": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz",
"integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw=="
},
"tweetnacl-util": {
"version": "0.15.1",
"resolved": "https://registry.npmjs.org/tweetnacl-util/-/tweetnacl-util-0.15.1.tgz",
"integrity": "sha512-RKJBIj8lySrShN4w6i/BonWp2Z/uxwC3h4y7xsRrpP59ZboCd0GpEVsOnMDYLMmKBpYhb5TgHzZXy7wTfYFBRw=="
},
"type": { "type": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz",

View File

@ -12,6 +12,7 @@
"@types/jest": "^26.0.15", "@types/jest": "^26.0.15",
"@types/react": "^17.0.0", "@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0", "@types/react-dom": "^17.0.0",
"eth-sig-util": "^3.0.1",
"ethers": "^5.2.0", "ethers": "^5.2.0",
"fontsource-roboto": "^4.0.0", "fontsource-roboto": "^4.0.0",
"js-waku": "../../build/main", "js-waku": "../../build/main",

View File

@ -3,7 +3,6 @@ import '@ethersproject/shims';
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import './App.css'; import './App.css';
import { Waku } from 'js-waku'; import { Waku } from 'js-waku';
import { Signer } from '@ethersproject/abstract-signer';
import { KeyPair } from './crypto'; import { KeyPair } from './crypto';
import { Message } from './messaging/Messages'; import { Message } from './messaging/Messages';
import 'fontsource-roboto'; import 'fontsource-roboto';
@ -25,6 +24,7 @@ import {
initWaku, initWaku,
PublicKeyContentTopic, PublicKeyContentTopic,
} from './waku'; } from './waku';
import { Web3Provider } from '@ethersproject/providers/src.ts/web3-provider';
import ConnectWallet from './ConnectWallet'; import ConnectWallet from './ConnectWallet';
const theme = createMuiTheme({ const theme = createMuiTheme({
@ -67,8 +67,8 @@ const useStyles = makeStyles({
function App() { function App() {
const [waku, setWaku] = useState<Waku>(); const [waku, setWaku] = useState<Waku>();
const [signer, setSigner] = useState<Signer>(); const [provider, setProvider] = useState<Web3Provider>();
const [EncryptionKeyPair, setEncryptionKeyPair] = useState< const [encryptionKeyPair, setEncryptionKeyPair] = useState<
KeyPair | undefined KeyPair | undefined
>(); >();
const [publicKeys, setPublicKeys] = useState<Map<string, Uint8Array>>( const [publicKeys, setPublicKeys] = useState<Map<string, Uint8Array>>(
@ -120,21 +120,21 @@ function App() {
useEffect(() => { useEffect(() => {
if (!waku) return; if (!waku) return;
if (!EncryptionKeyPair) return; if (!encryptionKeyPair) return;
waku.relay.addDecryptionKey(EncryptionKeyPair.privateKey); waku.relay.addDecryptionKey(encryptionKeyPair.privateKey);
return function cleanUp() { return function cleanUp() {
if (!waku) return; if (!waku) return;
if (!EncryptionKeyPair) return; if (!encryptionKeyPair) return;
waku.relay.deleteDecryptionKey(EncryptionKeyPair.privateKey); waku.relay.deleteDecryptionKey(encryptionKeyPair.privateKey);
}; };
}, [waku, EncryptionKeyPair]); }, [waku, encryptionKeyPair]);
useEffect(() => { useEffect(() => {
if (!waku) return; if (!waku) return;
if (!EncryptionKeyPair) return; if (!encryptionKeyPair) return;
if (!address) return; if (!address) return;
const observerPrivateMessage = handlePrivateMessage.bind( const observerPrivateMessage = handlePrivateMessage.bind(
@ -154,7 +154,7 @@ function App() {
PrivateMessageContentTopic, PrivateMessageContentTopic,
]); ]);
}; };
}, [waku, address, EncryptionKeyPair]); }, [waku, address, encryptionKeyPair]);
useEffect(() => { useEffect(() => {
if (!waku) return; if (!waku) return;
@ -204,18 +204,22 @@ function App() {
<main className={classes.main}> <main className={classes.main}>
<fieldset> <fieldset>
<legend>Wallet</legend> <legend>Wallet</legend>
<ConnectWallet setAddress={setAddress} setSigner={setSigner} /> <ConnectWallet
setAddress={setAddress}
setProvider={setProvider}
/>
</fieldset> </fieldset>
<fieldset> <fieldset>
<legend>Encryption Key Pair</legend> <legend>Encryption Key Pair</legend>
<KeyPairHandling <KeyPairHandling
encryptionKeyPair={EncryptionKeyPair} encryptionKeyPair={encryptionKeyPair}
setEncryptionKeyPair={setEncryptionKeyPair} setEncryptionKeyPair={setEncryptionKeyPair}
/> />
<BroadcastPublicKey <BroadcastPublicKey
signer={signer} address={address}
EncryptionKeyPair={EncryptionKeyPair} EncryptionKeyPair={encryptionKeyPair}
waku={waku} waku={waku}
providerRequest={provider?.provider?.request}
/> />
</fieldset> </fieldset>
<fieldset> <fieldset>

View File

@ -3,26 +3,30 @@ import React, { useState } from 'react';
import { createPublicKeyMessage, KeyPair } from './crypto'; import { createPublicKeyMessage, KeyPair } from './crypto';
import { PublicKeyMessage } from './messaging/wire'; import { PublicKeyMessage } from './messaging/wire';
import { WakuMessage, Waku } from 'js-waku'; import { WakuMessage, Waku } from 'js-waku';
import { Signer } from '@ethersproject/abstract-signer';
import { PublicKeyContentTopic } from './waku'; import { PublicKeyContentTopic } from './waku';
interface Props { interface Props {
EncryptionKeyPair: KeyPair | undefined; EncryptionKeyPair: KeyPair | undefined;
waku: Waku | undefined; waku: Waku | undefined;
signer: Signer | undefined; address: string | undefined;
providerRequest:
| ((request: { method: string; params?: Array<any> }) => Promise<any>)
| undefined;
} }
export default function BroadcastPublicKey({ export default function BroadcastPublicKey({
signer,
EncryptionKeyPair, EncryptionKeyPair,
waku, waku,
address,
providerRequest,
}: Props) { }: Props) {
const [publicKeyMsg, setPublicKeyMsg] = useState<PublicKeyMessage>(); const [publicKeyMsg, setPublicKeyMsg] = useState<PublicKeyMessage>();
const broadcastPublicKey = () => { const broadcastPublicKey = () => {
if (!EncryptionKeyPair) return; if (!EncryptionKeyPair) return;
if (!signer) return; if (!address) return;
if (!waku) return; if (!waku) return;
if (!providerRequest) return;
if (publicKeyMsg) { if (publicKeyMsg) {
encodePublicKeyWakuMessage(publicKeyMsg) encodePublicKeyWakuMessage(publicKeyMsg)
@ -35,7 +39,11 @@ export default function BroadcastPublicKey({
console.log('Failed to encode Public Key Message in Waku Message'); console.log('Failed to encode Public Key Message in Waku Message');
}); });
} else { } else {
createPublicKeyMessage(signer, EncryptionKeyPair.publicKey) createPublicKeyMessage(
address,
EncryptionKeyPair.publicKey,
providerRequest
)
.then((msg) => { .then((msg) => {
setPublicKeyMsg(msg); setPublicKeyMsg(msg);
encodePublicKeyWakuMessage(msg) encodePublicKeyWakuMessage(msg)
@ -64,7 +72,7 @@ export default function BroadcastPublicKey({
variant="contained" variant="contained"
color="primary" color="primary"
onClick={broadcastPublicKey} onClick={broadcastPublicKey}
disabled={!EncryptionKeyPair || !waku} disabled={!EncryptionKeyPair || !waku || !address || !providerRequest}
> >
Broadcast Encryption Public Key Broadcast Encryption Public Key
</Button> </Button>

View File

@ -1,16 +1,16 @@
import { Button } from '@material-ui/core'; import { Button } from '@material-ui/core';
import React from 'react'; import React from 'react';
import { Signer } from '@ethersproject/abstract-signer';
import { ethers } from 'ethers'; import { ethers } from 'ethers';
import { Web3Provider } from '@ethersproject/providers/src.ts/web3-provider';
declare let window: any; declare let window: any;
interface Props { interface Props {
setAddress: (address: string) => void; setAddress: (address: string) => void;
setSigner: (signer: Signer) => void; setProvider: (provider: Web3Provider) => void;
} }
export default function ConnectWallet({ setAddress, setSigner }: Props) { export default function ConnectWallet({ setAddress, setProvider }: Props) {
const connectWallet = () => { const connectWallet = () => {
try { try {
window.ethereum window.ethereum
@ -18,7 +18,7 @@ export default function ConnectWallet({ setAddress, setSigner }: Props) {
.then((accounts: string[]) => { .then((accounts: string[]) => {
const _provider = new ethers.providers.Web3Provider(window.ethereum); const _provider = new ethers.providers.Web3Provider(window.ethereum);
setAddress(accounts[0]); setAddress(accounts[0]);
setSigner(_provider.getSigner()); setProvider(_provider);
}); });
} catch (e) { } catch (e) {
console.error('No web3 provider available'); console.error('No web3 provider available');

View File

@ -1,10 +1,9 @@
import '@ethersproject/shims'; import '@ethersproject/shims';
import { ethers } from 'ethers';
import { Signer } from '@ethersproject/abstract-signer';
import { PublicKeyMessage } from './messaging/wire'; import { PublicKeyMessage } from './messaging/wire';
import { hexToBuf, equalByteArrays, bufToHex } from 'js-waku/lib/utils'; import { hexToBuf, equalByteArrays, bufToHex } from 'js-waku/lib/utils';
import { generatePrivateKey, getPublicKey } from 'js-waku'; import { generatePrivateKey, getPublicKey } from 'js-waku';
import * as sigUtil from 'eth-sig-util';
export interface KeyPair { export interface KeyPair {
privateKey: Uint8Array; privateKey: Uint8Array;
@ -22,52 +21,95 @@ export async function generateEncryptionKeyPair(): Promise<KeyPair> {
/** /**
* Sign the encryption public key with Web3. This can then be published to let other * Sign the encryption public key with Web3. This can then be published to let other
* users know to use this public key to encrypt messages for the * users know to use this encryption public key to encrypt messages for the
* Ethereum Address holder. * Ethereum Address holder.
*/ */
export async function createPublicKeyMessage( export async function createPublicKeyMessage(
web3Signer: Signer, address: string,
encryptionPublicKey: Uint8Array encryptionPublicKey: Uint8Array,
providerRequest: (request: {
method: string;
params?: Array<any>;
}) => Promise<any>
): Promise<PublicKeyMessage> { ): Promise<PublicKeyMessage> {
const ethAddress = await web3Signer.getAddress(); const signature = await signEncryptionKey(
const signature = await web3Signer.signMessage( encryptionPublicKey,
formatPublicKeyForSignature(encryptionPublicKey) address,
providerRequest
); );
console.log('Asking wallet to sign Public Key Message');
console.log('Public Key Message signed');
return new PublicKeyMessage({ return new PublicKeyMessage({
encryptionPublicKey: encryptionPublicKey, encryptionPublicKey: encryptionPublicKey,
ethAddress: hexToBuf(ethAddress), ethAddress: hexToBuf(address),
signature: hexToBuf(signature), signature: hexToBuf(signature),
}); });
} }
function buildMsgParams(encryptionPublicKey: Uint8Array, fromAddress: string) {
return JSON.stringify({
domain: {
chainId: 1,
name: 'Ethereum Private Message over Waku',
version: '1',
},
message: {
encryptionPublicKey: bufToHex(encryptionPublicKey),
ownerAddress: fromAddress,
},
// Refers to the keys of the *types* object below.
primaryType: 'PublishEncryptionPublicKey',
types: {
EIP712Domain: [
{ name: 'name', type: 'string' },
{ name: 'version', type: 'string' },
{ name: 'chainId', type: 'uint256' },
],
PublishEncryptionPublicKey: [
{ name: 'encryptionPublicKey', type: 'string' },
{ name: 'ownerAddress', type: 'string' },
],
},
});
}
export async function signEncryptionKey(
encryptionPublicKey: Uint8Array,
fromAddress: string,
providerRequest: (request: {
method: string;
params?: Array<any>;
from?: string;
}) => Promise<any>
): Promise<Uint8Array> {
const msgParams = buildMsgParams(encryptionPublicKey, fromAddress);
const result = await providerRequest({
method: 'eth_signTypedData_v3',
params: [fromAddress, msgParams],
from: fromAddress,
});
console.log('TYPED SIGNED:' + JSON.stringify(result));
return hexToBuf(result);
}
/** /**
* Validate that the Encryption Public Key was signed by the holder of the given Ethereum address. * Validate that the Encryption Public Key was signed by the holder of the given Ethereum address.
*/ */
export function validatePublicKeyMessage(msg: PublicKeyMessage): boolean { export function validatePublicKeyMessage(msg: PublicKeyMessage): boolean {
const formattedMsg = formatPublicKeyForSignature(msg.encryptionPublicKey); const recovered = sigUtil.recoverTypedSignature_v4({
try { data: JSON.parse(
const sigAddress = ethers.utils.verifyMessage(formattedMsg, msg.signature); buildMsgParams(msg.encryptionPublicKey, '0x' + bufToHex(msg.ethAddress))
return equalByteArrays(sigAddress, msg.ethAddress); ),
} catch (e) { sig: '0x' + bufToHex(msg.signature),
console.log(
'Failed to verify signature for Public Key Message',
formattedMsg,
msg
);
return false;
}
}
/**
* Prepare encryption public key to be signed for publication.
* The public key is set in on Object `{ encryptionPublicKey: string; }`, converted
* to JSON and then hashed with Keccak256.
* The usage of the object helps ensure the signature is only used in an Eth-PM
* context.
*/
function formatPublicKeyForSignature(encryptionPublicKey: Uint8Array): string {
return JSON.stringify({
encryptionPublicKey: bufToHex(encryptionPublicKey),
}); });
console.log('Recovered', recovered);
console.log('ethAddress', '0x' + bufToHex(msg.ethAddress));
return equalByteArrays(recovered, msg.ethAddress);
} }