@eduarte/cmc
v0.1.2
Published
Browser-side decryption package for encrypted SOG Gaussian model files stored in R2.
Downloads
459
Readme
Model Crypto (Go WASM)
Browser-side decryption package for encrypted SOG Gaussian model files stored in R2.
Build
cd wasm/model-crypto
./scripts/build.sh "your-arbitrary-key-string" "citizenshub.app,localhost"- 1st arg: key material (arbitrary string /
hex:/base64:) - 2nd arg (optional): allowed hostnames for origin check, comma-separated (default:
citizenshub.app) - Env key fallback:
MODEL_CRYPTO_BUILD_KEY,CCU_HISTORY_BUILD_KEY,CCU_HISTORY_ENCRYPTION_KEY - Env host fallback:
MODEL_CRYPTO_ALLOWED_HOSTS,CCU_HISTORY_ALLOWED_HOSTS,CCU_HISTORY_ALLOWED_HOST
The build script will:
- derive a 16-byte key with
SHA-256using the same rule as the Worker backend andccu-history-crypto - compile
src/main.gotopkg/cmc.wasm - copy Go runtime loader to
pkg/wasm_exec.js
Usage
import { fetchModelBytes } from '@eduarte/cmc';
import wasmUrl from '@eduarte/cmc/cmc.wasm?url';
import wasmExecUrl from '@eduarte/cmc/wasm_exec.js?url';
const fileBytes = await fetchModelBytes(modelUrl, {
encrypted: true,
algorithm: 'xtea-ctr-v1',
nonce: model.encryptionNonce,
wasmUrl,
wasmExecUrl
});Pass fileBytes into Spark's SplatMesh({ fileBytes, fileName }).
Behavior
- Uses the same XTEA-CTR implementation, static nonce convention, key derivation, and Go WASM hostname check as
ccu-history-crypto. - Intended for binary payloads, not JSON envelopes.
- SOG uploads are encrypted on the Worker before being stored in R2. R2 custom metadata carries
encrypted,algorithm,nonce, and original content details.
