Skip to main content

Errors

Every error thrown by the SDK extends OpenACError, which carries a stable code: ErrorCode plus a human-readable message. The runtime classes group codes by phase:

import {
OpenACError,
SetupError,
ProofError,
VerificationError,
InputError,
WasmError,
} from "openac-sdk";

try {
await openac.precompute(req);
} catch (err) {
if (err instanceof InputError && err.code === "INVALID_JWT") {
// ...recover or surface to the user
}
throw err;
}

Source: src/errors.ts. The ErrorCode union is exported from src/types.ts.

Code reference

CodeClassThrown whenRemediation
SETUP_FAILEDSetupErrorOpenAC.init failed to initialize the WASM bridge or witness calculator.Verify the WASM build artifacts exist and assetsDir resolves; re-run npm run build:wasm.
SETUP_NOT_SUPPORTEDWasmErrorA code path tried to invoke setup inside WASM. Setup is offline-only (Rust CLI).Use NativeBackend.setup or pre-generate keys.
KEYS_NOT_FOUNDSetupErrorNativeBackend could not locate the ecdsa-spartan2 binary or Cargo.toml.Pass an explicit binaryPath / workDir, or build with cargo build --release.
KEY_LOAD_FAILEDWasmErrorloadKeysFromUrl got a non-200 response, or NativeBackend.loadArtifact failed.Check the CDN URL and VcSize; verify network access and CORS.
PROOF_GENERATION_FAILEDProofErrorThe Spartan2 prover threw, or a CLI command exited non-zero. Includes cause.Re-run with RUST_LOG=debug (Native) or inspect the WASM console; usually indicates malformed inputs or a key/circuit mismatch.
WITNESS_GENERATION_FAILEDProofErrorThe Circom-generated witness calculator threw on the supplied inputs.Compare your inputs against tests/e2e.test.ts; typical causes are out-of-range claim values or wrong jwtParams.
REBLIND_FAILEDProofErrorThe present WASM call rejected the (instance, witness) pair before reblinding.Check that precomputed was generated by the same KeySet; do not mutate the witness between precompute and present.
VERIFICATION_FAILEDVerificationErrorVerifier returned valid = false for a non-format reason (signature, commitment, or predicate output mismatch).Inspect result.error; verify the verifier nonce was bound to the same Show witness.
INVALID_PROOF_FORMATVerificationErrorThe serialized proof could not be parsed (wrong length / version).Confirm both sides use the same SDK version; re-issue the bundle.
COMMITMENT_MISMATCHVerificationErrorThe linking commitment between Prepare and Show did not match.The proofs were not built from the same precomputation; regenerate Show from the cached PrecomputedCredential.
INVALID_JWTInputErrorThe compact JWT could not be parsed, the header is not ES256, or the issuer signature did not verify locally.Validate the JWT with an off-the-shelf SD-JWT parser; ensure issuerPublicKey matches the issuer.
INVALID_KEYInputErrorA JWK was passed without kty: "EC" and crv: "P-256", or the device key was malformed.Use a P-256 JWK; for PEM keys, wrap them as { pem: "..." }.
INVALID_SIGNATUREInputErrorbuildShowCircuitInputs could not verify the device-nonce signature against the device key in the credential.Make sure devicePrivateKey corresponds to the credential's cnf.jwk.
MISSING_DISCLOSUREInputErrorThe credential references an _sd digest with no matching disclosure.Include all disclosures the verifier expects; an SD-JWT issuer must publish disclosures together with the JWT.
BIRTHDAY_NOT_FOUNDInputErrorprecompute was given a credential without a birthdate / birthday disclosure and no explicit birthdayClaimIndex.Pass birthdayClaimIndex or include the disclosure.
CLAIM_NOT_FOUNDInputErrorA claimRef in a predicate points at an index outside the disclosed claims.Match claimRef to disclosures order; check Credential.disclosedClaims.
PARAMS_EXCEEDEDInputErrorInputs overflow JwtCircuitParams (e.g. JWT length > maxMessageLength) or ShowCircuitParams (e.g. more than maxPredicates).Choose a larger VcSize for JWTs; recompile Show with bigger parameters for more predicates / logic tokens.
WASM_LOAD_FAILEDWasmErrorThe bundled WASM module could not be imported.Pass wasmPath or wasmModule to OpenAC.init.
WASM_OOMWasmErrorThe WASM heap could not grow past memory.maximum.Raise memory.maximum in OpenACConfig; prefer the native backend for 2k+ keys.
WASM_NOT_INITIALIZEDWasmErrorA method was called before OpenAC.init finished.Always await OpenAC.init(...) before invoking proving/verification methods.

Patterns

Distinguish user-recoverable from fatal errors. InputError codes (INVALID_JWT, INVALID_KEY, INVALID_SIGNATURE, MISSING_DISCLOSURE, BIRTHDAY_NOT_FOUND, CLAIM_NOT_FOUND, PARAMS_EXCEEDED) typically mean the caller passed bad data and the wallet should prompt the user. WasmError / SetupError mean the environment is mis-configured and retrying with the same inputs will not help.

Always log the cause. ProofError instances wrap the underlying CLI / WASM exception in error.cause. Surface it in debug logs but do not show it to end users — stack traces often leak filesystem paths.

VerificationResult.error mirrors codes. When OpenAC.verify returns valid: false, the human-readable error string includes the underlying code; verifiers can pattern-match on it for audit logs without throwing.