forked from tung-lee/contextMeM
-
Notifications
You must be signed in to change notification settings - Fork 0
Spike: run @mysten/seal encrypt+decrypt inside a Cloudflare Worker #5
Copy link
Copy link
Open
Labels
P0Demo-blocking: required for a working Sui Overflow demoDemo-blocking: required for a working Sui Overflow demoharborHarbor encrypted Walrus storage on Sui (Space/Bucket/File)Harbor encrypted Walrus storage on Sui (Space/Bucket/File)seal@mysten/seal client-side encryption + on-chain access control@mysten/seal client-side encryption + on-chain access controlspikeTime-boxed throwaway investigation to de-risk a decisionTime-boxed throwaway investigation to de-risk a decision
Milestone
Description
Metadata
Metadata
Assignees
Labels
P0Demo-blocking: required for a working Sui Overflow demoDemo-blocking: required for a working Sui Overflow demoharborHarbor encrypted Walrus storage on Sui (Space/Bucket/File)Harbor encrypted Walrus storage on Sui (Space/Bucket/File)seal@mysten/seal client-side encryption + on-chain access control@mysten/seal client-side encryption + on-chain access controlspikeTime-boxed throwaway investigation to de-risk a decisionTime-boxed throwaway investigation to de-risk a decision
Context
The Harbor HTTP API is plain
fetch+ multipart and is Worker-friendly, but@mysten/sealleans on WebCrypto +@noblecurves + CPU-intensive BLS12-381. The Worker runs withcompatibility_flags: ["nodejs_compat"]andcompatibility_date: 2026-05-21(apps/api/cloudflare/wrangler.jsonc:17), and@mysten/sui^2.9.1is already a dependency ofapps/api(apps/api/package.json). Whether SEAL fits the Worker's compressed-bundle cap and CPU limit is the single highest-risk unknown gating the entire private-memory workstream (roadmap "The key runtime unknown (must spike early)" + §1 spike row).Goal / user story
As an engineer, I want a throwaway Worker that imports
@mysten/seal, encrypts one blob and decrypts it back, so we can decide WHERE encryption runs (Worker vs queue consumer vs Node CLI/MCP) before investing inHarborClient/seal.ts.Acceptance criteria
apps/apitest entry) imports@mysten/seal+@mysten/sui/keypairs/ed25519, and encrypts a small (<10KB)Uint8Arrayagainst a Seal policy id on Sui testnet, returning ciphertext.SessionKey+seal_approvePTB and decrypts the ciphertext back to the original bytes (round-trip asserted byte-equal).wrangler deploy --dry-run(or a real deploy) reports the compressed bundle size, recorded against the Workers size cap; CPU ms for one encrypt+decrypt is noted.Implementation notes
@mysten/sealto a scratch package orapps/api(do NOT keep it in the prod bundle if the spike fails).@mysten/suiis already present.seal_policy_idon Sui testnet — create one via Harbor (a bucket create yields a Seal policy) or reuse theseal-docs.wal.appexample policy; the demo sample target already points there (CONTEXTMEM_DEMO_SAMPLE_TARGETinwrangler.jsonc).SessionKeyrequires an Ed25519 signer:decodeSuiPrivateKey(suiprivkey1...)→Ed25519Keypair. UseSuiGrpcClient(already used inpackages/walrus/src/proof.ts/history.ts/resolve.ts) for theseal_approvedevInspect.nodejs_compatpolyfills crypto, but BLS in@noble/curvesis CPU-heavy (Worker CPU limit ~30s paid, lower on free) and the compressed-bundle cap is small. This is throwaway — do not ship to prod. Keeptar-basedpackProofBundle(packages/walrus/src/storage.ts:231) out; it's Node-only regardless.Sui Overflow angle
This de-risks the whole Sui-native private-memory demo. The answer (edge-encrypt vs offload) determines the live-demo architecture: whether the hackathon judges see encryption happen in the same Worker that serves recall, or in a queue/Node tier.
Dependencies
None — do this first. Blocks the
HarborClientissue and the private SEAL encrypted remember/recall issue.Part of the ContextMEM roadmap (#4) • Sui Overflow build.