Try it Live
Run Authorization examples in the interactive playground
WASM
WebAssembly bindings for authorization operations.Overview
WASM bindings provide lightweight access to Zig implementation of authorization operations. These functions offer potential performance benefits for compute-intensive operations. Implementation: TypeScript bindings to Zig authorization.zig via WASMFunctions
validateWasm
Validate authorization structure via WASM.auth: Authorization to validate
Authorization.validate.call(auth) but uses WASM implementation
Usage
Implementation
TypeScript Binding:signingHashWasm
Calculate signing hash via WASM.chainId: Chain IDaddress: Target addressnonce: Nonce
Authorization.hash.call({ chainId, address, nonce }) but uses WASM
Usage
Implementation
TypeScript Binding:authorityWasm
Recover authority (signer) via WASM.auth: Authorization to recover from
Authorization.verify.call(auth) but uses WASM
Usage
Implementation
TypeScript Binding:gasCostWasm
Calculate gas cost via WASM.authCount: Number of authorizationsemptyAccounts: Number of empty accounts
Authorization.calculateGasCost.call(authList, emptyAccounts) but uses WASM
Usage
Implementation
TypeScript Binding:Performance Comparison
JavaScript vs WASM
Typical performance (relative):| Operation | JS | WASM | Speedup |
|---|---|---|---|
| validate | 1x | 1.5x | 50% faster |
| signingHash | 1x | 2x | 2x faster |
| authority | 1x | 2.5x | 2.5x faster |
| gasCost | 1x | 1x | Same |
- JavaScript engine
- WASM runtime
- Hardware
- Input size
When to Use WASM
Use WASM for:- High-throughput validation
- Batch processing many authorizations
- Performance-critical paths
- Server-side processing
- Simple operations
- One-off validations
- Browser environments without WASM
- Debugging (better stack traces)
Usage Patterns
Conditional WASM Usage
Use WASM when available, fallback to JS:Batch Processing with WASM
Process multiple authorizations efficiently:Mixed Operations
Combine WASM and JS operations:Performance Monitoring
Compare WASM vs JS performance:Error Handling
WASM Errors
WASM functions throw JavaScript errors:Error Compatibility
WASM errors match JavaScript error messages:WASM Loading
Automatic Loading
WASM module loads automatically:Manual Loading
Load WASM explicitly if needed:Browser Compatibility
WASM Support
Modern browsers support WASM:- Chrome 57+
- Firefox 52+
- Safari 11+
- Edge 16+
Feature Detection
Check WASM availability:Testing
Test WASM Functions
Test JS/WASM Equivalence
Verify WASM produces same results as JS:Optimization Tips
- Batch operations - Process multiple auths in sequence
- Reuse WASM module - Module loaded once
- Profile first - Measure before optimizing
- Consider overhead - WASM call overhead may exceed benefit for simple operations
See Also
- Validation - JavaScript validation
- Signing - JavaScript signing
- Processing - JavaScript processing
- Performance - Performance comparison

