npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lukeburns/hyperswarm-crypto

v0.2.1

Published

Crypto bindings for HyperDHT and Hyperswarm

Downloads

292

Readme

hyperswarm-crypto

The crypto and Noise bindings used by HyperDHT and Hyperswarm.

npm install hyperswarm-crypto

Usage

const crypto = require("hyperswarm-crypto");

const keyPair = crypto.createKeyPair();
console.log(keyPair); // prints an ML-KEM identity + transport key pair

API

keyPair = crypto.createKeyPair([seed])

Returns a HyperDHT identity key pair and transport key pair.

If seed is provided, the identity and transport key pairs are deterministically derived from separate namespaces.

digest = crypto.identityDigest(publicKey, [algorithm])

Hashes an identity public key and algorithm label into the fixed-size DHT routing identity.

digest = crypto.unslabbedIdentityDigest(publicKey, [algorithm])

Like identityDigest, but returns an unslabbed buffer.

signature = crypto.sign(data, keyPair)

Signs DHT records with the swarm identity signing scheme.

valid = crypto.verify(signature, data, publicKey, [algorithm])

Verifies a DHT record signature.

keyPair = crypto.transportKeyPair(keyPair)

Returns the transport key pair for a HyperDHT identity, falling back to the identity key pair when no separate transport key is present.

keyPair = crypto.createHandshakeKeyPair([seed], [opts])

Returns a key pair for the configured Noise KEM.

If seed is provided, it must match the selected KEM seed length.

noise = crypto.createHandshakeNoise(isInitiator, keyPair, remotePublicKey, pattern, [opts])

Creates and initializes a Noise handshake instance for secret streams.

noise = crypto.createTransportNoise(isInitiator, keyPair, remotePublicKey, prologue, [opts])

Creates and initializes a Noise handshake instance for HyperDHT peer handshakes.

opts = crypto.toNoiseOptions([opts])

Normalizes user options into the option object passed to the Noise implementation.

crypto.validateRemotePublicKey(remotePublicKey, [opts])

Validates that a remote public key matches the configured KEM shape.

crypto.validateHandshakeKeyPair(keyPair, [opts])

Validates that a handshake key pair matches the configured KEM shape.

bytes = crypto.getNoisePublicKeyBytes([opts])

Returns the configured Noise public key byte length.

hash = crypto.hash(data)

Hashes data with the swarm hash primitive.

hash = crypto.unslabbedHash(data)

Like hash, but returns an unslabbed buffer.

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.

Constants

crypto.DEFAULT_HANDSHAKE_PATTERN

The default secret-stream handshake pattern.

crypto.DEFAULT_TRANSPORT_PATTERN

The default HyperDHT peer handshake pattern.

crypto.DEFAULT_KEM

The default Noise KEM.

crypto.MLKEM512, crypto.MLKEM768, crypto.MLKEM1024

The ML-KEM Noise bindings exposed for callers that need to override the default KEM.

License

Apache-2.0