https://github.com/hackergrrl/hypercore-private-box
Encrypt messages that only members from a set of hypercores can decrypt.
https://github.com/hackergrrl/hypercore-private-box
Last synced: 6 months ago
JSON representation
Encrypt messages that only members from a set of hypercores can decrypt.
- Host: GitHub
- URL: https://github.com/hackergrrl/hypercore-private-box
- Owner: hackergrrl
- Created: 2019-05-22T21:28:41.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-05-22T21:36:12.000Z (about 6 years ago)
- Last Synced: 2024-12-28T21:44:18.621Z (6 months ago)
- Language: JavaScript
- Homepage:
- Size: 3.91 KB
- Stars: 16
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# hypercore-private-box
> Encrypt messages that only members of a set of hypercores can decrypt.
Wraps [private-box](https://github.com/auditdrivencrypto/private-box) to support hypercore (ed25519) keys.
## Usage
```js
var hbox = require('hypercore-private-box')
var hypercore = require('hypercore')
var ram = require('random-access-memory')var core = hypercore(ram, { valueEncoding: 'json' })
var text = Buffer.from('hello secure world!')core.ready(function () {
var ctext = hbox.box(text, core)
console.log(ctext)
var result = hbox.unbox(ctext, core)
console.log(result)
})
```outputs
```
hello secure world!
```## API
```js
var hbox = require('hypercore-private-box')
```### var ctext = hbox.box(buf, recipients)
Encrypts the buffer `buf` such that only the `recipients` (array of 1-7 hypercores) can decrypt.
### var res = hbox.unbox(buf, core)
Decrypts the ciphertext buffer `buf` using the hypercore `core`. Returns `undefined` if the buffer could not be decrypted.
## Install
With [npm](https://npmjs.org/) installed, run
```
$ npm install hypercore-private-box
```## Thanks
Appreciation goes out to punkmonk (`@EaYYQo5nAQRabB9nxAn5i2uiIZ665b90Qk2U/WHNVE8=.ed25519`) for helping me figure out how sodium works!
## License
ISC