Skip to content
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Changed
- **BREAKING**: `generate_proof_wasm()` now accepts `num_public_signals: usize` instead of `circuit_type: &str`
- Makes the library truly generic and usable with any Groth16 circuit
- No need to modify source code for custom circuits

### Added
- Validation for `num_public_signals` parameter (must be > 0 and < witness length)

### Removed
- Hardcoded circuit type mappings ("unshield", "transfer", "disclosure")

## [0.1.0] - 2026-02-12

### Added
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "groth16-proofs"
version = "0.1.0"
version = "1.0.0"
edition = "2021"
license = "Apache-2.0 OR GPL-3.0-or-later"
description = "High-performance Groth16 proof generator using arkworks for Orbinum privacy protocol"
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ let proof = generate_proof_from_witness(&witness, "proving_key.ark")?;

**JavaScript (Browser/Node.js)**:
```typescript
import { generateProofWasm } from 'groth16-proofs';
// Import from downloaded WASM module (see releases)
import { generate_proof_wasm } from './wasm/groth16_proofs.js';

const result = generateProofWasm('unshield', witnessJson, provingKeyBytes);
const result = generate_proof_wasm(5, witnessJson, provingKeyBytes); // 5 = number of public signals
```

📖 **Full guides**: See [Installation](./docs/installation.md) and [Usage](./docs/usage.md)
Expand All @@ -48,7 +49,7 @@ This crate generates **128-byte compressed Groth16 proofs** from witness data us

```
┌────────────────────────────────────────────────┐
orbinum-groth16-proofs │
│ groth16-proofs
├────────────────────────────────────────────────┤
│ │
│ ┌──────────────────────────────────────────┐ │
Expand Down
99 changes: 24 additions & 75 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,24 @@ use orbinum_groth16_proofs::generate_proof_from_witness;
let proof = generate_proof_from_witness(&witness, "proving_key.ark")?;
```

### As an NPM Package (WASM)
### As a WASM Module

Install via npm:
**Note**: This library is not published to NPM. To use WASM, download the precompiled binaries from [GitHub Releases](https://github.com/orbinum/groth16-proofs/releases).

1. Download `orb-groth16-proof.tar.gz` from the latest release
2. Extract to your project:
```bash
npm install groth16-proofs
tar -xzf orb-groth16-proof.tar.gz -C ./wasm
```

Or yarn:

```bash
yarn add groth16-proofs
```

Then import in TypeScript/JavaScript:
3. Import in TypeScript/JavaScript:

```typescript
import { generateProofWasm } from 'orbinum-groth16-proofs';
import { generate_proof_wasm } from './wasm/groth16_proofs.js';

const result = generateProofWasm('unshield', witnessJson, provingKeyBytes);
// numPublicSignals depends on your circuit (check your circuit definition)
const numPublicSignals = 5;
const result = generate_proof_wasm(numPublicSignals, witnessJson, provingKeyBytes);
```

### Development Installation
Expand Down Expand Up @@ -79,7 +77,7 @@ make build

```bash
make build-wasm
# Output: ./pkg/orbinum_groth16_proofs.wasm
# Output: ./pkg/groth16_proofs_bg.wasm
```

### Both
Expand Down Expand Up @@ -126,71 +124,24 @@ wasm-pack build --target web --out-dir ./pkg --release --features wasm

## Quick Start

### Rust Example

```rust
use orbinum_groth16_proofs::generate_proof_from_witness;

fn main() -> Result<(), Box<dyn std::error::Error>> {
// Witness data (hex-encoded field elements)
let witness = vec![
"0x0100000000000000000000000000000000000000000000000000000000000000".to_string(),
// ... ~11,808 elements total
];

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

println!("Proof (128 bytes): 0x{}", hex::encode(&proof_bytes));
Ok(())
}
```
Once installed, see the **[Usage Guide](./usage.md)** for:
- Complete API reference for Rust and WASM
- Full working examples (Browser, Node.js, native)
- Error handling and best practices
- Performance optimization tips

### TypeScript Example (Browser)
**Minimal example**:

```typescript
import { generateProofWasm } from 'orbinum-groth16-proofs';

async function generateProof() {
// Load witness and proving key
const witness = [
"0x0100000000000000000000000000000000000000000000000000000000000000",
// ...
];

const provingKeyFile = await fetch('proving_keys/unshield.ark');
const provingKeyBytes = new Uint8Array(await provingKeyFile.arrayBuffer());

// Generate proof
try {
const resultJson = generateProofWasm(
'unshield',
JSON.stringify(witness),
provingKeyBytes
);

const { proof, publicSignals } = JSON.parse(resultJson);
console.log('✓ Proof generated:', proof);
console.log('✓ Public signals:', publicSignals);
} catch (error) {
console.error('✗ Proof generation failed:', error);
}
}
```rust
// Rust
use groth16_proofs::generate_proof_from_witness;
let proof = generate_proof_from_witness(&witness, "key.ark")?;
```

### TypeScript Example (Node.js WASM)

```typescript
import { generateProofWasm } from 'orbinum-groth16-proofs';
import fs from 'fs';

const witness = JSON.parse(fs.readFileSync('witness.json', 'utf-8'));
const provingKeyBytes = fs.readFileSync('proving_key.ark');

const result = generateProofWasm('unshield', JSON.stringify(witness), new Uint8Array(provingKeyBytes));
const { proof, publicSignals } = JSON.parse(result);

console.log(proof, publicSignals);
// WASM
import { generate_proof_wasm } from './wasm/groth16_proofs.js';
const result = generate_proof_wasm(numPublicSignals, witnessJson, keyBytes);
```

## Configuration
Expand Down Expand Up @@ -264,5 +215,3 @@ Ensure your TypeScript config includes WASM types:
## Next Steps

- Read the [Usage Guide](./usage.md) for detailed API reference
- Check the [tests](../src/) for more examples
- See [GitHub Actions CI](../.github/workflows/) for build examples
25 changes: 7 additions & 18 deletions docs/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,6 @@ The GitHub Actions pipeline will:
- Create release with tag
```

#### Publish to npm:

```yaml
- Build WASM (second time)
- Publish pkg/ directory to npm
- Uses NODE_AUTH_TOKEN secret
```

## Configuration Files

### `.cargo/release.toml`
Expand Down Expand Up @@ -183,21 +175,22 @@ tar -xzf pkg.tar.gz

### crates.io

Published as: `orbinum-groth16-proofs`
Published as: `groth16-proofs`

**Install**:
```toml
[dependencies]
groth16-proofs = "0.2"
```

### npm
### WASM

Published as: `orbinum-groth16-proofs`
Not published to NPM. Download precompiled binaries from GitHub Releases:

**Install**:
**Download**:
```bash
npm install orbinum-groth16-proofs
curl -L https://github.com/orbinum/groth16-proofs/releases/download/v0.2.0/orb-groth16-proof.tar.gz -o wasm.tar.gz
tar -xzf wasm.tar.gz -C ./wasm
```

## Manual Release (Fallback)
Expand Down Expand Up @@ -278,16 +271,12 @@ git push origin main
# ✅ WASM builds
# ✅ Published to crates.io
# ✅ GitHub release created with orb-groth16-proof.tar.gz
# ✅ npm package published
```

Then verify:
```bash
# Check on crates.io
curl https://crates.io/api/v1/crates/orbinum-groth16-proofs/0.2.0

# Check on npm
npm info orbinum-groth16-proofs@0.2.0
curl https://crates.io/api/v1/crates/groth16-proofs/0.2.0

# Check GitHub
curl https://api.github.com/repos/orbinum/groth16-proofs/releases/latest
Expand Down
Loading