|
@@ -64,3 +64,23 @@ feed.ready(() => {
|
64
|
64
|
})
|
65
|
65
|
})
|
66
|
66
|
```
|
|
67
|
+
|
|
68
|
+```js
|
|
69
|
+const { publicKey, secretKey } = boxKeypair(seed)
|
|
70
|
+```
|
|
71
|
+
|
|
72
|
+```js
|
|
73
|
+const boxed = box(publicKey, message, [contextMessage])
|
|
74
|
+```
|
|
75
|
+Encrypts a message to a given public key and returns it as a buffer
|
|
76
|
+- `publicKey` buffer or hex encoded string
|
|
77
|
+- `message` buffer or hex encoded string of any length
|
|
78
|
+- `contextMessage`, if passed, will be hashed in to the shared secret. Should be a buffer or hex encoded string.
|
|
79
|
+
|
|
80
|
+```js
|
|
81
|
+const unboxed = unbox(cipherText, keypair, [contextMessage])
|
|
82
|
+```
|
|
83
|
+Decrypts a message using the given keypair.
|
|
84
|
+- `cipherText` the encrypted message given as a buffer.
|
|
85
|
+- `keypair` an object of the form `{ publicKey, secretKey }` both of which should be buffers or hex encoded strings.
|
|
86
|
+- `contextMessage`, if given, will be hashed into the shared secret. Should be a buffer or hex encoded string.
|