address comments

This commit is contained in:
danisharora099 2022-11-15 18:08:21 +05:30
parent 8f243eb325
commit c012748bb7
No known key found for this signature in database
GPG Key ID: FBD2BF500037F135
3 changed files with 22 additions and 16 deletions

30
package-lock.json generated
View File

@ -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": { "node_modules/@noble/secp256k1": {
"version": "1.7.0", "version": "1.7.0",
"resolved": "https://registry.npmjs.org/@noble/secp256k1/-/secp256k1-1.7.0.tgz", "resolved": "https://registry.npmjs.org/@noble/secp256k1/-/secp256k1-1.7.0.tgz",
@ -8628,11 +8639,6 @@
"integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==",
"dev": true "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": { "node_modules/fastq": {
"version": "1.13.0", "version": "1.13.0",
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz",
@ -21912,10 +21918,10 @@
"@libp2p/interfaces": "^3.0.2", "@libp2p/interfaces": "^3.0.2",
"@libp2p/peer-id": "^1.1.10", "@libp2p/peer-id": "^1.1.10",
"@multiformats/multiaddr": "^11.0.6", "@multiformats/multiaddr": "^11.0.6",
"@noble/hashes": "^1.1.3",
"@waku/byte-utils": "*", "@waku/byte-utils": "*",
"@waku/interfaces": "*", "@waku/interfaces": "*",
"debug": "^4.3.4", "debug": "^4.3.4",
"fast-sha256": "^1.3.0",
"it-all": "^1.0.6", "it-all": "^1.0.6",
"it-length-prefixed": "^8.0.2", "it-length-prefixed": "^8.0.2",
"it-pipe": "^2.0.4", "it-pipe": "^2.0.4",
@ -24850,6 +24856,11 @@
"resolved": "https://registry.npmjs.org/@noble/ed25519/-/ed25519-1.7.1.tgz", "resolved": "https://registry.npmjs.org/@noble/ed25519/-/ed25519-1.7.1.tgz",
"integrity": "sha512-Rk4SkJFaXZiznFyC/t77Q0NKS4FL7TLJJsVG2V2oiEq3kJVeTdxysEe/yRWSpnWMe808XRDJ+VFh5pt/FN5plw==" "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": { "@noble/secp256k1": {
"version": "1.7.0", "version": "1.7.0",
"resolved": "https://registry.npmjs.org/@noble/secp256k1/-/secp256k1-1.7.0.tgz", "resolved": "https://registry.npmjs.org/@noble/secp256k1/-/secp256k1-1.7.0.tgz",
@ -26268,6 +26279,7 @@
"@libp2p/interfaces": "^3.0.2", "@libp2p/interfaces": "^3.0.2",
"@libp2p/peer-id": "^1.1.10", "@libp2p/peer-id": "^1.1.10",
"@multiformats/multiaddr": "^11.0.6", "@multiformats/multiaddr": "^11.0.6",
"@noble/hashes": "*",
"@rollup/plugin-commonjs": "^22.0.0", "@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-json": "^4.1.0", "@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.3.0", "@rollup/plugin-node-resolve": "^13.3.0",
@ -26293,7 +26305,6 @@
"eslint-plugin-import": "^2.25.3", "eslint-plugin-import": "^2.25.3",
"eslint-plugin-prettier": "^4.0.0", "eslint-plugin-prettier": "^4.0.0",
"fast-check": "^2.14.0", "fast-check": "^2.14.0",
"fast-sha256": "*",
"gh-pages": "^3.2.3", "gh-pages": "^3.2.3",
"ignore-loader": "^0.1.2", "ignore-loader": "^0.1.2",
"isomorphic-fetch": "^3.0.0", "isomorphic-fetch": "^3.0.0",
@ -29388,11 +29399,6 @@
"integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==",
"dev": true "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": { "fastq": {
"version": "1.13.0", "version": "1.13.0",
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz",

View File

@ -96,10 +96,10 @@
"@libp2p/interfaces": "^3.0.2", "@libp2p/interfaces": "^3.0.2",
"@libp2p/peer-id": "^1.1.10", "@libp2p/peer-id": "^1.1.10",
"@multiformats/multiaddr": "^11.0.6", "@multiformats/multiaddr": "^11.0.6",
"@noble/hashes": "^1.1.3",
"@waku/byte-utils": "*", "@waku/byte-utils": "*",
"@waku/interfaces": "*", "@waku/interfaces": "*",
"debug": "^4.3.4", "debug": "^4.3.4",
"fast-sha256": "^1.3.0",
"it-all": "^1.0.6", "it-all": "^1.0.6",
"it-length-prefixed": "^8.0.2", "it-length-prefixed": "^8.0.2",
"it-pipe": "^2.0.4", "it-pipe": "^2.0.4",

View File

@ -1,10 +1,10 @@
import type { Connection } from "@libp2p/interface-connection"; import type { Connection } from "@libp2p/interface-connection";
import type { PeerId } from "@libp2p/interface-peer-id"; import type { PeerId } from "@libp2p/interface-peer-id";
import { Peer } from "@libp2p/interface-peer-store"; 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 { DecodedMessage, Decoder } from "@waku/interfaces";
import debug from "debug"; import debug from "debug";
import sha256 from "fast-sha256";
import all from "it-all"; import all from "it-all";
import * as lp from "it-length-prefixed"; import * as lp from "it-length-prefixed";
import { pipe } from "it-pipe"; import { pipe } from "it-pipe";
@ -386,7 +386,7 @@ export async function createCursor(
): Promise<proto.Index> { ): Promise<proto.Index> {
const contentTopicBytes = utf8ToBytes(contentTopic); const contentTopicBytes = utf8ToBytes(contentTopic);
const messageBytes = utf8ToBytes(message); const messageBytes = utf8ToBytes(message);
const digest = sha256(Buffer.concat([contentTopicBytes, messageBytes])); const digest = sha256(concat([contentTopicBytes, messageBytes]));
return { return {
digest, digest,