# JSON Web Key Set (JWKS)

The JSON Web Key Set (JWKS) endpoint provides the public keys that ID Check uses to sign ID tokens. Clients use these keys to verify the signature of the ID tokens that they receive from the token endpoint.

> **Preview**
>
> ID Check OIDC4IA is in preview, so it can change. For a stable integration, use [ID Check](https://docs.stoe.no/id-check.md).

## Endpoint

```
GET /jwks
```

## Response

The endpoint returns a JSON Web Key Set (JWKS) as defined in [RFC 7517](https://tools.ietf.org/html/rfc7517).

### Response headers

| Header          | Value                   |
| --------------- | ----------------------- |
| `Content-Type`  | `application/json`      |
| `Cache-Control` | `public, max-age=86400` |

### Response body

```json
{
  "keys": [
    {
      "kty": "EC",
      "use": "sig",
      "kid": "123456789",
      "crv": "P-256",
      "x": "base64url-encoded-x-coordinate",
      "y": "base64url-encoded-y-coordinate",
      "x5c": ["base64-encoded-cert", "..."]
    }
  ]
}
```

## Key properties

| Property | Description                                                                                                             |
| -------- | ----------------------------------------------------------------------------------------------------------------------- |
| `kty`    | Key type. ID Check uses `EC` (Elliptic Curve) for signing keys.                                                         |
| `use`    | Key usage. `sig` indicates that ID Check uses the key for signatures.                                                   |
| `kid`    | Key ID. The certificate serial number. Clients use it to match the key with the `kid` header in JSON Web Tokens (JWTs). |
| `crv`    | Curve name. ID Check uses `P-256` for ES256 signatures.                                                                 |
| `x`      | Base64url-encoded x-coordinate of the EC public key.                                                                    |
| `y`      | Base64url-encoded y-coordinate of the EC public key.                                                                    |
| `x5c`    | X.509 certificate chain. Contains the signing certificate and its issuing CA certificates.                              |

## Usage

When validating an ID token signature:

1. Decode the ID token header to get the `kid` (key ID)
2. Fetch the JWKS from this endpoint
3. Find the key with the matching `kid`
4. Use the public key to verify the signature

## Notes

- ID Check uses **ES256** (ECDSA with P-256 curve) for signing ID tokens
- The signing key is separate from the encryption key. ID Check encrypts each ID token with the RSA key in the client's JWKS that has `use` set to `enc`. See [Encryption key](https://docs.stoe.no/id-check/oidc4ia/getting-started/authentication.md#encryption-key)
- Always match keys by `kid`. Do not assume key order or count
