# Public keys

The published keys that verify everything Provenance signs.

Related guide: [Verify a proof](https://provenanceauth.com/docs/integrate/verify-a-proof.md)

## Endpoints

- `GET /.well-known/jwks.json`: [Get the published keys](#get-well-known-jwks-json)
- `GET /.well-known/ap2/jwks.json`: [Get the AP2 issuer's keys](#get-well-known-ap2-jwks-json)

## The jwks object

### Attributes

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `keys` | array of objects | no | The keys. |
| `keys.kty` | string | no | The key type, `EC`. |
| `keys.crv` | string | no | The curve, `P-256`. |
| `keys.x` | string | no | The x-coordinate of the public key. |
| `keys.y` | string | no | The y-coordinate of the public key. |
| `keys.kid` | string | no | Key id (matches the token header `kid`). |
| `keys.use` | string | no | `sig`: the key signs. |
| `keys.alg` | string | no | The algorithm, `ES256`. |

### Example

```json
{
  "keys": [
    {
      "kty": "EC",
      "crv": "P-256",
      "x": "ZcUUGCBlqah-wZnUYcMZVlPRX4LzmUiacRPeXxU2eC0",
      "y": "BgopxKsogtnpwK7Ow8bM0ysJ71eT0Afz1m4J5HuS9dE",
      "kid": "f765a99ad0543d99",
      "use": "sig",
      "alg": "ES256"
    }
  ]
}
```

## Get the published keys

`GET /.well-known/jwks.json`

Returns the ES256 public keys that sign intent tokens, receipts, manifests and log checkpoints, so anyone can verify them offline. Served at the domain root, with no key. Cacheable for an hour.

Auth: none. No API key needed.

### Parameters

No parameters.

### Returns

The public signing keys. See [the jwks object](#object).

### Request

**curl**

```bash
curl "$PROVENANCE_API/.well-known/jwks.json"
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/.well-known/jwks.json`)).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
data = httpx.get(f"{api}/.well-known/jwks.json").json()
```

### Response 200

```json
{
  "keys": [
    {
      "kty": "EC",
      "crv": "P-256",
      "x": "ZcUUGCBlqah-wZnUYcMZVlPRX4LzmUiacRPeXxU2eC0",
      "y": "BgopxKsogtnpwK7Ow8bM0ysJ71eT0Afz1m4J5HuS9dE",
      "kid": "f765a99ad0543d99",
      "use": "sig",
      "alg": "ES256"
    }
  ]
}
```

## Get the AP2 issuer's keys

`GET /.well-known/ap2/jwks.json`

The ES256 public key that signs the AP2 mandates Provenance issues, separate from the intent keyset: list it as an AP2 issuer to trust those mandates and nothing else. No key needed; cacheable for an hour. A `kid` starting `sandbox-` was made at boot. `503` until the deployment turns the AP2 issuer on.

Auth: none. No API key needed.

### Parameters

No parameters.

### Returns

The AP2 issuer's public key. See [the jwks object](#object).

### Errors

- [`ap2_issuer_unconfigured`](https://provenanceauth.com/docs/platform/errors.md#ap2_issuer_unconfigured)

### Request

**curl**

```bash
export PROVENANCE_KEY=prv_test_full_K7mN3xQp9RbT2vWm8sYd4cFjLhXn6gAe
curl "$PROVENANCE_API/v1/.well-known/ap2/jwks.json" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/.well-known/ap2/jwks.json`, {
  headers: { Authorization: `Bearer ${process.env.PROVENANCE_KEY}` },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
data = httpx.get(f"{api}/v1/.well-known/ap2/jwks.json", headers={"Authorization": f"Bearer {os.environ['PROVENANCE_KEY']}"}).json()
```

### Response 200

```json
{
  "keys": [
    {
      "kty": "EC",
      "crv": "P-256",
      "x": "7MAQoKtKbW2cUuJwVb4wzDbX9o0x1ZqjGfL1s3R8nYc",
      "y": "i3OUjGXe0rQwP2l7mE4hYt6aS9kV1cN5dZ8bF3gJ2uA",
      "kid": "3c1f0a9b7d2e4f60",
      "use": "sig",
      "alg": "ES256"
    }
  ]
}
```
