The crypto primitives used in ddatabase, extracted into a separate module
npm install ddatabase-crypto
const crypto = require('ddatabase-crypto')
const keyPair = crypto.keyPair()
console.log(keyPair) // prints a ed25519 keypair
Returns an ED25519
keypair that can used for tree signing.
Signs a message (buffer).
Verifies a signature for a message.
Hashes a leaf node in a merkle tree.
Hash a parent node in a merkle tree. left
and right
should look like this:
{
index: treeIndex,
hash: hashOfThisNode,
size: byteSizeOfThisTree
}
Hashes the merkle root of the tree. peaks
should be an array of the peaks of the tree and should look like above.
Encodes a buffer to sign. length
should be how many leaf nodes exist in the tree.
Returns a buffer containing random bytes of size size
.
Return a hash derived from a publicKey
that can used for discovery
without disclosing the public key.
MIT