mirror of
https://github.com/waku-org/js-waku.git
synced 2025-01-12 21:44:33 +00:00
08fc2d133a
* changing default pubsub topic to its static sharding version * keeping RFC's Waku Message test vectors * reverting change in changelog * setting pubsub topic when creating nwaku node * adding shardInfo to runMultipleNodes call * adding shardInfo to runMultipleNodes call in lightpush tests * add pubsub topics to nwaku.start * get rid of it.only that remained * fixing compliance tests * setting clusterId to 0 * removing unnecessary fix * adding shardInfo when creating nodes * fixing wait for remote peer tests * fixing peer exchange test * refactor * removing unnecessary variable * feat: create default shard info, update tests (#2085) * feat: create default shard info, update tests * add link * fix tests * remoe only * up tests * up test --------- Co-authored-by: Sasha <118575614+weboko@users.noreply.github.com>
@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) => {
// ...
});