Skip to navigation

SDK — ZKP Operations

View as Markdown

Source: packages/sdk/src/zkp.ts.

SDK methodEndpoint
generateChallenge()POST /api/v1/zkp/challenge
generateZKProof(params)POST /api/v1/zkp/proofs
verifyZKProof(proof, proverDid)POST /api/v1/zkp/verify
getZKProof(proofId)GET /api/v1/zkp/proofs/{id}

Example: predicate proof

const challenge = await client.generateZKChallenge();
const { proof } = await client.generateZKProof({
credentialId: vc.id,
proverDid: 'did:adi:alice…',
privateKey: holderPrivateKeyB64Url,
credentialSubject: { age: 25, country: 'US' },
predicates: [
{ attributeName: 'age', type: 'gte', value: 18 },
{ attributeName: 'country', type: 'membership', memberSet: ['US','UK','EU'] },
],
challenge: challenge.challenge,
anchorOnChain: false,
});
const verification = await verifierClient.verifyZKProof(proof, 'did:adi:alice…');
console.log('All predicates satisfied?', verification.valid);

Important: The wallet uses this exact API on mobile (§8.4). When anchorOnChain: true, the response includes onChainHash — use it to fetch the on-chain ProofRecord from the ZKProofVerifier contract (§11.6).