new private message format for ssb
npm install envelope-jsA javascript tool for cryptographically "boxing" and "unboxing" messages
following the envelope spec.
envelope supports encryption to individuals and groups
``js`
var { box, unbox, CloakedMsgId } = require('envelope-js')
...
where:
- plain_text Buffer is the content to be "enveloped"feed_id
- Buffer is a type-format-key (TFK) encoded value for the feed authoring a messageprev_msg_id
- Buffer is a TFK encoded value of the id of last message of this feeds chainmsg_key
- Buffer a randomised 32 Bytes which will be the unique key for this messagerecps_keys
- Array is a collection of items of form { key, scheme }, wherekey
- Buffer is the key the particular recipientscheme
- String|Buffer is the type of key / the key management scheme for this recipient
where:
- ciphertext Buffer is envelopefeed_id
- Buffer is a type-format-key (TFK) encoded value for the feed authoring a messageprev_msg_id
- Buffer is a TFK encoded value of the id of last message of this feeds chaintrial_keys
- Array is a collection of items of form { key, scheme }, wherekey
- Buffer is the key the particular recipientscheme
- String|Buffer is the type of key / the key management scheme for this recipientmax_attempts
- Integer (default: 8) how many key_slots you want to assume the envelope hasplain_text
- Buffer the envelope contents
NOTE: we also expose unboxKey and unboxBody for convenience.
Used for taking a msg_key (the one-time key for a particular envelope) and deriving other keys used in the envelope (e.g. read_key)
where:
- feed_id Buffer is a TFK encoded id for the feed the envelope is part ofprev_msg_id
- Buffer is a TFK encoded id for the message prior to one where our envelope isprev_msg_id
- NOTE if this is the first message, then the K part of 's TFK is a zero-filled Buffer.derive(key, labels) => new_key
- function where:key
- Buffer is a seed key which we're going to derive fromlabels
- Array is a an array of Strings which help define a derivation
Determine a cloaked message id for a published message following the envelope-spec/cloaked_msg_id/README.md
where:
- public_msg_id Buffer is the id of a enveloped message that's been published (it has an id as it's part of a feed / chain)read_key
- Buffer is the read capability (NOT the msg_key) for this message envelopecloakedMsgId
- is an instance with methods:toBuffer() => Buffer
- which returns the cloaked id key as a BuffertoString(encoding) => String
- which returns the cloaked id key as a Buffer (encoding defaults to 'base64')mock() => cloakedMsgId
- a method for testing. populates the id with random content. if using this, instantiate with no args.
where info` is an Array of Buffers.
This is "short length-prefixed encoding", see https://github.com/ssbc/envelope-spec/blob/master/encoding/slp.md
...
MIT