hypercore-crypto

WebJar for hypercore-crypto

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

hypercore-crypto
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

hypercore-crypto
WebJar for hypercore-crypto
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/mafintosh/hypercore-crypto

Download hypercore-crypto

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/hypercore-crypto/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>hypercore-crypto</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/hypercore-crypto/
implementation 'org.webjars.npm:hypercore-crypto:1.0.0'
// https://jarcasting.com/artifacts/org.webjars.npm/hypercore-crypto/
implementation ("org.webjars.npm:hypercore-crypto:1.0.0")
'org.webjars.npm:hypercore-crypto:jar:1.0.0'
<dependency org="org.webjars.npm" name="hypercore-crypto" rev="1.0.0">
  <artifact name="hypercore-crypto" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='hypercore-crypto', version='1.0.0')
)
libraryDependencies += "org.webjars.npm" % "hypercore-crypto" % "1.0.0"
[org.webjars.npm/hypercore-crypto "1.0.0"]

Dependencies

compile (4)

Group / Artifact Type Version
org.webjars.npm : buffer-alloc-unsafe jar [1.1.0,2)
org.webjars.npm : buffer-from jar [1.1.0,2)
org.webjars.npm : sodium-universal jar [2.0.0,3)
org.webjars.npm : uint64be jar [2.0.2,3)

Project Modules

There are no modules declared in this project.

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 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.

dataToSign = crypto.signable(peaksOrHash, length)

Encodes a buffer to sign. length should be how many leaf nodes exist in the tree.

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.

License

MIT

Versions

Version
1.0.0