diff --git a/package-lock.json b/package-lock.json index a34cc7ea3b..ab40d739d2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22949,7 +22949,8 @@ "@waku/core": "*", "@waku/create": "*", "@waku/enr": "*", - "@waku/interfaces": "*" + "@waku/interfaces": "*", + "@waku/message-encryption": "*" }, "devDependencies": { "@typescript-eslint/eslint-plugin": "^5.8.1", @@ -27702,6 +27703,7 @@ "@waku/create": "*", "@waku/enr": "*", "@waku/interfaces": "*", + "@waku/message-encryption": "*", "cspell": "^5.14.0", "eslint": "^8.6.0", "eslint-config-prettier": "^8.3.0", diff --git a/packages/message-encryption/src/index.ts b/packages/message-encryption/src/index.ts index baccaef194..feb42d6115 100644 --- a/packages/message-encryption/src/index.ts +++ b/packages/message-encryption/src/index.ts @@ -9,7 +9,14 @@ import type { Decoder, Encoder, Message, ProtoMessage } from "@waku/interfaces"; import debug from "debug"; import { Symmetric } from "./constants.js"; -import { keccak256, randomBytes, sign } from "./crypto.js"; +import { + generatePrivateKey, + generateSymmetricKey, + getPublicKey, + keccak256, + randomBytes, + sign, +} from "./crypto.js"; import * as ecies from "./ecies.js"; import * as symmetric from "./symmetric.js"; @@ -22,6 +29,8 @@ const PaddingTarget = 256; const SignatureLength = 65; const OneMillion = BigInt(1_000_000); +export { generatePrivateKey, generateSymmetricKey, getPublicKey }; + export const Version = 1; export type Signature = { diff --git a/packages/tests/package.json b/packages/tests/package.json index 1adbe1806a..7bc92a924d 100644 --- a/packages/tests/package.json +++ b/packages/tests/package.json @@ -59,7 +59,8 @@ "@waku/enr": "*", "@waku/create": "*", "@waku/interfaces": "*", - "@waku/byte-utils": "*" + "@waku/byte-utils": "*", + "@waku/message-encryption": "*" }, "devDependencies": { "@typescript-eslint/eslint-plugin": "^5.8.1", diff --git a/packages/tests/tests/relay.node.spec.ts b/packages/tests/tests/relay.node.spec.ts index 604439a503..2ed42b7e13 100644 --- a/packages/tests/tests/relay.node.spec.ts +++ b/packages/tests/tests/relay.node.spec.ts @@ -1,26 +1,24 @@ import { PeerId } from "@libp2p/interface-peer-id"; import { bytesToUtf8, utf8ToBytes } from "@waku/byte-utils"; -import { - DefaultPubSubTopic, - generatePrivateKey, - generateSymmetricKey, - getPublicKey, -} from "@waku/core"; +import { DefaultPubSubTopic } from "@waku/core"; import { waitForRemotePeer } from "@waku/core/lib/wait_for_remote_peer"; import { DecoderV0, EncoderV0, MessageV0, } from "@waku/core/lib/waku_message/version_0"; -import { - AsymDecoder, - AsymEncoder, - SymDecoder, - SymEncoder, -} from "@waku/core/lib/waku_message/version_1"; import { createPrivacyNode } from "@waku/create"; import type { Message, WakuPrivacy } from "@waku/interfaces"; import { Protocols } from "@waku/interfaces"; +import { + AsymDecoder, + AsymEncoder, + generatePrivateKey, + generateSymmetricKey, + getPublicKey, + SymDecoder, + SymEncoder, +} from "@waku/message-encryption"; import { expect } from "chai"; import debug from "debug"; diff --git a/packages/tests/tests/store.node.spec.ts b/packages/tests/tests/store.node.spec.ts index b63392b911..38b076bb67 100644 --- a/packages/tests/tests/store.node.spec.ts +++ b/packages/tests/tests/store.node.spec.ts @@ -1,21 +1,19 @@ import { bytesToUtf8, utf8ToBytes } from "@waku/byte-utils"; -import { - generatePrivateKey, - generateSymmetricKey, - getPublicKey, -} from "@waku/core"; import { PageDirection } from "@waku/core"; import { waitForRemotePeer } from "@waku/core/lib/wait_for_remote_peer"; import { DecoderV0, EncoderV0 } from "@waku/core/lib/waku_message/version_0"; -import { - AsymDecoder, - AsymEncoder, - SymDecoder, - SymEncoder, -} from "@waku/core/lib/waku_message/version_1"; import { createFullNode } from "@waku/create"; import type { Message, WakuFull } from "@waku/interfaces"; import { Protocols } from "@waku/interfaces"; +import { + AsymDecoder, + AsymEncoder, + generatePrivateKey, + generateSymmetricKey, + getPublicKey, + SymDecoder, + SymEncoder, +} from "@waku/message-encryption"; import { expect } from "chai"; import debug from "debug"; diff --git a/packages/tests/tests/waku.node.spec.ts b/packages/tests/tests/waku.node.spec.ts index 07c4e69010..9c3965c6fb 100644 --- a/packages/tests/tests/waku.node.spec.ts +++ b/packages/tests/tests/waku.node.spec.ts @@ -1,12 +1,15 @@ import type { PeerId } from "@libp2p/interface-peer-id"; import { bytesToUtf8, utf8ToBytes } from "@waku/byte-utils"; -import { generateSymmetricKey } from "@waku/core"; import { PeerDiscoveryStaticPeers } from "@waku/core/lib/peer_discovery_static_list"; import { waitForRemotePeer } from "@waku/core/lib/wait_for_remote_peer"; -import { SymDecoder, SymEncoder } from "@waku/core/lib/waku_message/version_1"; import { createLightNode, createPrivacyNode } from "@waku/create"; import type { Message, Waku, WakuLight, WakuPrivacy } from "@waku/interfaces"; import { Protocols } from "@waku/interfaces"; +import { + generateSymmetricKey, + SymDecoder, + SymEncoder, +} from "@waku/message-encryption"; import { expect } from "chai"; import { makeLogFileName, NOISE_KEY_1, NOISE_KEY_2, Nwaku } from "../src/";