> For the complete documentation index, see [llms.txt](https://rc.sunbird.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rc.sunbird.org/use/connectors/openid-for-verifiable-credentials-oid4vci.md).

# OpenID for Verifiable Credentials (OID4VCI)

`oid4vc-service` is a protocol façade: it speaks OpenID4VCI 1.0 (issuance) and OpenID4VP 1.0/draft-23 (presentation) on the wallet-facing side, and delegates everything else internally.

```mermaid
flowchart LR
    Wallet -->|OpenID4VCI / OpenID4VP| OID4VC[oid4vc-service]
    OID4VC -->|issue / verify| Creds[credentials-service]
    OID4VC -->|oid4vci-configs| Schema[credential-schema]
    Creds -->|signing| Identity[identity-service]
    Identity --> Vault[(Vault)]
```

| Service               | Endpoints used                              | Role                                                   |
| --------------------- | ------------------------------------------- | ------------------------------------------------------ |
| `credentials-service` | `/credentials/issue`, `/credentials/verify` | Builds and signs the VC, stores it; keys stay in Vault |
| `credential-schema`   | `/credential-schema/oid4vci-configs`        | Drives the published issuer metadata                   |

{% hint style="info" %}
`oid4vc-service` itself holds no credential keys or storage — only its own short-lived session state and (optionally) its own OAuth/protocol signing key, delegated to `identity-service`.
{% endhint %}

## Supported credential formats

Chosen per credential type via `oid4vciConfig.oid4vciFormats`:

| Format     | Selective disclosure | Notes                              |
| ---------- | -------------------- | ---------------------------------- |
| JWT VC     | No                   | Signed by identity-service         |
| SD-JWT VC  | Yes                  | Via `_sd` digests                  |
| `mso_mdoc` | Per-element          | ES256 COSE\_Sign1, ISO/IEC 18013-5 |

Credentials can also carry a W3C VC Render Method entry (inline SVG or a hosted URL) for wallet-side visual rendering.

## Issuance flow

{% stepper %}
{% step %}

### Discovery

`GET /.well-known/openid-credential-issuer` — `oid4vc-service` looks up opted-in schemas live from `credential-schema` and returns one `credential_configurations_supported` entry per `<schemaId>_<format>` combination.
{% endstep %}

{% step %}

### Offer creation (issuer-side)

`POST /oid4vc/offer` with `{credential_configuration_id, format, claims}`, returns `{offer_id, credential_offer_uri, credential_offer, qr_data}`.
{% endstep %}

{% step %}

### Wallet dereferences the offer

`GET /oid4vc/offer/:id` returns the `credential_offer`, including a `pre-authorized_code` grant.
{% endstep %}

{% step %}

### Token exchange

`POST /oid4vc/token` with the single-use pre-authorized code (a replay returns `400 invalid_grant`), returns a short-lived access token plus a single-use `c_nonce`.
{% endstep %}

{% step %}

### Credential issuance

The wallet presents a proof-of-possession (bound via `kid`, or an inline JWK/`did:jwk`); `oid4vc-service` verifies it, delegates to `credentials-service` (which delegates signing to `identity-service`), and returns the signed credential.
{% endstep %}
{% endstepper %}

## Presentation flow

{% stepper %}
{% step %}

### Request

Verification requests default to a signed JAR (`client_id` is a `did:...`); unsigned and legacy pre-draft-22 modes are available — see [Wallet Integration](broken://pages/CMaqpL3FZl00iepOjCGx) → Wallet compatibility flags.
{% endstep %}

{% step %}

### Response

The wallet posts to `/vp/response` (`direct_post`) with its `vp_token`.
{% endstep %}

{% step %}

### Verification chain

`oid4vc-service` checks, in order: holder/device signature, nonce/session-transcript freshness, each embedded credential's signature and revocation status, holder binding, and finally DCQL satisfaction against the disclosed claims.
{% endstep %}

{% step %}

### Status

`GET /vp/status/:id` reports whether the presentation verified.
{% endstep %}
{% endstepper %}

For the complete config reference, see `services/oid4vc-service/README.md` §4 in the `sunbird-rc-core` repo.

## Getting started

```bash
docker compose up -d db vault redis
bash enable-v2.sh   # inits vault, brings up identity/credential-schema/credential
docker compose --profile oid4vc up -d --build oid4vc-service
curl -s http://localhost:3400/health
```

For the full local deployment walkthrough (including Apple Silicon build notes), manual testing guide, and production hardening checklist, see `services/oid4vc-service/README.md` §5–§8.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://rc.sunbird.org/use/connectors/openid-for-verifiable-credentials-oid4vci.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
