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

@waku/zerokit-rln-wasm-utils

v0.1.0

Published

[![npm version](https://badge.fury.io/js/@waku%2Fzerokit-rln-wasm.svg)](https://badge.fury.io/js/@waku%2Fzerokit-rln-wasm-utils) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![License: Apache 2

Downloads

10

Readme

RLN WASM Utils

npm version License: MIT License: Apache 2.0

The Zerokit RLN WASM Utils Module provides WebAssembly bindings for Rate-Limiting Nullifier RLN cryptographic primitives. This module offers comprehensive functionality for identity generation and hashing needed for RLN applications.

Features

Identity Generation

  • Random Identity Generation: Generate cryptographically secure random identities
  • Seeded Identity Generation: Generate deterministic identities from seeds
  • Extended Identity Generation: Generate extended identities with additional parameters
  • Seeded Extended Identity Generation: Generate deterministic extended identities from seeds
  • Endianness Support: Both little-endian and big-endian serialization support

Hashing

  • Standard Hashing: Hash arbitrary data to field elements
  • Poseidon Hashing: Advanced cryptographic hashing using Poseidon hash function
  • Endianness Support: Both little-endian and big-endian serialization support

API Reference

Identity Generation Functions

generateMembershipKey(isLittleEndian: boolean): Uint8Array

Generates a random membership key pair (identity secret and commitment).

Inputs:

  • isLittleEndian: Boolean indicating endianness for serialization

Outputs: Serialized identity pair as Uint8Array in corresponding endianness

generateExtendedMembershipKey(isLittleEndian: boolean): Uint8Array

Generates an extended membership key with additional parameters.

Inputs:

  • isLittleEndian: Boolean indicating endianness for serialization

Outputs: Serialized extended identity tuple as Uint8Array in corresponding endianness

generateSeededMembershipKey(seed: Uint8Array, isLittleEndian: boolean): Uint8Array

Generates a deterministic membership key from a seed.

Inputs:

  • seed: Seed data as Uint8Array
  • isLittleEndian: Boolean indicating endianness for serialization

Outputs: Serialized identity pair as Uint8Array in corresponding endianness

generateSeededExtendedMembershipKey(seed: Uint8Array, isLittleEndian: boolean): Uint8Array

Generates a deterministic extended membership key from a seed.

Inputs:

  • seed: Seed data as Uint8Array
  • isLittleEndian: Boolean indicating endianness for serialization

Outputs: Serialized extended identity tuple as Uint8Array in corresponding endianness

Hashing Functions

hash(input: Uint8Array, isLittleEndian: boolean): Uint8Array

Hashes input data to a field element.

Inputs:

  • input: Input data as Uint8Array
  • isLittleEndian: Boolean indicating endianness for serialization

Outputs: Serialized hash result as Uint8Array in corresponding endianness

poseidonHash(input: Uint8Array, isLittleEndian: boolean): Uint8Array

Computes Poseidon hash of input field elements.

Inputs:

  • input: Serialized field elements as Uint8Array (format: length + field elements)
  • isLittleEndian: Boolean indicating endianness for serialization

Outputs: Serialized hash result as Uint8Array in corresponding endianness

Usage Examples

JavaScript/TypeScript

import init, { 
  generateMembershipKey, 
  generateSeededMembershipKey,
  hash,
  poseidonHash 
} from '@waku/zerokit-rln-wasm-utils';

// Initialize the WASM module
await init();

// Generate a random membership key
const membershipKey = generateMembershipKey(true); // little-endian
console.log('Membership key:', membershipKey);

// Generate a deterministic membership key from seed
const seed = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
const seededKey = generateSeededMembershipKey(seed, true);
console.log('Seeded key:', seededKey);

// Hash some data
const input = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
const hashResult = hash(input, true);
console.log('Hash result:', hashResult);

// Poseidon hash with field elements
const fieldElements = new Uint8Array([
  // Length (8 bytes) + field elements (32 bytes each)
  1, 0, 0, 0, 0, 0, 0, 0, // length = 1
  // field element data...
]);
const poseidonResult = poseidonHash(fieldElements, true);
console.log('Poseidon hash:', poseidonResult);

Install Dependencies

[!NOTE] This project requires the following tools:

  • wasm-pack - for compiling Rust to WebAssembly
  • cargo-make - for running build commands
  • nvm - to install and manage Node.js

Ensure all dependencies are installed before proceeding.

Manually

Install wasm-pack

cargo install wasm-pack --version=0.13.1

Install cargo-make

cargo install cargo-make

Install Node.js

If you don't have nvm (Node Version Manager), install it by following the installation instructions.

After installing nvm, install and use Node.js v22.14.0:

nvm install 22.14.0
nvm use 22.14.0
nvm alias default 22.14.0

If you already have Node.js installed, check your version with node -v command — the version must be strictly greater than 22.

Or install everything

You can run the following command from the root of the repository to install all required dependencies for zerokit

make installdeps

Building the library

First, navigate to the rln-wasm-utils directory:

cd rln-wasm-utils

Compile rln-wasm-utils for wasm32-unknown-unknown:

cargo make build

Running tests

cargo make test

License

This project is licensed under both MIT and Apache 2.0 licenses. See the LICENSE files for details.