WebGPU-Accelerated Post-Quantum Blockchain Wallet
The UniCash wallet is a Progressive Web App (PWA) that enables users to:
- Generate post-quantum cryptographic keys (Dilithium)
- Create and sign transactions
- Generate zero-knowledge proofs using WebGPU
- Fallback to CPU proving (WASM) for unsupported devices
wallet/
├── src/
│ ├── App.tsx # Main React application
│ ├── main.tsx # Entry point
│ ├── index.css # Styles
│ ├── webgpu/
│ │ ├── prover.ts # WebGPU proof generation
│ │ └── shaders/
│ │ ├── ntt.wgsl # Number Theoretic Transform
│ │ └── fri.wgsl # FRI folding
│ └── wasm/
│ └── crypto.ts # WASM crypto bridge
├── public/
│ └── wasm/ # Compiled WASM modules
├── package.json
├── vite.config.ts
└── tsconfig.json
- Node.js 18+ and npm
- Rust and wasm-pack (for building WASM)
- Modern browser with WebGPU support
cd unicash-mvp/wallet
# Install dependencies
npm install
# Build WASM module
npm run wasm:build
# Start development server
npm run devOpen http://localhost:3000 in your browser.
The wallet uses Rust compiled to WebAssembly for cryptographic operations:
# Install wasm-pack (one time)
cargo install wasm-pack
# Build WASM module
cd unicash-mvp
wasm-pack build --target web --out-dir wallet/public/wasm wasm-crypto
# Or use npm script
cd wallet
npm run wasm:build| Browser | Version | WebGPU Support |
|---|---|---|
| Chrome | 113+ | ✅ Full support |
| Edge | 113+ | ✅ Full support |
| Safari | 17+ | ✅ Full support |
| Firefox | 120+ |
The wallet automatically detects WebGPU support:
if (!navigator.gpu) {
console.log('WebGPU not supported, falling back to CPU');
}- WebGPU (preferred): <1s proof generation
- WASM CPU: 3-5s proof generation
- Delegated proving: Send to prover network (future)
Performs Number Theoretic Transform on M31 field:
- Cooley-Tukey FFT algorithm
- Optimized for GPU parallelism
- Handles up to 2^20 elements
Implements FRI folding for Circle STARKs:
- Polynomial degree reduction
- Query evaluation
- Commitment generation
| Device | Method | Proof Time | Status |
|---|---|---|---|
| Desktop GPU | WebGPU | <1s | ✅ Target |
| Mobile GPU | WebGPU | <3s | ✅ Target |
| Desktop CPU | WASM | 3-5s | ✅ Acceptable |
| Mobile CPU | WASM | 5-10s |
# Unit tests
npm test
# WASM tests
cd ../wasm-crypto
cargo test --target wasm32-unknown-unknown# Build optimized bundle
npm run build
# Preview production build
npm run previewEnable verbose logging:
// In browser console
localStorage.setItem('debug', 'unicash:*');- Keys stored in browser's IndexedDB
- Encrypted with user password
- Never sent to server
- All computation happens locally
- No data leaves the device
- Proofs are zero-knowledge (reveal nothing)
- All RPC calls use HTTPS
- WebSocket connections use WSS
- P2P connections use libp2p encryption
- WebAssembly (all modern browsers)
- WebGPU (Chrome 113+, Safari 17+)
- IndexedDB (for key storage)
- Web Workers (for background tasks)
The wallet works on all devices but performs best with:
- WebGPU support (10x faster proving)
- 4GB+ RAM
- Modern GPU (2020+)
Solution: Use a supported browser or enable experimental features:
- Chrome:
chrome://flags/#enable-unsafe-webgpu - Firefox:
about:config→dom.webgpu.enabled
Solution: Rebuild WASM module:
npm run wasm:buildSolution:
- Check if WebGPU is enabled
- Close other GPU-intensive applications
- Use delegated proving (future feature)
- ✅ Basic UI
- ✅ WebGPU detection
- ✅ WASM crypto bridge
- ⏳ WGSL shader implementation
- Transaction creation
- Balance display
- Transaction history
- QR code support
- Staking interface
- Multi-signature support
- Hardware wallet integration
- Mobile app (React Native)
See CONTRIBUTING.md for development guidelines.
Apache 2.0 - See LICENSE for details.
Built with ❤️ for a post-quantum future