Skip to main content
Version: 0.3.0

Custom prover storage

You only need this if you want to plug in your own storage (encrypted blobs, shared between apps, fetched from a server). Default behavior — files under the app's persistent dir — is correct for almost every app; skip this page if you haven't hit a concrete reason to override.

Override VK and SRS

Both knobs live on the prover config passed to createRuntime:

import { Paths } from 'expo-file-system'
import {
createRuntime,
EbProverNative,
getBundledCircuitBytecode,
} from '@cardinal-cryptography/sdk-react-native'
import type { ProofKind } from '@cardinal-cryptography/core'
import { MMKV } from 'react-native-mmkv'

const store = new MMKV()

const runtime = createRuntime({
prover: {
// Bring your own VK cache. Sync or async; the prover memoizes per-process
// automatically. Override the derivation path entirely (e.g. fetch from a
// server) if needed.
vkBase64For: async (kind) => {
const key = `eb:vk:${kind}`
const cached = store.getString(key)
if (cached) return cached
const vk = await EbProverNative.getNoirVerificationKey(
getBundledCircuitBytecode(kind),
null,
false,
)
store.set(key, vk)
return vk
},
// Resolve a real on-device path. Use the document dir (persistent,
// survives backup) or the cache dir (OS may purge under pressure).
// Set to `null` to opt out of caching entirely — native bb will
// download on every cold start without persisting.
srsPath: `${Paths.document.uri}/my-app/g1.dat`,
},
})

Wipe the native cache

Useful for debugging or after a circuit upgrade where you want to force re-derivation (though the bytecode-keyed cache files would naturally miss on bytecode change anyway):

await EbProverNative.clearCache()