@waku/message-encryption 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/README.md +65 -0
- package/bundle/ecies.js +1 -0
- package/bundle/index-80756c1f.js +15281 -0
- package/bundle/index.js +1 -13530
- package/bundle/symmetric.js +1 -0
- package/dist/crypto/ecies.d.ts +17 -0
- package/dist/crypto/ecies.js +126 -0
- package/dist/crypto/ecies.js.map +1 -0
- package/dist/{crypto.d.ts → crypto/index.d.ts} +0 -0
- package/dist/{crypto.js → crypto/index.js} +2 -2
- package/dist/crypto/index.js.map +1 -0
- package/dist/crypto/symmetric.d.ts +3 -0
- package/dist/crypto/symmetric.js +18 -0
- package/dist/crypto/symmetric.js.map +1 -0
- package/dist/ecies.d.ts +45 -11
- package/dist/ecies.js +97 -112
- package/dist/ecies.js.map +1 -1
- package/dist/index.d.ts +7 -84
- package/dist/index.js +6 -316
- package/dist/index.js.map +1 -1
- package/dist/symmetric.d.ts +51 -3
- package/dist/symmetric.js +107 -14
- package/dist/symmetric.js.map +1 -1
- package/dist/waku_payload.d.ts +53 -0
- package/dist/waku_payload.js +178 -0
- package/dist/waku_payload.js.map +1 -0
- package/package.json +10 -2
- package/src/crypto/ecies.ts +194 -0
- package/src/{crypto.ts → crypto/index.ts} +1 -1
- package/src/crypto/symmetric.ts +33 -0
- package/src/ecies.ts +147 -173
- package/src/index.ts +12 -444
- package/src/symmetric.ts +161 -27
- package/src/waku_payload.ts +239 -0
- package/dist/crypto.js.map +0 -1
package/CHANGELOG.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## [Unreleased]
|
9
|
+
|
10
|
+
## [0.0.5] - 2022-12-15
|
11
|
+
|
12
|
+
### Added
|
13
|
+
|
14
|
+
- Add `@multiformats/multiaddr` as peer dependency.
|
15
|
+
- New `createEncoder` and `createDecoder` functions so that the consumer does not deal with Encoder/Decoder classes.
|
16
|
+
-
|
17
|
+
|
18
|
+
### Changed
|
19
|
+
|
20
|
+
- `Asymmetric` renamed to `ECIES` to follow RFC terminology.
|
21
|
+
- Split `ECIES` and `symmetric` packages, all items are now export from two different paths: `@waku/message-encryption/ecies` and `@waku/message-encryption/symmetric`.
|
22
|
+
- remove `asym` and `sym` prefix from exported items as they are now differentiated from their export path: `createEncoder`, `createDecoder`, `DecodedMessage`.
|
23
|
+
- Remove usage for `Partial` with `Message` as `Message`'s field are all optional.
|
24
|
+
|
25
|
+
## [0.0.4] - 2022-11-18
|
26
|
+
|
27
|
+
### Added
|
28
|
+
|
29
|
+
- Alpha version of `@waku/message-encryption`.
|
30
|
+
|
31
|
+
[unreleased]: https://github.com/waku-org/js-waku/compare/@waku/message-encryption@0.0.5...HEAD
|
32
|
+
[0.0.5]: https://github.com/waku-org/js-waku/compare/@waku/message-encryption@0.0.4...@waku/message-encryption@0.0.5
|
33
|
+
[0.0.4]: https://github.com/waku-org/js-waku/compare/@waku/message-encryption@0.0.3...@waku/message-encryption@0.0.4
|
34
|
+
[0.0.3]: https://github.com/waku-org/js-waku/compare/@waku/message-encryption@0.0.2...%40waku/message-encryption@0.0.3
|
35
|
+
[0.0.2]: https://github.com/waku-org/js-waku/compare/@waku/message-encryption@0.0.1...%40waku/message-encryption@0.0.2
|
36
|
+
[0.0.1]: https://github.com/status-im/js-waku/compare/a20b7809d61ff9a9732aba82b99bbe99f229b935...%40waku/message-encryption%400.0.2
|
package/README.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# `@waku/message-encryption`
|
2
|
+
|
3
|
+
Provide Waku Message Version 1 payload encryption as defined in [26/WAKU2-PAYLOAD](https://rfc.vac.dev/spec/26/).
|
4
|
+
|
5
|
+
## Symmetric Encryption
|
6
|
+
|
7
|
+
Symmetric encryption uses a unique key to encrypt and decrypt messages.
|
8
|
+
|
9
|
+
```typescript
|
10
|
+
import {
|
11
|
+
createDecoder,
|
12
|
+
createEncoder,
|
13
|
+
generateSymmetricKey,
|
14
|
+
} from "@waku/message-encryption/symmetric";
|
15
|
+
|
16
|
+
// Generate a random key
|
17
|
+
const key = generateSymmetricKey();
|
18
|
+
|
19
|
+
// To send messages, create an encoder
|
20
|
+
const encoder = createEncoder(contentTopic, key);
|
21
|
+
|
22
|
+
// For example
|
23
|
+
waku.lightPush.push(encoder, { payload });
|
24
|
+
|
25
|
+
// To receive messages, create a decoder
|
26
|
+
const decoder = createDecoder(contentTopic, key);
|
27
|
+
|
28
|
+
// For example
|
29
|
+
await waku.store.queryOrderedCallback([decoder], (msg) => {
|
30
|
+
// ...
|
31
|
+
});
|
32
|
+
```
|
33
|
+
|
34
|
+
## ECIES Encryption
|
35
|
+
|
36
|
+
ECIES encryption enables encryption for a public key and decryption using a private key.
|
37
|
+
|
38
|
+
```typescript
|
39
|
+
import {
|
40
|
+
createDecoder,
|
41
|
+
createEncoder,
|
42
|
+
generatePrivateKey,
|
43
|
+
getPublicKey,
|
44
|
+
} from "@waku/message-encryption/ecies";
|
45
|
+
|
46
|
+
// Generate a random private key
|
47
|
+
const privateKey = generatePrivateKey();
|
48
|
+
|
49
|
+
// Keep the private key secure, provide the public key to the sender
|
50
|
+
const publicKey = getPublicKey(privateKey);
|
51
|
+
|
52
|
+
// To send messages, create an encoder
|
53
|
+
const encoder = createEncoder(contentTopic, publicKey);
|
54
|
+
|
55
|
+
// For example
|
56
|
+
waku.lightPush.push(encoder, { payload });
|
57
|
+
|
58
|
+
// To receive messages, create a decoder
|
59
|
+
const decoder = createDecoder(contentTopic, privateKey);
|
60
|
+
|
61
|
+
// For example
|
62
|
+
await waku.store.queryOrderedCallback([decoder], (msg) => {
|
63
|
+
// ...
|
64
|
+
});
|
65
|
+
```
|
package/bundle/ecies.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export { D as DecodedMessage, b as createDecoder, c as createEncoder, g as generatePrivateKey, a as getPublicKey } from './index-80756c1f.js';
|