verifiablejs
v1.1.0
Published
WebAssembly bindings for the Parity `verifiable` crate
Maintainers
Readme
Verifiable JS
This package provides JavaScript/TypeScript bindings for the Parity Verifiable crate.
Features
- Generate proofs of membership in a set with known members
- Validate proofs
- Sign and verify messages
- All cryptographic operations are performed using the Bandersnatch curve implementation
Installation
npm install verifiablejsUsage
For bundler environments (Webpack, Vite, Rollup, etc.)
import init, { one_shot, validate, sign, verify_signature, member_from_entropy } from 'verifiablejs/bundler';
// Initialize the WASM module
await init();
// Generate a proof
const entropy = new Uint8Array(32); // Your entropy bytes
const members = new Uint8Array(...); // Your encoded members list
const context = new TextEncoder().encode("my-context");
const message = new TextEncoder().encode("my-message");
const result = one_shot(entropy, members, context, message);
const { proof, alias, member } = result;
// Validate a proof
const validatedAlias = validate(proof, members, context, message);
// Sign a message
const signature = sign(entropy, message);
// Verify a signature
const isValid = verify_signature(signature, message, member);For Node.js or Bun
import init, { one_shot, validate, sign, verify_signature, member_from_entropy } from 'verifiablejs/nodejs';
// Initialize the WASM module
await init();
// Use the same API as aboveBuilding
npm run buildThis builds both bundler and Node.js targets:
wasm-pack build --release --target bundler --features small-ringwasm-pack build --release --target nodejs --features small-ring
Testing
npm testThis will run both Rust and WASM tests:
cargo test --features "small-ring"wasm-pack test --node --features small-ring
Releasing
This project uses Changesets for version management.
- Create a changeset:
pnpm changeset(select bump type: patch/minor/major) - Version bump:
pnpm version(consumes changesets, updates package.json and CHANGELOG.md) - Publish:
pnpm release(builds and publishes to npm)
License
Licensed under GPL-3.0-or-later WITH Classpath-exception-2.0
