js-waku/packages/message-encryption
dependabot[bot] 6f12c15bda
chore(deps)(deps-dev): bump puppeteer from 19.7.4 to 19.8.2 (#1283)
Bumps [puppeteer](https://github.com/puppeteer/puppeteer) from 19.7.4 to 19.8.2.
- [Release notes](https://github.com/puppeteer/puppeteer/releases)
- [Changelog](https://github.com/puppeteer/puppeteer/blob/main/release-please-config.json)
- [Commits](https://github.com/puppeteer/puppeteer/compare/puppeteer-v19.7.4...puppeteer-v19.8.2)

---
updated-dependencies:
- dependency-name: puppeteer
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Sasha <118575614+weboko@users.noreply.github.com>
2023-03-31 02:13:06 +02:00
..
src chore!: add exports map to @waku/utils (#1201) 2023-03-14 10:10:38 +05:30
.eslintrc.cjs chore: init message-encryption package 2022-11-04 11:25:53 +11:00
.mocharc.json chore: remove usage of jsdom 2023-02-10 19:44:59 +11:00
.prettierignore fix: prettier and cspell ignore CHANGELOG (#1235) 2023-03-13 23:40:41 +01:00
CHANGELOG.md chore: release master (#1269) 2023-03-25 00:22:44 +01:00
README.md doc: add readme for @waku/message-encryption 2022-12-05 15:14:51 +11:00
karma.conf.cjs chore: init message-encryption package 2022-11-04 11:25:53 +11:00
package.json chore(deps)(deps-dev): bump puppeteer from 19.7.4 to 19.8.2 (#1283) 2023-03-31 02:13:06 +02:00
rollup.config.js chore: rename build-utils to avoid potential conflict 2023-03-07 16:44:57 +11:00
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

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) => {
  // ...
});