stwo-cairo
v1.1.1
Published
A Typescript library for stwo-cairo using WASM64
Readme
S-two Cairo TS

This is a Typescript library compatible with cairo-prove. It targets modern browsers supporting the Memory64 WebAssembly feature.
Installation
npm i stwo-cairoServer settings
All responses from your app must send these headers to satisfy the browser security requirements for SharedArrayBuffer:
Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Opener-Policy: same-originUsage
Executing and generating a proof of execution for a compiled Cairo program:
import { init, execute, containsPedersenBuiltin, prove } from "stwo-cairo";
init(); // optional: call this on page load
const executable = "..."; // Cairo executable JSON string
const args = [1n, 2n]; // arguments for the program
const prover_input = await execute(executable, ...args); // the execution trace
const with_pedersen = containsPedersenBuiltin(prover_input); // for the verifier
const proof = await prove(prover_input); // the generated Cairo proofVerifying a proof:
import { verify } from "stwo-cairo";
const verdict = await verify(proof, with_pedersen); // whether the proof is validDevelopment
Build the rust Wasm package
Make sure you have rust installed on your computer and run:
pnpm run build:wasmRun tests
pnpm run test:browser