Package Exports
- @clawdstrike/wasm
- @clawdstrike/wasm/hush_wasm.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@clawdstrike/wasm) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@backbay/wasm
WebAssembly bindings for clawdstrike cryptographic verification.
Installation
npm install @backbay/wasmUsage
Browser (ES Modules)
import init, {
verify_ed25519,
hash_sha256,
hash_keccak256,
verify_receipt,
verify_merkle_proof
} from '@backbay/wasm';
// Initialize WASM module (required once)
await init();
// Hash data
const hash = hash_sha256(new TextEncoder().encode('hello'));
console.log(hash); // 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
// Verify Ed25519 signature
const valid = verify_ed25519(publicKeyHex, messageBytes, signatureHex);
// Verify a signed receipt
const result = verify_receipt(receiptJson, signerPubkeyHex, null);
console.log(result.valid, result.signer_valid);Node.js
const { verify_ed25519, hash_sha256 } = require('@backbay/wasm');
const hash = hash_sha256(Buffer.from('hello'));API
Hashing
hash_sha256(data: Uint8Array): string- SHA-256 hash (hex, no prefix)hash_sha256_prefixed(data: Uint8Array): string- SHA-256 hash (hex, 0x prefix)hash_keccak256(data: Uint8Array): string- Keccak-256 hash (hex, 0x prefix)
Signatures
verify_ed25519(pubkey_hex: string, message: Uint8Array, sig_hex: string): boolean
Receipts
verify_receipt(receipt_json: string, signer_pubkey_hex: string, cosigner_pubkey_hex?: string): VerificationResulthash_receipt(receipt_json: string, algorithm: "sha256" | "keccak256"): stringget_canonical_json(receipt_json: string): string
Merkle Trees
verify_merkle_proof(leaf_hash_hex: string, proof_json: string, root_hex: string): booleancompute_merkle_root(leaf_hashes_json: string): stringgenerate_merkle_proof(leaf_hashes_json: string, leaf_index: number): string
Bundle Size
- Uncompressed: ~268KB
- Gzipped: ~90KB
The WASM binary is automatically loaded when you call init().
TypeScript
Full TypeScript definitions are included. The VerificationResult type:
interface VerificationResult {
valid: boolean;
signer_valid: boolean;
cosigner_valid: boolean | null;
errors: string[];
}License
MIT