mirror of
https://github.com/waku-org/js-waku.git
synced 2025-01-24 19:29:30 +00:00
Concatenate signature to have enough entropy for eth-crypto
This commit is contained in:
parent
af2b2691f1
commit
85b4879410
@ -1,7 +1,6 @@
|
||||
import '@ethersproject/shims';
|
||||
|
||||
import * as EthCrypto from 'eth-crypto';
|
||||
import { toUtf8Bytes } from '@ethersproject/strings';
|
||||
import { ethers } from 'ethers';
|
||||
import { Signer } from '@ethersproject/abstract-signer';
|
||||
import { PublicKeyMessage } from './messages';
|
||||
@ -24,7 +23,9 @@ export async function generateEthDmKeyPair(
|
||||
web3Signer: Signer
|
||||
): Promise<KeyPair> {
|
||||
const signature = await web3Signer.signMessage(Salt);
|
||||
const entropy = Buffer.from(signature, 'hex');
|
||||
// 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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user