From 93665feac88aec1ee57cb0975c5687b50b1628fc Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 24 Jun 2021 15:59:20 +1000 Subject: [PATCH] Generate fresh new keypair, do not use signature as entropy --- examples/eth-dm/src/App.tsx | 2 +- examples/eth-dm/src/crypto.ts | 14 ++------------ 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/examples/eth-dm/src/App.tsx b/examples/eth-dm/src/App.tsx index ab6273e5cf..b94b5f9397 100644 --- a/examples/eth-dm/src/App.tsx +++ b/examples/eth-dm/src/App.tsx @@ -67,7 +67,7 @@ function App() { if (ethDmKeyPair) return; if (!provider) return; - generateEthDmKeyPair(provider.getSigner()) + generateEthDmKeyPair() .then((keyPair) => { setEthDmKeyPair(keyPair); }) diff --git a/examples/eth-dm/src/crypto.ts b/examples/eth-dm/src/crypto.ts index 08a32f8732..4ed906d169 100644 --- a/examples/eth-dm/src/crypto.ts +++ b/examples/eth-dm/src/crypto.ts @@ -5,9 +5,6 @@ import { ethers } from 'ethers'; import { Signer } from '@ethersproject/abstract-signer'; import { PublicKeyMessage } from './messages'; -const Salt = - 'Salt for Eth-Dm, do not share a signature of this message or others could decrypt your messages'; - export interface KeyPair { privateKey: string; publicKey: string; @@ -19,15 +16,8 @@ export interface KeyPair { * the entropy for the EthCrypto keypair. Note that the entropy is hashed with keccak256 * to make the private key. */ -export async function generateEthDmKeyPair( - web3Signer: Signer -): Promise { - const signature = await web3Signer.signMessage(Salt); - // Need to remove '0x' prefix to allow buffer to decode the hex string. - const sigBuf = Buffer.from(signature.slice(2), 'hex'); - const entropy = Buffer.concat([sigBuf, sigBuf]); - const keys = EthCrypto.createIdentity(entropy); - return keys; +export async function generateEthDmKeyPair(): Promise { + return EthCrypto.createIdentity(); } /**