@baerae/zkap-zkp
v0.1.7
Published
Compatibility facade for the zkap-zkp runtime SDK packages.
Readme
@baerae/zkap-zkp
Compatibility facade for the zkap-zkp runtime SDK packages. New applications should install exactly one runtime package:
- Node.js:
@baerae/zkap-zkp-node - Browser/WebAssembly:
@baerae/zkap-zkp-wasm - React Native:
@baerae/zkap-zkp-react-native
This facade keeps the historical import paths, but the runtime implementations
are optional peers. npm install @baerae/zkap-zkp alone is not enough to run
the SDK; install exactly one matching runtime package alongside it.
# Node.js
npm install @baerae/zkap-zkp @baerae/zkap-zkp-node
# Browser/WebAssembly
npm install @baerae/zkap-zkp @baerae/zkap-zkp-wasm
# React Native
npx expo install @baerae/zkap-zkp @baerae/zkap-zkp-react-nativeimport { generateHash, generateAnchor, initZkap } from '@baerae/zkap-zkp'
await initZkap() // optional no-op on Node/RN, preloads WASM in browsers
const hash = await generateHash(['0x1', '0x2'])
const anchor = await generateAnchor(config, secrets)The root API is Promise-based in every runtime. Internally this package resolves
to @baerae/zkap-zkp-node, @baerae/zkap-zkp-wasm, or
@baerae/zkap-zkp-react-native through package export conditions, but it does
not install all three runtimes for you. npm cannot reliably infer the target
runtime at install time, so applications choose the runtime package explicitly.
Runtime-specific imports
Use these only when you need to pin a runtime explicitly:
import { generateHash } from '@baerae/zkap-zkp/node'
import { initZkap } from '@baerae/zkap-zkp/wasm'
import { prove } from '@baerae/zkap-zkp/react-native'Node.js synchronous compatibility is available at:
import { generateHash } from '@baerae/zkap-zkp/node-sync'
const hash = generateHash(['0x1', '0x2'])Proving bundles
Large CRS/proving artifacts are not bundled in npm. Serve the zkap-circuit flat
release directory from HTTPS/S3-compatible static hosting and let the SDK create
the local manifestDir:
import {
downloadRelease,
loadCircuitConfig,
prove,
} from '@baerae/zkap-zkp'
const release = await downloadRelease({
baseUrl: 'https://static.example.com/zkap/releases/v0.1.5',
shape: '3-of-3',
expectedReleaseSha: '50aaaa8fe35fc261',
})
const config = await loadCircuitConfig(release.stagedDir)
const proof = await prove(config, {
...request,
manifestDir: release.stagedDir,
})React Native uses expo-file-system for this helper. Install it with
npx expo install expo-file-system if your app does not already include it.
downloadRelease and Node's loadRelease verify each artifact against the
release's <shape>-SHA256SUMS (and the optional expectedReleaseSha pin), but
they do not enforce any specific zkap-circuit revision. Ensure the release
bundle you serve was built from a circuit revision compatible with this SDK.
Platform notes
- Node.js supports hash helpers, release download/loading, proving, and verification.
- WebAssembly supports hash helpers only.
prove,prepareProver,downloadRelease,loadRelease,loadCircuitConfig, andverifythrowUnsupportedPlatformError. - React Native supports hash helpers,
downloadRelease,loadCircuitConfig, and on-device proving. Node-only helpers throwUnsupportedPlatformError. normalizeCircuitConfigis available in every runtime and converts releaseconfig.jsonsnake_case fields to the facade's camelCaseCircuitConfig.
