A browser-based implementation of Verifiable Delay Function (VDF) and Verifiable Random Function (VRF) for the VTP protocol.
Features • Quick Start • Documentation • API Reference • Contributing
- Overview
- Features
- Architecture
- Quick Start
- Installation
- Development
- Building for Production
- Testing
- Project Structure
- API Reference
- Configuration
- Performance
- Browser Compatibility
- Documentation
- Contributing
- License
- Acknowledgments
VTP Node is a single-node prototype implementation of the Verifiable Time Proof (VTP) protocol. It demonstrates the feasibility of running VDF and VRF computations entirely in the browser using WebAssembly.
Verifiable Time Proof (VTP) is a cryptographic protocol that combines:
- VDF (Verifiable Delay Function): A function that takes a prescribed amount of time to compute, even with parallel processing, but produces a unique output that can be quickly verified.
- VRF (Verifiable Random Function): A function that produces a pseudorandom output along with a proof that the output was computed correctly.
- Accessibility: No installation required, runs in any modern browser
- Transparency: All computations are visible and verifiable
- Decentralization: Each user runs their own node
- Privacy: Private keys never leave the browser
| Feature | Description | Status |
|---|---|---|
| VDF Engine | Wesolowski VDF over imaginary quadratic class groups (WebAssembly) | ✅ Complete |
| VRF Implementation | ECVRF-ED25519 proof generation and verification | ✅ Complete |
| Web Worker | Background computation with time-slicing | ✅ Complete |
| Real-time Dashboard | Live progress visualization with Canvas 2D | ✅ Complete |
| PWA Support | Installable Progressive Web App | ✅ Complete |
| Checkpoint System | Automatic persistence with IndexedDB | ✅ Complete |
| Adaptive Scheduling | AudioContext-based background execution | ✅ Complete |
| Metric | Target | Description |
|---|---|---|
| VDF Speed | Class group squarings/sec | Sequential class group operations |
| VDF Verification | O(log l) group ops | Wesolowski proof verification |
| VRF Latency | ≤ 1ms | Proof generation time |
| Background Retention | ≥ 50% | Speed when tab is in background |
| Memory Stability | < 10MB growth | Over 30 minutes of operation |
┌─────────────────────────────────────────────────────────────┐
│ Browser Environment │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ Main Thread (UI) │ │
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────────┐ │ │
│ │ │ Dashboard │ │ Stats │ │ Event Log │ │ │
│ │ │ Component │ │ Panel │ │ Component │ │ │
│ │ └──────────────┘ └─────────────┘ └─────────────────┘ │ │
│ └───────────────────────────┬─────────────────────────────┘ │
│ │ postMessage │
│ ┌───────────────────────────┴─────────────────────────────┐ │
│ │ Web Worker │ │
│ │ ┌─────────────────────────────────────────────────────┐ │ │
│ │ │ vtp-core (WebAssembly) │ │ │
│ │ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │ │
│ │ │ │ VDF Engine │ │ VRF Engine │ │ Session │ │ │ │
│ │ │ │ (Class Grp) │ │ (ED25519) │ │ Manager │ │ │ │
│ │ │ └─────────────┘ └─────────────┘ └─────────────┘ │ │ │
│ │ └─────────────────────────────────────────────────────┘ │ │
│ │ ┌─────────────────────────────────────────────────────┐ │ │
│ │ │ Scheduler │ Checkpoint │ Error Handler │ │ │
│ │ └─────────────────────────────────────────────────────┘ │ │
│ └──────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘
- Initialization: User starts VDF computation with seed and parameters
- Computation: Worker performs sequential class group squarings (Wesolowski VDF) in batches
- Checkpointing: State is periodically saved to IndexedDB
- VRF Sampling: At each checkpoint interval, VRF proof is generated
- Progress Reporting: Worker sends progress updates to main thread
- Visualization: Dashboard displays real-time statistics and animations
Before you begin, ensure you have the following installed:
- Rust: 1.70 or later (Install Rust)
- wasm-pack: 0.12 or later (Install wasm-pack)
- Node.js: 18 or later (Install Node.js)
- npm: 9 or later (comes with Node.js)
# Clone and setup in one command
git clone <repository-url> && cd vtp-node && npm install && npm run wasm:build# 1. Clone the repository
git clone <repository-url>
cd vtp-node
# 2. Install Rust toolchain (if not already installed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
# 3. Add WebAssembly target
rustup target add wasm32-unknown-unknown
# 4. Install wasm-pack
cargo install wasm-pack
# 5. Install Node.js dependencies
npm install
# 6. Build the Rust/Wasm library
npm run wasm:build
# 7. Start the development server
npm run devOpen your browser and navigate to:
http://localhost:5173
npm installpnpm installyarn installStart the development server with hot reload:
npm run devThe server will start at http://localhost:5173 by default.
Build the Rust core library to WebAssembly:
npm run wasm:buildThis will compile the vtp-core crate and output the Wasm files to static/wasm/.
During development, you may want to watch for Rust changes:
# In terminal 1: Watch and rebuild Wasm
cd src/lib/vtp-core
cargo watch -w src -s 'wasm-pack build --target web --out-dir ../../../static/wasm'
# In terminal 2: Run dev server
npm run devFormat all code:
# Format Rust code
cargo fmt
# Format TypeScript/Svelte code
npm run formatRun linters:
# Lint all code
npm run lint
# Lint Rust code
cargo clippy
# Type check
npm run checknpm run buildThis will:
- Build the Rust/Wasm library
- Build the Worker
- Build the Svelte application
- Output to the
build/directory
npm run preview# Development build
NODE_ENV=development npm run build
# Production build (minified)
NODE_ENV=production npm run buildRun all Rust unit tests:
npm run wasm:testOr directly with cargo:
cd src/lib/vtp-core
cargo testRun frontend tests with Vitest:
npm testRun tests with interactive UI:
npm run test:uiGenerate test coverage report:
npm run test:coverageRun Rust benchmarks:
cd src/lib/vtp-core
cargo benchvtp-node/
├── README.md # This file
├── package.json # Node.js dependencies and scripts
├── svelte.config.js # SvelteKit configuration
├── vite.config.ts # Vite build configuration
├── tsconfig.json # TypeScript configuration
├── Cargo.toml # Rust workspace configuration
├── rust-toolchain.toml # Rust toolchain specification
├── rustfmt.toml # Rust formatting configuration
├── .eslintrc.cjs # ESLint configuration
├── .prettierrc # Prettier configuration
├── .editorconfig # Editor configuration
├── .gitignore # Git ignore rules
├── .gitattributes # Git attributes
├── .env.example # Environment variables example
├── LICENSE # MIT License
│
├── src/ # Source code
│ ├── app.html # HTML entry point
│ │
│ ├── routes/ # SvelteKit routes
│ │ ├── +layout.svelte # Root layout
│ │ └── +page.svelte # Main page
│ │
│ ├── components/ # Svelte components
│ │ ├── Dashboard.svelte # Main dashboard
│ │ ├── StatsPanel.svelte # Statistics panel
│ │ ├── EventLog.svelte # Event log
│ │ ├── IdentityBadge.svelte # Node identity
│ │ ├── VDFCanvas.svelte # VDF visualization
│ │ └── PWAInstall.svelte # PWA install prompt
│ │
│ ├── stores/ # Svelte stores
│ │ └── worker.ts # Worker state management
│ │
│ ├── utils/ # Utility functions
│ │ └── index.ts # Common utilities
│ │
│ └── lib/ # Libraries
│ ├── vtp-core/ # Rust core library
│ │ ├── Cargo.toml # Rust package configuration
│ │ ├── src/ # Rust source code
│ │ │ ├── lib.rs # Library entry point
│ │ │ ├── vdf.rs # VDF implementation
│ │ │ ├── vrf.rs # VRF implementation
│ │ │ ├── session.rs # Session manager
│ │ │ ├── error.rs # Error types
│ │ │ └── utils.rs # Utility functions
│ │ └── tests/ # Rust tests
│ │
│ └── worker/ # Web Worker
│ ├── index.ts # Worker entry point
│ └── types.ts # Type definitions
│
├── static/ # Static files
│ ├── manifest.json # PWA manifest
│ ├── sw.js # Service Worker
│ ├── icons/ # App icons
│ └── screenshots/ # App screenshots
│
├── tests/ # Frontend tests
├── scripts/ # Build scripts
│ └── build-worker.js # Worker build script
│
└── docs/ # Documentation
├── README.md # Technical documentation
├── api.md # API reference
├── architecture.md # Architecture guide
├── development.md # Development guide
└── deployment.md # Deployment guide
/// Execute a single VDF step (class group squaring)
pub fn vdf_step(state: &[u8; 32]) -> [u8; 32]
/// VDF Iterator for batch processing
pub struct VdfIterator { ... }
impl VdfIterator {
pub fn new(seed: &[u8], total: u64) -> Self
pub fn step(&self) -> u64
pub fn total(&self) -> u64
pub fn is_finished(&self) -> bool
pub fn get_state(&self) -> Vec<u8>
pub fn next(&mut self) -> bool
pub fn run_batch(&mut self, max_steps: u64) -> u64
}
/// Generate Wesolowski proof
pub fn generate_proof(seed: &[u8], state_bytes: &[u8], total: u64) -> Vec<u8>
/// Verify Wesolowski proof
pub fn verify_proof(seed: &[u8], state_bytes: &[u8], total: u64, proof_bytes: &[u8]) -> bool/// Generate a new VRF keypair
pub fn generate_keypair() -> VrfKeypair
/// Generate a VRF proof
pub fn prove(secret_key: &[u8], message: &[u8]) -> Vec<u8>
/// Verify a VRF proof
pub fn verify(public_key: &[u8], message: &[u8], proof: &[u8]) -> bool/// VDF Session Manager
pub struct Session { ... }
impl Session {
pub fn new(seed: &[u8], total: u64, k: u64, tau: &[u8], checkpoint_interval: u64) -> Self
pub fn state(&self) -> SessionState
pub fn public_key(&self) -> Vec<u8>
pub fn pause(&mut self)
pub fn resume(&mut self)
pub fn run_batch(&mut self, max_steps: u64) -> BatchResult
pub fn get_checkpoint_data(&self) -> Vec<u8>
pub fn verify_winner(&self, step: u64, proof: &[u8]) -> bool
pub fn generate_vdf_proof(&self) -> Vec<u8>
pub fn verify_vdf_proof(&self, proof_bytes: &[u8]) -> bool
}| Type | Description | Parameters |
|---|---|---|
start |
Start VDF computation | seed, total, k, tau, checkpointInterval |
pause |
Pause computation | - |
resume |
Resume computation | - |
stop |
Stop computation | - |
| Type | Description | Data |
|---|---|---|
started |
Computation started | publicKey |
progress |
Progress update | step, speed, memoryUsage |
winner |
VRF winner found | step, proof |
finished |
Computation finished | step |
heartbeat |
Keep-alive signal | timestamp, status |
error |
Error occurred | code, message, recoverable |
// Worker state store
export const workerState: Writable<WorkerState>;
// Events store
export const events: Writable<VtpEvent[]>;
// Progress store (derived)
export const progress: Readable<number>;
// Functions
export function addEvent(event: Omit<VtpEvent, 'timestamp'>): void;
export function resetWorkerState(): void;Create a .env file in the root directory:
# Application
NODE_ENV=development
PORT=5173
# VDF Configuration
VDF_DEFAULT_TOTAL=1000000
VDF_CHECKPOINT_INTERVAL=100000
# VRF Configuration
VRF_KEYPAIR_SIZE=32
# Performance
WORKER_BATCH_SIZE=1000
WORKER_TIME_SLICE_MS=50
# Logging
LOG_LEVEL=debug
ENABLE_PERFORMANCE_MONITORING=true
# PWA
ENABLE_PWA=true
SERVICE_WORKER_PATH=/sw.jsEdit vite.config.ts to customize the build:
export default defineConfig({
plugins: [sveltekit()],
server: {
port: 5173,
strictPort: false
},
build: {
target: 'esnext',
minify: 'esbuild',
sourcemap: true
}
});Edit Cargo.toml to customize Rust compilation:
[profile.release]
opt-level = 3 # Maximum optimization
lto = true # Link-time optimization
codegen-units = 1 # Single codegen unit for better optimization-
Batch Size: Adjust
WORKER_BATCH_SIZEbased on your needs- Larger batches = less overhead, but less responsive
- Smaller batches = more responsive, but more overhead
-
Time Slice: Adjust
WORKER_TIME_SLICE_MSfor responsiveness- 50ms is a good default for smooth UI
- Lower values = more responsive UI, but slower computation
-
Memory Management: Monitor memory usage in Chrome DevTools
- Use the Memory tab to detect leaks
- Check heap snapshots periodically
Run benchmarks to measure performance:
# Rust benchmarks
cd src/lib/vtp-core
cargo bench
# Frontend performance
npm run test:performanceUse Chrome DevTools for profiling:
- Open DevTools (F12)
- Go to Performance tab
- Click Record
- Perform actions
- Click Stop
- Analyze results
| Browser | Version | Status | Notes |
|---|---|---|---|
| Chrome | 90+ | ✅ Full Support | Best performance |
| Edge | 90+ | ✅ Full Support | Chromium-based |
| Firefox | 90+ | ✅ Supported | No performance.memory |
| Safari | 15+ | AudioContext limitations | |
| Mobile Chrome | 90+ | ✅ Supported | Performance varies |
| Mobile Safari | 15+ | Background limitations |
| Feature | Chrome | Firefox | Safari |
|---|---|---|---|
| WebAssembly | ✅ | ✅ | ✅ |
| Web Workers | ✅ | ✅ | ✅ |
| AudioContext | ✅ | ✅ | |
| IndexedDB | ✅ | ✅ | ✅ |
| PWA Install | ✅ | ❌ | ❌ |
performance.memory |
✅ | ❌ | ❌ |
- Technical Documentation: Detailed technical specifications
- API Reference: Complete API documentation
- Architecture Guide: System architecture overview
- Development Guide: Development setup and workflow
- Deployment Guide: Production deployment instructions
- Cryptographic Security Verification: Professional-grade security audit report
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Clone your fork:
git clone https://github.com/your-username/vtp-node.git
- Create a feature branch:
git checkout -b feature/amazing-feature
- Commit your changes:
git commit -m 'feat: add amazing feature' - Push to the branch:
git push origin feature/amazing-feature
- Open a Pull Request
We follow Conventional Commits:
feat: add new feature
fix: bug fix
docs: documentation changes
style: formatting changes
refactor: code refactoring
test: adding tests
chore: maintenance tasks
- All submissions require review
- Tests must pass
- Code must follow style guidelines
- Documentation must be updated
This project is licensed under the MIT License - see the LICENSE file for details.
MIT License
Copyright (c) 2026 VTP Team
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
- curve25519-dalek - ECVRF implementation
- wasm-pack - WebAssembly tooling
- Svelte - Frontend framework
- Vite - Build tool
- Workbox - PWA tooling
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: support@vtp-node.dev