fix js-waku utils
This commit is contained in:
parent
4fd6928735
commit
a962d8c723
|
@ -1,10 +1,9 @@
|
|||
import { BN } from 'bn.js'
|
||||
import { derive } from 'ecies-geth'
|
||||
import { ec } from 'elliptic'
|
||||
import { bufToHex } from 'js-waku/build/main/lib/utils'
|
||||
|
||||
import { idToContentTopic } from './contentTopic'
|
||||
import { hexToBuf } from './utils'
|
||||
import { bufToHex, hexToBuf } from './utils'
|
||||
|
||||
import type { Identity } from '.'
|
||||
|
||||
|
@ -40,7 +39,7 @@ export async function getNegotiatedTopic(
|
|||
const key = EC.keyFromPublic(publicKey.slice(2), 'hex')
|
||||
const sharedSecret = await derive(
|
||||
Buffer.from(identity.privateKey),
|
||||
hexToBuf(key.getPublic('hex'))
|
||||
Buffer.concat([hexToBuf(key.getPublic('hex'))])
|
||||
)
|
||||
return idToContentTopic(bufToHex(sharedSecret))
|
||||
}
|
||||
|
|
|
@ -8,14 +8,16 @@ import type { Waku } from 'js-waku'
|
|||
|
||||
const EC = new ec('secp256k1')
|
||||
|
||||
const hexToBuf = utils.hexToBuf
|
||||
// TODO: rename
|
||||
const hexToBuf = utils.hexToBytes
|
||||
export { hexToBuf }
|
||||
|
||||
// TODO: rename
|
||||
/**
|
||||
* Return hex string with 0x prefix (commonly used for string format of a community id/public key.
|
||||
*/
|
||||
export function bufToHex(buf: Uint8Array): string {
|
||||
return '0x' + utils.bufToHex(buf)
|
||||
return '0x' + utils.bytesToHex(buf)
|
||||
}
|
||||
|
||||
export function compressPublicKey(key: Uint8Array): string {
|
||||
|
|
Loading…
Reference in New Issue