mirror of https://github.com/waku-org/js-waku.git
420e6c698d
* upgrade libp2p version, partially update protocols, rename to IBaseProtocol * complete transition for protocols * complete transition of connection maanger * finish sdk * complete core * complete relay * complete peer-exchange * complete dns-discovery * add components field to Libp2p interface and use it in core * add type hack for Libp2p creation: * finish waku node test * complete relay test * complete peer exchange * complete dns peer discovery test * add missing dependency to relay * fix new peer store integration * improve initialization of pubsub * add catch for missing peer * update test and remove extra dependency * prevent error throw * fix edge case with peerStore * fix peer exchange * fix protocols used * fix test with another evnet * bump libp2p and interfaces * add missing package * fix peer-exchange problem * prefer libp2p peerDiscovery for integration tests * fix import * increate timeout * return test against Test fleet * remove await for peer:update * increase timeout * add await for peerStore * comment event for testing * fix lint * remove bind * fix stub * decouple to separate test case * move back to explicit build * remove only * do not test event |
||
---|---|---|
.. | ||
src | ||
.eslintrc.cjs | ||
.mocharc.json | ||
CHANGELOG.md | ||
README.md | ||
karma.conf.cjs | ||
package.json | ||
rollup.config.js | ||
tsconfig.dev.json | ||
tsconfig.json |
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) => {
// ...
});