mirror of https://github.com/waku-org/js-waku.git
2bc3735e4d
tests: use a generator for sharded pubsub topics set pubsub topic in encoder/decoder based on sharding type add function for grouping content topics by pubsub topic add autosharding config to create options add autoshard rpc endpoints to nwaku and use in tests set autoshard pubsub topics in all protocols fix rebase with static sharding removes unused function remove console logs remove autosharding from ShardInfo, add to EncoderOptions fix enr and encoder/decoder options test that same application/version hashes to same shard index update comment on shard field fix spelling of autosharding fix content topic protocol in tests add sharding type alias and function to determine topic in encoders/decoders move DefaultPubsubTopic from core to interfaces |
||
---|---|---|
.. | ||
src | ||
.eslintrc.cjs | ||
.mocha.reporters.json | ||
.mocharc.cjs | ||
CHANGELOG.md | ||
README.md | ||
karma.conf.cjs | ||
package.json | ||
rollup.config.js | ||
tsconfig.dev.json | ||
tsconfig.json | ||
typedoc.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) => {
// ...
});