Generate fresh new keypair, do not use signature as entropy

This commit is contained in:
Franck Royer 2021-06-24 15:59:20 +10:00
parent bd0ad81d17
commit 93665feac8
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
2 changed files with 3 additions and 13 deletions

View File

@ -67,7 +67,7 @@ function App() {
if (ethDmKeyPair) return;
if (!provider) return;
generateEthDmKeyPair(provider.getSigner())
generateEthDmKeyPair()
.then((keyPair) => {
setEthDmKeyPair(keyPair);
})

View File

@ -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<KeyPair> {
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<KeyPair> {
return EthCrypto.createIdentity();
}
/**