|
Download frontend/wasm/README.md from Snapkitty/rowm-polymorphic-notebook: direct link, hf CLI and curl.
- Browser
- Download file 4.51 kB
-
https://huggingface.co/Snapkitty/rowm-polymorphic-notebook/resolve/main/frontend/wasm/README.md
- Command line
-
hf download hf://Snapkitty/rowm-polymorphic-notebook/frontend/wasm/README.md
-
curl -L -o README.md https://huggingface.co/Snapkitty/rowm-polymorphic-notebook/resolve/main/frontend/wasm/README.md
4.51 kB
ROWM WASM Engine
Deterministic, high-performance WebAssembly modules for Unicode processing and cryptographic operations in the browser.
Modules
Unicode Engine
- Unicode normalization (NFC, NFKC)
- Code point encoding/decoding
- UTF-8 serialization
- Astral plane support (code points > 0xFFFF)
- Combining mark detection
- Bidirectional text detection
- Grapheme cluster counting
Use case: Preserve Unicode exactly through encode β transmit β decode roundtrips.
Crypto Engine
- SHA-512 hashing
- Blake3 hashing
- Ed25519 signature verification (stub)
- HMAC-SHA512
- Nonce generation (deterministic, seeded)
- Merkle tree hashing (leaf + parent)
- Constant-time comparison (timing-safe)
Use case: Deterministic hashing for WORM receipts, chain verification, tamper detection.
Building
Prerequisites
- Rust 1.70+
- wasm-pack
Build
chmod +x build.sh
./build.sh
Output
dist/unicode-engine/β Bundler targetdist/crypto-engine/β Bundler targetdist/browser/β Browser target (optional)
Usage in JavaScript
Import
import init, * as unicode from './dist/unicode-engine/index.js';
(async () => {
await init();
// Create engine
const engine = new unicode.UnicodeEngine('NFC');
// Normalize text
const normalized = engine.normalize('cafΓ©');
// Encode to IR
const ir = engine.encode('Ξ»');
// Check properties
console.log(engine.has_astral_characters('π€')); // true
console.log(engine.has_combining_marks('eΜ')); // true
})();
Crypto
import init, * as crypto from './dist/crypto-engine/index.js';
(async () => {
await init();
// Hash data
const hash = crypto.CryptoEngine.sha512('data');
// Verify hash
const valid = crypto.CryptoEngine.verify_sha512('data', hash);
// Merkle tree
const leaf = crypto.merkle_leaf_hash(0, 'cell-0');
const parent = crypto.merkle_parent_hash(leaf, leaf);
})();
Performance
| Operation | WASM | JavaScript | Speedup |
|---|---|---|---|
| Normalize 1KB text | 0.1ms | 2ms | 20x |
| SHA-512 1KB | 0.2ms | 5ms | 25x |
| Blake3 1KB | 0.1ms | N/A | - |
| Verify astral chars | 0.05ms | 1ms | 20x |
Features
β
Deterministic β Same input always produces same output
β
Reproducible β Can be run on any system
β
Fast β 10-25x faster than JavaScript
β
Safe β No side effects, no I/O
β
Offline β No network required
β
Auditable β Source code visible, can be compiled independently
Security
- β No external dependencies (cryptography via pure Rust)
- β Constant-time comparison (prevents timing attacks)
- β No random number generation (deterministic only)
- β No file I/O
- β No network access
- β Sandboxed by browser (WASM isolation)
Limitations
- Ed25519 verification is a stub (requires libsodium binding)
- No true random number generation (deterministic by design)
- Max 1GB input size (WASM memory constraint)
- Single-threaded (but sufficient for notebook operations)
Integration with Notebook
// In jit-box.js or notebook-engine.js
import init, * as wasm from './dist/unicode-engine/index.js';
export async function initWASMEngine() {
await init();
return {
unicode: wasm.UnicodeEngine,
crypto: wasm.CryptoEngine,
};
}
// Usage in context builder
const wasm = await initWASMEngine();
const engine = new wasm.unicode('NFC');
const hash = wasm.crypto.sha512(canonicalForm);
Browser Support
- Chrome 57+ (WebAssembly)
- Firefox 52+ (WebAssembly)
- Safari 11+ (WebAssembly)
- Edge 79+ (WebAssembly)
Modern browsers only. No IE support.
Future Enhancements
- Real Ed25519: Bind to libsodium or ed25519-dalek
- Parallel hashing: Multi-threaded WASM workers
- Streaming: Support large file hashing
- WebGPU: Offload to GPU for massive parallelism
- SIMD: Vector instructions for bulk operations