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 🙏

© 2025 – Pkg Stats / Ryan Hefner

subfield

v0.2.6

Published

This package holds the WASM functions for the [Subfield Protocol](https://subfield.org).

Downloads

6

Readme

Subfield

This package holds the WASM functions for the Subfield Protocol.

Installation

npm install subfield

Usage

import * as sf from "subfield/web" // for web
import * as sf from "subfield/node" // for node

await sf.init() // Initialize the WASM module, only necessary if the environment does not support top-level await

Features

VersionedBytes

Hash, PublicKey, PrivateKey, SharedSecret, and CipherKey are all based on VersionedBytes. This allows, for example, a Keypair's SharedKey to be used as a CipherKey for the Cipher functions.

// Constructors
const vb = new sf.VersionedBytes(
	version: number, 
	bytes: Uint8Array
	): VersionedBytes
const vb = sf.VersionedBytes.random(): VersionedBytes

// Getters
vb.version: Number
vb.data: Uint8Array // length of 32

// Conversions
vb.toBytes(): Uint8Array
vb.fromBytes(bytes: Uint8Array): VersionedBytes
vb.toString(): string // Base32
vb.fromString(str: string): VersionedBytes

Crypto

Hashing (BLAKE3)

// Usage
sf.hash(bytes: Uint8Array): Hash
sf.verifyHash(bytes: Uint8Array, hash: Hash): boolean

Cipher (CHA-CHA20)

// Instantiation
const cipherKey: CipherKey = sf.Cipher.randomKey()
const cipher: Cipher = new sf.Cipher(cipherKey)

// Getters
cipher.key: CipherKey 

// Usage
cipher.encrypt(secret: CipherKey, message: Uint8Array): Uint8Array
cipher.decrypt(secret: CipherKey, encrypted: Uint8Array): Uint8Array

Signatures (Ed25519)

// Instantiation
const keypair = new sf.Keypair(private_key: PrivateKey)
const keypair = sf.Keypair.random(): Keypair
const keypair = await sf.Keypair.vanity(prefix: string): Keypair 
	// Prefix must be valid base32, or will throw an error
	// Vanity Keypair search times (single-threaded):
	// On average, requires 2^(letters * 5 - 1) address generations,
	// so each added letter increases average generations by 32x
	// 1 character  ~0s  (2^4  generations)
	// 2 characters ~1s  (2^9  generations)
	// 3 characters ~1m  (2^14 generations) 
	// 4 characters ~20m (2^19 generations)
	// 5 characters ~10h (2^24 generations)

// Getters
keypair.publicKey.edwards(): PublicKey
keypair.publicKey.montgomery(): PublicKey
keypair.privateKey.edwards(): PrivateKey
keypair.privateKey.montgomery(): PrivateKey

// Signatures
keypair.sign(message: Uint8Array): Signature
keypair.verify(message: Uint8Array, signature: Signature): boolean

// Shared secret
keypair.sharedSecret(publicKey: PublicKey): SharedKey

Noise (Noise_NN_25519_ChaChaPoly_BLAKE2s)

// Instantation

// The client creates a Noise initiator
const initiator: Noise = sf.Noise.initiator()
const initiator: Noise = sf.Noise.initiatorFromKeypair(keypair: Keypair)
// The server creates a Noise responder
const responder: Noise = sf.Noise.responder()
const responder: Noise = sf.Noise.responderFromKeypair(keypair: Keypair)

// Setup

// step 1 : initiator sends message1 to responder
let message1 = initiator.handshakeStep1()

// step 2 : responder processes message1 and sends message2 to initiator
let message2 = responder.handshakeStep2(message1)

// step 3 : initiator processes message2
initiator.handshakeStep3(message2)

// Setup done!

// Usage

const helloMessage: Uint8Array = sf.fromString("hello")

// initiator -> responder
let encrypted: Uint8Array = initiator.encrypt(helloMessage)
let decrypted: Uint8Array = responder.decrypt(encrypted)

// responder -> initiator
let encrypted: Uint8Array = responder.encrypt(helloMessage)
let decrypted: Uint8Array = initiator.decrypt(encrypted)

Misc

// String encoding
sf.fromString(str: string): Uint8Array
sf.toString(bytes: Uint8Array): string

// Base32 encoding
sf.fromBase32(str: string): Uint8Array
sf.toBase32(bytes: Uint8Array): string