Skip to content

orbinum/groth16-proofs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

21 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

groth16-proofs

High-performance Groth16 proof generator using arkworks for Orbinum privacy protocol

npm version Crates.io License

Efficient Groth16 zero-knowledge proof generator for Orbinum's privacy protocol. Compiles to both native Rust and WebAssembly for maximum flexibility.

πŸš€ Quick Start

Install

npm/yarn/pnpm (WASM for JavaScript/TypeScript):

npm install @orbinum/groth16-proofs

Rust (Native binary):

[dependencies]
groth16-proofs = "2.2"

Use

JavaScript/TypeScript:

import * as groth16 from '@orbinum/groth16-proofs';
import * as snarkjs from 'snarkjs';

// Initialize WASM
await groth16.default();
groth16.init_panic_hook();

// Calculate witness with snarkjs
const witnessArray = await snarkjs.wtns.exportJson('witness.wtns');

// Generate proof (no conversion needed!)
const result = groth16.generate_proof_from_decimal_wasm(
  5,  // number of public signals
  JSON.stringify(witnessArray),  // direct from snarkjs
  provingKeyBytes
);

const { proof, publicSignals } = JSON.parse(result);

Rust:

use groth16_proofs::generate_proof_from_witness;

let proof = generate_proof_from_witness(&witness, "proving_key.ark")?;

πŸ“– Full guides:

What Is This?

This crate generates 128-byte compressed Groth16 proofs from witness data using the arkworks library. It supports:

  • Performance: ~1.6–1.8s WASM (small circuits, post-warmup); native Rust faster
  • Curves: BN254 (Ethereum-compatible)
  • Targets: Native (Rust) + WebAssembly
  • Circuits: Unshield, Transfer, Disclosure
  • WASM Input Format: Decimal witness (snarkjs native)

For interoperability with snarkjs-generated proofs, the WASM API also exposes compress_snarkjs_proof_wasm() to convert pi_a/pi_b/pi_c JSON into arkworks canonical compressed proof bytes (0x..., 128 bytes).

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ groth16-proofs                                 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ Core (src/proof.rs)                      β”‚  β”‚
β”‚  β”‚ - Groth16 proof generation               β”‚  β”‚
β”‚  β”‚ - Arkworks constraint system             β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                                                β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚ Native Binary    β”‚  β”‚ WASM Module       β”‚   β”‚
β”‚  β”‚ (Rust)           β”‚  β”‚ (JavaScript)      β”‚   β”‚
β”‚  β”‚ - CLI tool       β”‚  β”‚ - Browser support β”‚   β”‚
β”‚  β”‚ - Fastest        β”‚  β”‚ - Portable        β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                                                β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ Dependencies (arkworks ecosystem)        β”‚  β”‚
β”‚  β”‚ - ark-bn254, ark-groth16, ark-serialize  β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                                                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Components

Component Location Purpose
proof.rs src/ Core Groth16 generation using arkworks
circuit.rs src/ Circuit wrapper implementing ConstraintSynthesizer
utils.rs src/ Format conversions (decimal ↔ hex ↔ field elements)
wasm.rs src/ WASM FFI bindings and public API re-exports
wasm/snarkjs_proof.rs src/wasm/ snarkjs proof parsing/validation and compression
binary src/bin/ CLI tool for Node.js integration

Features

βœ… Multiple Targets: Native + WASM
βœ… Fast: ~1.6–1.8s WASM (post-warmup); native Rust faster
βœ… WASM Decimal-Only API: Direct snarkjs witness input
βœ… Type-Safe: Memory-safe cryptography
βœ… Well-Tested: 21+ tests included
βœ… Automated Release: CI/CD pipeline ready
βœ… Zero External Calls: Everything bundled

Development

Quick Commands

make help              # Show all commands
make dev              # Format β†’ Lint β†’ Test
make build            # Build native
make build-wasm       # Build WASM
make build-all        # Build both

See Makefile for all available targets.

Documentation

Publishing

This crate is published to both registries:

License

About

High-performance Groth16 proof generator using arkworks for Orbinum privacy protocol

Resources

License

Apache-2.0, GPL-3.0 licenses found

Licenses found

Apache-2.0
LICENSE-APACHE2
GPL-3.0
LICENSE-GPL3

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors