Try it Live
Run SIWE examples in the interactive playground
WASM
WebAssembly bindings for SIWE operations.Overview
SIWE includes Zig implementation with WASM bindings for high-performance message operations. WASM provides native-speed formatting, parsing, and validation.Availability
WASM bindings are compiled from Zig source at:- Source:
/Users/williamcory/primitives/src/primitives/Siwe/siwe.zig - Module: Available via build system
- Target: wasm32-freestanding or wasm32-wasi
Types
Core Functions
format
parse
validate
Performance
Benchmarks
Typical performance compared to JavaScript:| Operation | JS (ms) | WASM (ms) | Speedup |
|---|---|---|---|
| Format | 0.05 | 0.02 | 2.5x |
| Parse | 0.15 | 0.06 | 2.5x |
| Validate | 0.01 | 0.005 | 2x |
WASM faster for string operations. JS competitive for simple validation. WASM benefits increase with message size.
When to Use WASM
Use WASM for:- High-throughput servers
- Batch processing
- Large messages
- Performance-critical paths
- Simple applications
- Infrequent operations
- Browser compatibility
- Smaller bundle size
Building WASM
Build Command
Output
- File:
siwe.wasm - Size: ~50KB optimized
- Exports: format, parse, validate, memory, allocate, free
Browser Support
Modern Browsers
- Chrome 57+
- Firefox 52+
- Safari 11+
- Edge 16+
Feature Detection
Limitations
- No crypto: Signature operations not in WASM (use JS crypto)
- Memory management: Manual allocation required
- Error handling: Numeric error codes, not exceptions
- Bundle size: Adds ~50KB to bundle
See Also
- Siwe.format - JavaScript implementation
- Siwe.parse - JavaScript implementation

