From c012748bb7b1e604bdd05076f1c281ea6cdb3f83 Mon Sep 17 00:00:00 2001 From: danisharora099 Date: Tue, 15 Nov 2022 18:08:21 +0530 Subject: [PATCH] address comments --- package-lock.json | 30 ++++++++++++++--------- packages/core/package.json | 2 +- packages/core/src/lib/waku_store/index.ts | 6 ++--- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index cffaed34f1..84b02f0ccc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3225,6 +3225,17 @@ } ] }, + "node_modules/@noble/hashes": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.1.3.tgz", + "integrity": "sha512-CE0FCR57H2acVI5UOzIGSSIYxZ6v/HOhDR0Ro9VLyhnzLwx0o8W1mmgaqlEUx4049qJDlIBRztv5k+MM8vbO3A==", + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ] + }, "node_modules/@noble/secp256k1": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/@noble/secp256k1/-/secp256k1-1.7.0.tgz", @@ -8628,11 +8639,6 @@ "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", "dev": true }, - "node_modules/fast-sha256": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/fast-sha256/-/fast-sha256-1.3.0.tgz", - "integrity": "sha512-n11RGP/lrWEFI/bWdygLxhI+pVeo1ZYIVwvvPkW7azl/rOy+F3HYRZ2K5zeE9mmkhQppyv9sQFx0JM9UabnpPQ==" - }, "node_modules/fastq": { "version": "1.13.0", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", @@ -21912,10 +21918,10 @@ "@libp2p/interfaces": "^3.0.2", "@libp2p/peer-id": "^1.1.10", "@multiformats/multiaddr": "^11.0.6", + "@noble/hashes": "^1.1.3", "@waku/byte-utils": "*", "@waku/interfaces": "*", "debug": "^4.3.4", - "fast-sha256": "^1.3.0", "it-all": "^1.0.6", "it-length-prefixed": "^8.0.2", "it-pipe": "^2.0.4", @@ -24850,6 +24856,11 @@ "resolved": "https://registry.npmjs.org/@noble/ed25519/-/ed25519-1.7.1.tgz", "integrity": "sha512-Rk4SkJFaXZiznFyC/t77Q0NKS4FL7TLJJsVG2V2oiEq3kJVeTdxysEe/yRWSpnWMe808XRDJ+VFh5pt/FN5plw==" }, + "@noble/hashes": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.1.3.tgz", + "integrity": "sha512-CE0FCR57H2acVI5UOzIGSSIYxZ6v/HOhDR0Ro9VLyhnzLwx0o8W1mmgaqlEUx4049qJDlIBRztv5k+MM8vbO3A==" + }, "@noble/secp256k1": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/@noble/secp256k1/-/secp256k1-1.7.0.tgz", @@ -26268,6 +26279,7 @@ "@libp2p/interfaces": "^3.0.2", "@libp2p/peer-id": "^1.1.10", "@multiformats/multiaddr": "^11.0.6", + "@noble/hashes": "*", "@rollup/plugin-commonjs": "^22.0.0", "@rollup/plugin-json": "^4.1.0", "@rollup/plugin-node-resolve": "^13.3.0", @@ -26293,7 +26305,6 @@ "eslint-plugin-import": "^2.25.3", "eslint-plugin-prettier": "^4.0.0", "fast-check": "^2.14.0", - "fast-sha256": "*", "gh-pages": "^3.2.3", "ignore-loader": "^0.1.2", "isomorphic-fetch": "^3.0.0", @@ -29388,11 +29399,6 @@ "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", "dev": true }, - "fast-sha256": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/fast-sha256/-/fast-sha256-1.3.0.tgz", - "integrity": "sha512-n11RGP/lrWEFI/bWdygLxhI+pVeo1ZYIVwvvPkW7azl/rOy+F3HYRZ2K5zeE9mmkhQppyv9sQFx0JM9UabnpPQ==" - }, "fastq": { "version": "1.13.0", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", diff --git a/packages/core/package.json b/packages/core/package.json index 20a4857216..917e0b4e05 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -96,10 +96,10 @@ "@libp2p/interfaces": "^3.0.2", "@libp2p/peer-id": "^1.1.10", "@multiformats/multiaddr": "^11.0.6", + "@noble/hashes": "^1.1.3", "@waku/byte-utils": "*", "@waku/interfaces": "*", "debug": "^4.3.4", - "fast-sha256": "^1.3.0", "it-all": "^1.0.6", "it-length-prefixed": "^8.0.2", "it-pipe": "^2.0.4", diff --git a/packages/core/src/lib/waku_store/index.ts b/packages/core/src/lib/waku_store/index.ts index 9b6990f521..89c9dc417b 100644 --- a/packages/core/src/lib/waku_store/index.ts +++ b/packages/core/src/lib/waku_store/index.ts @@ -1,10 +1,10 @@ import type { Connection } from "@libp2p/interface-connection"; import type { PeerId } from "@libp2p/interface-peer-id"; import { Peer } from "@libp2p/interface-peer-store"; -import { utf8ToBytes } from "@waku/byte-utils"; +import { sha256 } from "@noble/hashes/sha256"; +import { concat, utf8ToBytes } from "@waku/byte-utils"; import { DecodedMessage, Decoder } from "@waku/interfaces"; import debug from "debug"; -import sha256 from "fast-sha256"; import all from "it-all"; import * as lp from "it-length-prefixed"; import { pipe } from "it-pipe"; @@ -386,7 +386,7 @@ export async function createCursor( ): Promise { const contentTopicBytes = utf8ToBytes(contentTopic); const messageBytes = utf8ToBytes(message); - const digest = sha256(Buffer.concat([contentTopicBytes, messageBytes])); + const digest = sha256(concat([contentTopicBytes, messageBytes])); return { digest,