cobox-crypto
The crypto primitives used in cobox, extracted into a separate module
npm install cobox-crypto
Usage
const Crypto = require('cobox-crypto')
const crypto = Crypto()
const accessKey = crypto.accessKey()
API
keyPair = crypto
Returns an ed25519
keypair that can used for tree signing.
const symKey = crypto
Returns an ed25519
symmetric key used for shared secret encryption
const accessKey = cryptoaccessKey // OR const accessKey = crypto
Returns an access key, which consists of an ed25519
public key, packed together with an ed25519
symmetric key
const keys = crypto
Returns an object containing a public key, and a shared secret if accessible. Public key alone is used for blind replication. The shared secret can then be used for decryption.
const valueEncoding = crypto
Returns a message encoder used for encrypting messages in hypercore. Can be passed to hypercore doing the following:
const accessKey = cryptoaccessKeyconst keys = cryptovar feed = feed
const publicKey secretKey =
const boxed =
Encrypts a message to a given public key and returns it as a buffer
publicKey
buffer or hex encoded stringmessage
buffer or hex encoded string of any lengthcontextMessage
, if passed, will be hashed in to the shared secret. Should be a buffer or hex encoded string.
const unboxed =
Decrypts a message using the given keypair.
cipherText
the encrypted message given as a buffer.keypair
an object of the form{ publicKey, secretKey }
both of which should be buffers or hex encoded strings.contextMessage
, if given, will be hashed into the shared secret. Should be a buffer or hex encoded string.