js-waku/packages/message-encryption
Sasha f3627c46a4
feat!: use ShardingParams on subscriptions, make Decoder/Encoder auto sharding friendly by default (#1958)
* fix: use pubsubTopic from current ones if not set

* fix: improve type on dial method

* enforce same pubusb on filter.subscribe, make content topic to pubsub mapping default for decoder / encoder

* fix mapping problem

* update tests

* add error handling

* fix typo

* up lock

* rm lock

* up lock

* remove only

* fix content topic

* fix ephemeral test

* fix filter unsubscribe test

* up utils

* fix subscribe test

* up interfaces and filter api

* remove only

* up ping test

* fix subscribe test

* fix push test

* fix lightPush

* fix multiple pubsub

* remove only, fix subscribe filter test

* remove only

* fix cluster ID selection and named sharding subscription test

* fix unsubscribe test

* fix light push test

* fix light push test

* fix push test

* fix relay publish

* create runNode and fix relay tests

* generalize runNodes, fix some tests

* fix store tests

* fix toAsyncIterator tests

* remove only

* fix lightPush

* use generics

* try fix test

* run failing tests

* remove only

* address failed tests, remove DefaultPubsubTopic dependency in some tests
2024-04-28 11:15:17 +02:00
..
src feat!: use ShardingParams on subscriptions, make Decoder/Encoder auto sharding friendly by default (#1958) 2024-04-28 11:15:17 +02:00
.eslintrc.cjs chore: upgrade libp2p and related deps (#1482) 2023-08-16 20:18:13 +05:30
.mocha.reporters.json chore: allure test reporting (#1668) 2023-10-23 17:53:56 +03:00
.mocharc.cjs chore: allure test reporting (#1668) 2023-10-23 17:53:56 +03:00
CHANGELOG.md chore: release master (#1950) 2024-04-09 14:11:20 +03:00
README.md chore: upgrade libp2p and related deps (#1482) 2023-08-16 20:18:13 +05:30
karma.conf.cjs feat: add Firefox and Webkit to karma (#1598) 2023-09-22 17:48:07 +02:00
package.json chore: release master (#1950) 2024-04-09 14:11:20 +03:00
rollup.config.js chore: upgrade libp2p and related deps (#1482) 2023-08-16 20:18:13 +05:30
tsconfig.dev.json chore: merge tsconfig 2022-12-02 15:54:30 +11:00
tsconfig.json chore: merge tsconfig 2022-12-02 15:54:30 +11:00
typedoc.json chore: update typescript (#1528) 2023-09-21 10:57:37 +02:00

README.md

@waku/message-encryption

Provide Waku Message Version 1 payload encryption as defined in 26/WAKU2-PAYLOAD.

Symmetric Encryption

Symmetric encryption uses a unique key to encrypt and decrypt messages.

import {
  createDecoder,
  createEncoder,
  generateSymmetricKey
} from "@waku/message-encryption/symmetric";

// Generate a random key
const key = generateSymmetricKey();

// To send messages, create an encoder
const encoder = createEncoder(contentTopic, key);

// For example
waku.lightPush.push(encoder, { payload });

// To receive messages, create a decoder
const decoder = createDecoder(contentTopic, key);

// For example
await waku.store.queryOrderedCallback([decoder], (msg) => {
  // ...
});

ECIES Encryption

ECIES encryption enables encryption for a public key and decryption using a private key.

import {
  createDecoder,
  createEncoder,
  generatePrivateKey,
  getPublicKey
} from "@waku/message-encryption/ecies";

// Generate a random private key
const privateKey = generatePrivateKey();

// Keep the private key secure, provide the public key to the sender
const publicKey = getPublicKey(privateKey);

// To send messages, create an encoder
const encoder = createEncoder(contentTopic, publicKey);

// For example
waku.lightPush.push(encoder, { payload });

// To receive messages, create a decoder
const decoder = createDecoder(contentTopic, privateKey);

// For example
await waku.store.queryOrderedCallback([decoder], (msg) => {
  // ...
});