Choose Your Platform
The ZK ElGamal Proof SDK is available for both Rust and JavaScript/TypeScript development. Choose the installation method that matches your project.Rust Installation
Prerequisites
Add to Cargo.toml
Add the SDK to your project’s dependencies:For Solana program development, you may need additional dependencies:
Cargo.toml
Cargo.toml
Platform-Specific Features
The SDK automatically enables platform-specific features:When targeting
target_os = "solana", certain dependencies like encryption and proof generation are disabled to optimize program size. Full functionality is available for all other platforms.JavaScript Installation
Prerequisites
Install Package
Install the WebAssembly package:The package includes pre-compiled WASM binaries for all target environments.
Environment-Specific Setup
- Node.js
- Web Browser
- Webpack
- Vite
For Node.js applications, use the CommonJS entry point:Package Path:
./dist/node/index.cjsTypeScript Support
The package includes TypeScript definitions for all environments:Verify Installation
- Rust
- JavaScript (Node.js)
- JavaScript (Browser)
Create a simple test to verify the installation:Run with:
src/main.rs
Next Steps
Quickstart Guide
Learn how to generate keypairs, encrypt data, and create zero-knowledge proofs.
Core Concepts
Understand the cryptographic foundations of ElGamal encryption and zero-knowledge proofs.
Troubleshooting
Rust: Compilation errors on curve25519-dalek
Rust: Compilation errors on curve25519-dalek
The SDK uses
curve25519-dalek v4.1.3 with SIMD optimizations. If you encounter performance issues in development builds, the workspace configuration automatically sets opt-level = 3 for this crate.This is already configured in the workspace Cargo.toml and should not require manual intervention.JavaScript: WASM module initialization failed
JavaScript: WASM module initialization failed
For web environments, ensure you call Node.js and bundler targets do not require initialization.
await init() before using any SDK functions:Bundler: AsyncWebAssembly experiment required
Bundler: AsyncWebAssembly experiment required
Some bundlers require enabling WebAssembly support:Webpack 5:Vite: No special configuration needed, but exclude from optimization: