@maatara/protocol-wasm
v0.2.1
Published
A minimal TypeScript wrapper for the Ma'atara protocol WebAssembly exports. It initializes the wasm-bindgen module and exposes typed helpers for deterministic canonicalization, preimage builders, royalty validation, and PQC verification.
Readme
@maatara/protocol-wasm
A minimal TypeScript wrapper for the Ma'atara protocol WebAssembly exports. It initializes the wasm-bindgen module and exposes typed helpers for deterministic canonicalization, preimage builders, royalty validation, and PQC verification.
Usage (Cloudflare Workers)
- Ensure the Worker bundles the wasm-bindgen glue and
.wasmasset. For esbuild:
- Configure loader:
--loader:.wasm=copy - Import the generated glue and wasm URL in your Worker (or use this package to initialize by URL)
- Initialize and use
import { createProtocolWasm } from '@maatara/protocol-wasm';
const protocol = createProtocolWasm();
await protocol.init('/wasm/maatara_wasm_bg.wasm');
const { canonical, msgB64u } = protocol.buildPolicyPreimage({
version: 'v1', threshold: 2,
signers: [{ id: 'alice', publicKeyB64u: '...' }, { id: 'bob', publicKeyB64u: '...' }]
});
const ok = protocol.validateRoyalty('0x1234...abcd', 500);API
init(wasmUrl: string): load the wasm-bindgen module with the given URL- Deterministic:
jcsCanonicalize(json)buildPolicyPreimage(policy)buildMintPreimage(header, asset)buildTransferPreimage(header)buildAnchorPreimage(userId, rootHex, epoch, chains)
- Validation:
validateRoyalty(receiver, bps)verifyAttestations(msgB64u, attestations, allowed?)
- PQC:
pqc.keygen()/pqc.sign(msgB64u, secret)/pqc.verify(msgB64u, sigB64u, pub)
Notes
- This wrapper assumes your runtime can fetch the glue JS using the same path as the
.wasmwith_bg.wasmsuffix replaced by.js. - For bundlers that rename files, pass the resolved URL for the wasm file.
