Zera is a developer-first privacy SDK that makes private transactions simple. With a clean API, developers can implement private SOL and SPL token transfers in just a few lines.
Version: 0.1.0-beta | Status: Public Beta | Release Date: 2025-10-31
โ ๏ธ BETA SOFTWARE: This SDK is in public beta. It is suitable for development and testing on devnet, but NOT recommended for production use with real funds. APIs may change before the stable 1.0.0 release.
โ
ZK Compression for private SOL transfers
โ
Stealth addresses for unlinkable payments
โ
Viewing keys for compliance and auditing
โ
React integration with hooks and providers
โ
TypeScript support with full type definitions
โ
Complete Next.js demo application
๐ Read the full changelog: CHANGELOG.md
๐ Migration guide: docs/MIGRATION_GUIDE.md
Zera provides a simple interface for private SOL and SPL token transfers using ZK Compression technology. The SDK wraps the ZK Compression APIs into easy-to-use functions that developers can integrate into their applications.
- Simple API: 3-line interface for private transfers
- Wallet Flexibility: Support for both Node.js Keypair and browser wallet adapters
- React Integration: Built-in React hooks and context providers
- TypeScript Support: Full type definitions and IntelliSense support
- Modular Design: Well-organized codebase with clear separation of concerns
# Install the latest beta version
npm install zera@0.1.0-beta
# Or use the beta tag
npm install zera@betaTo install the latest beta version with cutting-edge features:
npm install zera@betaOr install a specific beta version:
npm install zera@0.1.0-beta.0Note: Beta releases may contain experimental features and are recommended for testing and development purposes. Important: During beta, we recommend pinning to a specific version to avoid unexpected changes:
{
"dependencies": {
"zera": "0.1.0-beta"
}
}- Node.js: 18+ (recommended: 20+)
- TypeScript: 5.5+ (for TypeScript projects)
- React: 18+ (for React integration)
- RPC Endpoint: Light Protocol-compatible RPC for full functionality
import { init, getAddress, getBalance, compress, transfer, decompress } from 'zera';
import { Keypair } from '@solana/web3.js';
// Generate a test keypair
const keypair = Keypair.generate();
console.log('๐ Generated address:', keypair.publicKey.toBase58());
console.log('๐ฐ Fund this address at: https://faucet.solana.com');
// Initialize the SDK
await init({
wallet: keypair,
cluster: 'devnet'
});
// Get your address
const address = getAddress();
console.log('Address:', address);
// Check compressed balance
const balance = await getBalance();
console.log('Compressed balance:', balance);
// Compress SOL (shield)
const compressSignature = await compress(0.5); // 0.5 SOL
console.log('Compress signature:', compressSignature);
// Transfer compressed tokens privately
const transferSignature = await transfer(recipientAddress, 0.1); // 0.1 SOL
console.log('Transfer signature:', transferSignature);
// Decompress SOL (unshield)
const decompressSignature = await decompress(0.3); // 0.3 SOL
console.log('Decompress signature:', decompressSignature);import { ZeraProvider, useZera } from 'zera/react';
import { WalletAdapterNetwork } from '@solana/wallet-adapter-base';
import { ConnectionProvider, WalletProvider } from '@solana/wallet-adapter-react';
import { PhantomWalletAdapter } from '@solana/wallet-adapter-wallets';
function App() {
const wallets = useMemo(() => [new PhantomWalletAdapter()], []);
const network = WalletAdapterNetwork.Devnet;
return (
<ConnectionProvider endpoint="https://api.devnet.solana.com">
<WalletProvider wallets={wallets} autoConnect>
<ZeraProvider cluster={network}>
<WalletButton />
</ZeraProvider>
</WalletProvider>
</ConnectionProvider>
);
}
function WalletButton() {
const { address, balance, compress, transfer, decompress, loading, error } = useZera();
if (loading) return <div>Loading...</div>;
if (error) return <div>Error: {error}</div>;
return (
<div>
<p>Address: {address}</p>
<p>Balance: {balance} lamports</p>
<button onClick={() => compress(0.1)}>Compress 0.1 SOL</button>
<button onClick={() => decompress(0.1)}>Decompress 0.1 SOL</button>
</div>
);
}Initialize the SDK with configuration options.
Parameters:
config.wallet- Wallet instance (Keypair or wallet adapter)config.cluster- Solana cluster ('devnet' | 'mainnet-beta')config.rpcUrl- Custom RPC endpoint URLconfig.commitment- Transaction commitment level
Get the user's public key as a base58 string.
Get the compressed token balance in lamports.
Compress SOL from regular account to compressed token account (shield operation).
Parameters:
amount- Amount to compress in SOL
Transfer compressed tokens to another address privately.
Parameters:
to- Recipient's public key as base58 stringamount- Amount to transfer in SOL
Decompress SOL from compressed account back to regular account (unshield operation).
Parameters:
amount- Amount to decompress in SOLto- Optional destination address (defaults to user's address)
Request devnet airdrop for testing purposes.
Parameters:
amount- Amount to request in SOL (default: 2 SOL)
React context provider for managing SDK state.
Props:
wallet- Wallet adapter from @solana/wallet-adapter-reactcluster- Solana cluster ('devnet' | 'mainnet-beta')children- React children
Hook to access GhostSol context.
Returns:
address- User's address (string | null)balance- Compressed balance (number | null)loading- Initialization status (boolean)error- Error message (string | null)compress()- Compress functiontransfer()- Transfer functiondecompress()- Decompress functionfundDevnet()- Airdrop functionrefresh()- Refresh balance and address
The SDK is built with modularity and maintainability in mind:
types.ts- TypeScript interfaces and typeswallet.ts- Wallet normalization utilitiesrpc.ts- ZK Compression RPC initializationrelayer.ts- TestRelayer implementation for fee paymentzera.ts- Main SDK class implementation
ZeraProvider.tsx- React context provideruseZera.ts- React hook for context access
- Compress SOL for private storage
- Private transfers between addresses
- Decompress back to regular SOL
- Built on Light Protocol's stateless.js
- Generate unlinkable one-time payment addresses
- Complete transaction privacy
- ECDH-based key derivation (secp256k1)
- Payment scanning and detection
- 34+ E2E test assertions
- Selective balance disclosure for auditors
- Time-limited access with expiration
- Permission-based access control
- Read-only (no spending authority)
- Revocation support
ZeraProvidercontext provideruseZera()hook for easy access- Browser wallet adapter support
- State management and error handling
- Devnet Only: Not yet tested on mainnet
- Prototype Encryption: ElGamal implementation for testing only
- Manual Scanning: Blockchain scanning for stealth addresses requires manual ephemeral key collection
- SOL Only: SPL token support coming in future releases
- RPC Requirements: Needs Light Protocol-compatible RPC endpoint
- ๐ Automated blockchain scanning for stealth addresses
- ๐ Production-ready ElGamal encryption (audited)
- ๐ Transaction history API
- ๐ Performance optimizations
- ๐ SPL token support (planned)
- ๐ฎ Mainnet support
- ๐ฎ Hardware wallet integration
- ๐ฎ Mobile SDK (React Native)
- ๐ฎ Multi-signature support
A complete Next.js demo application is available in examples/nextjs-demo/ showcasing:
- Wallet connection with Phantom
- Balance display
- Private SOL operations (compress, transfer, decompress)
- Transaction logging
- Error handling
# Install dependencies
npm install
# Start the demo application
cd examples/nextjs-demo
npm run dev
# Open http://localhost:3000 in your browser# Run functionality tests
cd sdk
npx tsx test/sdk-functionality-test.ts
# Run end-to-end tests (requires funded account)
npx tsx test/e2e-test.ts- CHANGELOG.md - Complete release notes and version history
- MIGRATION_GUIDE.md - Guide for migrating between versions
- SDK README - Detailed API documentation
- Implementation Docs - Technical implementation details
- Research - Privacy architecture and protocol analysis
- This is BETA software - not audited for production use
- Do NOT use with real funds on mainnet
- Prototype ElGamal encryption is for testing only
- Range proofs are placeholder implementations (not cryptographically secure)
- Professional security audit required before production use
- Report security issues privately via GitHub Security Advisories
Implemented Privacy Protections:
- โ ZK Compression: Hide transaction amounts and balances on-chain
- โ Stealth Addresses: Unlinkable one-time payment addresses using ECDH
- โ Viewing Keys: Selective disclosure for regulatory compliance
- โ Encrypted Balances: Twisted ElGamal encryption over Ristretto255
- โ Domain Separation: Cryptographic domain separation prevents protocol collisions
Security Assumptions:
- Elliptic Curve Discrete Logarithm Problem (ECDLP) is hard on secp256k1 and Ristretto255
- Decisional Diffie-Hellman (DDH) assumption holds for ElGamal encryption
- SHA-256 and SHA-512 are collision-resistant and pre-image resistant
- AES-GCM provides authenticated encryption with unique nonces
- Platform CSPRNG (crypto.getRandomValues) provides secure randomness
- User private keys remain confidential and are never exposed
Known Security Limitations:
โ ๏ธ Range proofs are placeholder only (no cryptographic proof of amount validity)โ ๏ธ Viewing key revocation is client-side only (not enforced on-chain)โ ๏ธ Fallback encryption methods in stealth addresses (should be removed for production)โ ๏ธ No explicit point validation for secp256k1 public keysโ ๏ธ No secure memory clearing for cryptographic key materialโ ๏ธ RPC providers can observe query patterns (metadata leakage)
Comprehensive security documentation is available for auditors and security researchers:
- Security Audit Preparation - Complete guide for security auditors
- Security Assumptions - Cryptographic and operational assumptions
- Audit Checklist - Systematic security review checklist
- Dependency Security Audit - External dependencies and API keys
Encryption (sdk/src/privacy/encryption.ts):
- Algorithm: Twisted ElGamal over Ristretto255 curve
- Symmetric Encryption: AES-256-GCM with random 12-byte IV
- Key Derivation: SHA-256 KDF with domain separation
- Commitment: Pedersen commitment for amount hiding
- Status: Prototype implementation for testing
Stealth Addresses (sdk/src/privacy/stealth-address.ts):
- Curve: secp256k1 (Bitcoin's elliptic curve)
- Protocol: ECDH-based one-time addresses
- Key Derivation: P = Hash(r*V)*G + S
- Unlinkability: Fresh ephemeral key per payment
- Status: Functional implementation, needs production hardening
Viewing Keys (sdk/src/privacy/viewing-keys.ts):
- Derivation: Account-specific keys using SHA-512 and XOR
- Encryption: ECIES-style encryption for auditor keys
- Access Control: Permission-based with expiration
- Status: Functional, client-side permission enforcement only
For Developers:
- Never expose private keys or seed phrases in code or logs
- Always verify recipient addresses before transfers
- Use environment variables for sensitive configuration (RPC API keys)
- Validate all user input before cryptographic operations
- Test thoroughly on devnet before any mainnet usage
- Keep viewing keys secure and revoke when no longer needed
- Run local RPC node for maximum privacy (future enhancement)
For Users:
- Use hardware wallets when possible for key protection
- Verify recipient addresses through multiple channels
- Understand beta limitations before using the SDK
- Never share private keys, seed phrases, or viewing keys
- Keep wallet software and browser up to date
- Be aware that RPC providers can see query patterns
For Auditors:
- Review cryptographic implementations in
sdk/src/privacy/directory - Check security comments marked with "SECURITY CRITICAL" and "
โ ๏ธ " - Verify no insecure fallback behaviors in production code
- Test with invalid inputs and malformed cryptographic parameters
- Review error handling for information leakage
- Validate randomness sources and nonce uniqueness
Protected Against:
- โ Transaction linkability (stealth addresses prevent linking)
- โ Balance disclosure (encrypted balances hide amounts)
- โ Unauthorized viewing (viewing keys require explicit authorization)
- โ Passive network observers (HTTPS encryption on RPC traffic)
- โ Replay attacks (transaction nonces and blockhash expiration)
NOT Protected Against (Out of Scope):
- โ Compromised user device with malware or keyloggers
- โ Physical access to unlocked wallet
- โ Social engineering or phishing attacks
- โ Quantum computer attacks (future threat)
- โ Malicious RPC provider censorship
- โ Browser extensions stealing wallet data
- โ Memory inspection or process dumps
- โ Side-channel attacks (timing, power, EM analysis)
Current Status: Preparing for professional security audit
Audit Preparation:
- Security documentation complete
- Security assumptions documented
- Audit checklist prepared
- Security comments added to critical code
- Known limitations identified and documented
- Professional security audit (pending)
- Remediation of audit findings (pending)
- Final security review before v1.0.0 (pending)
Target: Complete professional security audit before v1.0.0 stable release
If you discover a security vulnerability, please report it responsibly:
- DO NOT open a public GitHub issue
- Use GitHub Security Advisories (preferred): Report a vulnerability
- Or email security contact: [To be added]
- Include detailed description and reproduction steps
- Allow time for us to fix before public disclosure
Security Disclosure Policy:
- We will acknowledge receipt within 48 hours
- We will provide an initial assessment within 1 week
- We will work with you to understand and fix the issue
- We will credit you in the security advisory (unless you prefer to remain anonymous)
- We request 90 days for responsible disclosure
v0.2.0-beta (Next Release):
- Remove insecure fallback behaviors
- Add explicit point validation for all public keys
- Implement constant-time comparison utilities
- Add secure memory clearing for key material
- Improve error messages (prevent information leakage)
v0.3.0-beta:
- Implement proper range proofs (Bulletproofs)
- On-chain viewing key registry for revocation
- ZK proof generation for confidential transfers
- Formal verification of key protocols
v1.0.0 (Stable Release):
- Complete professional security audit
- All critical security issues resolved
- Production-ready cryptographic implementations
- Comprehensive security testing
- Mainnet deployment approved
We welcome contributions! This SDK follows strict development principles:
- Best Practices: Optimized for performance, maintainability, readability, and modularity
- Functional Modularity: Well-defined, reusable functions with single purposes
- File Modularity: Organized codebase with clear separation of concerns
- Documentation: Comprehensive comments and JSDoc for all functions
- Testing: E2E tests for all features
- Readability: Intuitive naming conventions and logical structure
MIT License - see LICENSE file for details.
- GitHub Issues: Bug reports and feature requests
- GitHub Discussions: Questions and community support
- Discord: [Join our Discord] (coming soon)
- Twitter: [@zera] (coming soon)
- Light Protocol - ZK Compression infrastructure
- Solana Foundation - Blockchain platform
- Noble Crypto - Cryptography libraries
- Open Source Community - Contributors and testers
Ready to build private Solana applications? Get started with our Quick Start Guide!