This example demonstrates the BMT (Binary Merkle Tree) hasher and SVG icon generation functionality from nectar-primitives in a web browser using WebAssembly.
- BMT Hasher: Calculate BMT hashes of input text with visual representations
- Icon Generator: Create unique SVG icons from chunk data with various styles
- Performance Benchmark: Test BMT hashing performance in your browser
- Rust (1.85.0 or later recommended)
- Trunk - A WASM application bundler for Rust
- WebAssembly target:
rustup target add wasm32-unknown-unknown
-
Install Trunk if not already installed:
cargo install trunk
-
Run the development server:
# From the wasm-demo directory trunk serve
-
Your browser will open automatically to http://localhost:8080
To build a production version:
trunk build --release
The compiled files will be in the dist
directory, ready for deployment to any static hosting service.
-
BMT Hasher Tab: Calculate BMT hashes of text input with real-time visualization
- Generates both a color-based byte visualization and an optional SVG icon
- Configure span parameter for BMT hasher
-
Icon Generator Tab: Create unique SVG icons from chunk data
- Specify chunk address, type, version, header, and payload
- Choose from 5 different generator styles, 2 shapes, and 4 color schemes
- Download or copy the generated SVG code
-
Benchmark Tab: Test BMT hashing performance
- Configure data size and iterations
- View detailed performance metrics
The demo showcases how WebAssembly enables complex cryptographic and visual operations to run efficiently in the browser using Rust code.