|
| 1 | +--- |
| 2 | +slug: /concepts/proofs |
| 3 | +sidebar_position: 5 |
| 4 | +--- |
| 5 | + |
| 6 | +# TLS Proofs |
| 7 | + |
| 8 | +TLS proofs provide cryptographic evidence that an API response came from a specific HTTPS endpoint. When enabled, |
| 9 | +Airnode attaches a proof to each response alongside the EIP-191 signature. The signature proves the airnode endorsed the |
| 10 | +data; the proof proves the data actually came from the upstream API over TLS. |
| 11 | + |
| 12 | +## Why TLS proofs |
| 13 | + |
| 14 | +Without a proof, you trust the airnode operator to faithfully relay the API response. The EIP-191 signature proves who |
| 15 | +signed the data, but not where the data came from. A malicious operator could fabricate responses. |
| 16 | + |
| 17 | +TLS proofs close this gap. An independent attestor participates in the TLS session (via MPC-TLS) and produces a |
| 18 | +cryptographic attestation that the response came from the claimed HTTPS endpoint. The attestor never sees the full |
| 19 | +plaintext -- it only verifies the TLS transcript and checks that the response matches specified patterns. |
| 20 | + |
| 21 | +## How it works |
| 22 | + |
| 23 | +1. Airnode calls the upstream API and receives the JSON response (the normal pipeline). |
| 24 | +2. Airnode sends a proof request to the proof gateway with the full URL, HTTP method, headers, and `responseMatches` |
| 25 | + patterns. |
| 26 | +3. The proof gateway coordinates with an attestor to re-fetch the URL via MPC-TLS. |
| 27 | +4. The attestor verifies the TLS session and checks that the response matches the `responseMatches` regex patterns. |
| 28 | +5. The attestor signs a claim attesting to the match, and the proof is returned to Airnode. |
| 29 | +6. Airnode attaches the proof to the response. |
| 30 | + |
| 31 | +## Configuration |
| 32 | + |
| 33 | +Enable proofs globally in `settings` and configure `responseMatches` on each endpoint that should have proofs: |
| 34 | + |
| 35 | +```yaml |
| 36 | +settings: |
| 37 | + proof: |
| 38 | + type: reclaim |
| 39 | + gatewayUrl: http://localhost:5177/v1/prove |
| 40 | + |
| 41 | +apis: |
| 42 | + - name: CoinGecko |
| 43 | + url: https://api.coingecko.com/api/v3 |
| 44 | + endpoints: |
| 45 | + - name: coinPrice |
| 46 | + path: /simple/price |
| 47 | + parameters: |
| 48 | + - name: ids |
| 49 | + in: query |
| 50 | + required: true |
| 51 | + - name: vs_currencies |
| 52 | + in: query |
| 53 | + default: usd |
| 54 | + encoding: |
| 55 | + type: int256 |
| 56 | + path: $.ethereum.usd |
| 57 | + times: '1e18' |
| 58 | + responseMatches: |
| 59 | + - type: regex |
| 60 | + value: '"usd":\s*(?<price>[\d.]+)' |
| 61 | +``` |
| 62 | +
|
| 63 | +The `gatewayUrl` must be the **full URL** to the proof endpoint. Airnode sends the request directly to this URL without |
| 64 | +appending any path. |
| 65 | + |
| 66 | +## `responseMatches` |
| 67 | + |
| 68 | +Each entry defines a regex pattern the attestor checks against the API response. The attestor only signs a claim if all |
| 69 | +patterns match. This ensures the proof covers specific data in the response, not just that some response was received. |
| 70 | + |
| 71 | +```yaml |
| 72 | +responseMatches: |
| 73 | + - type: regex |
| 74 | + value: '"usd":\s*(?<price>[\d.]+)' |
| 75 | +``` |
| 76 | + |
| 77 | +| Field | Type | Required | Description | |
| 78 | +| ------- | -------- | -------- | --------------------------------------- | |
| 79 | +| `type` | `string` | Yes | Must be `'regex'`. | |
| 80 | +| `value` | `string` | Yes | Regex pattern to match in the response. | |
| 81 | + |
| 82 | +Endpoints without `responseMatches` skip proof generation entirely, even when proof is enabled globally. |
| 83 | + |
| 84 | +## Response format |
| 85 | + |
| 86 | +When a proof is successfully generated, the response includes a `proof` field: |
| 87 | + |
| 88 | +```json |
| 89 | +{ |
| 90 | + "airnode": "0x...", |
| 91 | + "endpointId": "0x...", |
| 92 | + "timestamp": 1711234567, |
| 93 | + "data": "0x...", |
| 94 | + "signature": "0x...", |
| 95 | + "proof": { |
| 96 | + "claim": { |
| 97 | + "provider": "http", |
| 98 | + "parameters": "{...}", |
| 99 | + "context": "{...}", |
| 100 | + "owner": "0x...", |
| 101 | + "timestampS": 1711234567, |
| 102 | + "epoch": 1, |
| 103 | + "identifier": "0x..." |
| 104 | + }, |
| 105 | + "signatures": { |
| 106 | + "attestorAddress": "0x7ff8f768be3c32132d395e888e44a6299e532604", |
| 107 | + "claimSignature": "0x..." |
| 108 | + } |
| 109 | + } |
| 110 | +} |
| 111 | +``` |
| 112 | + |
| 113 | +The `proof.signatures.attestorAddress` identifies the attestor that generated the proof. The `claimSignature` is a |
| 114 | +signature over the claim data that can be verified independently. |
| 115 | + |
| 116 | +## Non-fatal behavior |
| 117 | + |
| 118 | +Proof generation is **non-fatal**. If the proof gateway is unavailable, times out, or returns an error: |
| 119 | + |
| 120 | +- The response is still returned without the `proof` field. |
| 121 | +- A `WARN` log is emitted with the failure reason. |
| 122 | +- The EIP-191 signature is unaffected. |
| 123 | + |
| 124 | +This ensures that proof infrastructure issues do not block data delivery. Consumers that require proofs should check for |
| 125 | +the presence of the `proof` field and reject responses without it. |
| 126 | + |
| 127 | +## URL construction |
| 128 | + |
| 129 | +Airnode builds the full URL for the proof request by resolving all endpoint parameters (path, query, defaults, fixed |
| 130 | +values) against the API base URL. This ensures the attestor fetches the exact same URL that Airnode called. For example, |
| 131 | +an endpoint at `/simple/price` with query parameters `ids=ethereum&vs_currencies=usd` produces: |
| 132 | + |
| 133 | +``` |
| 134 | +https://api.coingecko.com/api/v3/simple/price?ids=ethereum&vs_currencies=usd |
| 135 | +``` |
| 136 | + |
| 137 | +## Example config |
| 138 | + |
| 139 | +See [`examples/configs/reclaim-proof/`](https://github.com/api3dao/airnode-v2/tree/main/examples/configs/reclaim-proof) |
| 140 | +for a minimal working configuration with TLS proofs enabled. |
0 commit comments