hypercore-crypto

The crypto primitives used in hypercore, extracted into a separate module

MIT 25 个版本
安装
npm install hypercore-crypto
yarn add hypercore-crypto
pnpm add hypercore-crypto
bun add hypercore-crypto
README

hypercore-crypto

The crypto primitives used in hypercore, extracted into a separate module

npm install hypercore-crypto

Usage

const crypto = require('hypercore-crypto')

const keyPair = crypto.keyPair()
console.log(keyPair) // prints a ed25519 keypair

API

keyPair = crypto.keyPair()

Returns an ED25519 keypair that can be used for tree signing.

signature = crypto.sign(message, secretKey)

Signs a message (buffer).

verified = crypto.verify(message, signature, publicKey)

Verifies a signature for a message.

hash = crypto.data(data)

Hashes a leaf node in a merkle tree.

hash = crypto.parent(left, right)

Hash a parent node in a merkle tree. left and right should look like this:

{
  index: treeIndex,
  hash: hashOfThisNode,
  size: byteSizeOfThisTree
}

hash = crypto.tree(peaks)

Hashes the merkle root of the tree. peaks should be an array of the peaks of the tree and should look like above.

buffer = crypto.randomBytes(size)

Returns a buffer containing random bytes of size size.

hash = crypto.discoveryKey(publicKey)

Return a hash derived from a publicKey that can used for discovery without disclosing the public key.

list = crypto.namespace(name, count)

Make a list of namespaces from a specific publicly known name. Use this to namespace capabilities or hashes / signatures across algorithms.

License

MIT

版本列表
3.7.0 2026-05-05
3.6.1 2025-05-22
3.6.0 2025-04-12
3.5.0 2025-02-13
3.4.2 2024-05-28
3.4.1 2024-04-28
3.4.0 2023-07-26
3.3.1 2023-01-10
3.3.0 2022-06-12
3.2.1 2022-03-11
3.2.0 2022-03-01
3.1.1 2021-11-23
3.1.0 2021-11-09
3.0.0 2021-11-08
2.3.2 2021-11-08
2.3.1 2021-11-04
2.3.0 2021-03-30
2.2.0 2020-12-08
2.1.1 2020-06-23
2.1.0 2020-05-16
2.0.2 2020-05-13
2.0.1 2020-05-13
2.0.0 2020-05-13
1.0.0 2018-06-28
0.0.0 2018-06-27