> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.adid.dev/llms.txt.
> For full documentation content, see https://docs.adid.dev/llms-full.txt.

# ZKP Generation

**Used in:** §3.3.3 Generating a Proof in the Browser
**Audience:** Holder, Backend Developer
**IA ID:** D7

```mermaid
flowchart TD
  A["Holder picks predicate (age_gte, country_in, range, set_membership, not_equal)"] --> B["POST /api/v1/zkp/challenge"]
  B --> C["API issues nonce (Redis TTL)"]
  C --> D["Build witness from credentialSubject + privateKey"]
  D --> E["Compile predicate to circuit input"]
  E --> F["Run prover (Airbender / snarkjs in browser or server)"]
  F --> G{"Predicate satisfied?"}
  G -- No --> GErr["422 PREDICATE_NOT_SATISFIED"]
  G -- Yes --> H["Aggregate proof bytes"]
  H --> I["POST /api/v1/zkp/proofs (proof, proverDid, credentialId)"]
  I --> J["DB: INSERT zk_proofs (status=generated)"]
  J --> K["Return proofId + proof bundle"]
```

**Reading guide:** The challenge has a TTL in Redis; if the holder takes too long to submit, the API returns `410 CHALLENGE_EXPIRED` (see `zkp.go:128`).

***