From a962d8c72349f3383b009f81757e5a7c884a8dea Mon Sep 17 00:00:00 2001 From: Felicio Mununga Date: Wed, 25 May 2022 14:42:47 +0200 Subject: [PATCH] fix js-waku utils --- packages/status-js/src/topics.ts | 5 ++--- packages/status-js/src/utils.ts | 6 ++++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/status-js/src/topics.ts b/packages/status-js/src/topics.ts index f4a402f..f197f7d 100644 --- a/packages/status-js/src/topics.ts +++ b/packages/status-js/src/topics.ts @@ -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)) } diff --git a/packages/status-js/src/utils.ts b/packages/status-js/src/utils.ts index 3b7f541..89a20f3 100644 --- a/packages/status-js/src/utils.ts +++ b/packages/status-js/src/utils.ts @@ -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 {