|
| 1 | +--- |
| 2 | +title: "IPIP-0351: IPNS Signed Records Response Format on HTTP Gateways" |
| 3 | +date: 2022-11-29 |
| 4 | +ipip: ratified |
| 5 | +editors: |
| 6 | + - name: Henrique Dias |
| 7 | + github: hacdias |
| 8 | + url: https://hacdias.com/ |
| 9 | + - name: Marcin Rataj |
| 10 | + github: lidel |
| 11 | + url: https://lidel.org/ |
| 12 | +relatedIssues: |
| 13 | + - https://github.com/ipfs/specs/issues/320 |
| 14 | + - https://github.com/ipfs/specs/pull/351 |
| 15 | + - https://github.com/ipfs/kubo/pull/9399 |
| 16 | +order: 351 |
| 17 | +tags: ['ipips'] |
| 18 | +--- |
| 19 | + |
| 20 | +## Summary |
| 21 | + |
| 22 | +Add IPNS Signed Records response format to the [HTTP Gateway](/http-gateways/). |
| 23 | + |
| 24 | +## Motivation |
| 25 | + |
| 26 | +Currently, the gateway allows for trustless retrieval of data under the `/ipfs` |
| 27 | +namespace, but fetching the data as a CAR, or Block, and then verifying it locally. |
| 28 | +This is especially important for light IPFS clients, so that they can retrieve |
| 29 | +data from other gateways without delegating any of the trust to them. Unfortunately, |
| 30 | +this is not possible under the `/ipns` namespace. |
| 31 | + |
| 32 | +In contrary to DNSLink, IPNS provides cryptographically-verifiable records that |
| 33 | +can be verified by the client. This means that, if a gateway is able to provide |
| 34 | +the IPNS signed record to an HTTP client, trustless retrieval would also be available |
| 35 | +under the `/ipns` namespace. |
| 36 | + |
| 37 | +In this IPIP, we propose adding :cite[ipns-record] as a response |
| 38 | +format to the gateway under the `/ipns` namespace, allowing for trustless |
| 39 | +retrieval of IPNS records over HTTP as [application/vnd.ipfs.ipns-record](https://www.iana.org/assignments/media-types/application/vnd.ipfs.ipns-record) content type (multicodec `0x0300`). |
| 40 | + |
| 41 | +## Detailed design |
| 42 | + |
| 43 | +- :cite[trustless-gateway] can now provide a signed IPNS record upon request for `/ipns/{ipns-name}` path. |
| 44 | +- To request the IPNS record, use one of the following methods: |
| 45 | + - Include the `Accept: application/vnd.ipfs.ipns-record` HTTP header in the request. |
| 46 | + - Include the `format=ipns-record` query parameter in the request URL. |
| 47 | +- The HTTP response containing the verifiable IPNS record will have the following format: |
| 48 | + - Header: `Content-Type: application/vnd.ipfs.ipns-record` |
| 49 | + - Body: :cite[ipns-record] serialized as the `IpnsEntry` protobuf. |
| 50 | + |
| 51 | +## Test fixtures |
| 52 | + |
| 53 | +This IPIP got ratified before |
| 54 | +[gateway-conformance](https://github.com/ipfs/gateway-conformance) existed. |
| 55 | + |
| 56 | + |
| 57 | +The [reference implementation in Kubo 0.19](https://github.com/ipfs/kubo/blob/master/docs/changelogs/v0.19.md#signed-ipns-record-response-format) |
| 58 | +provides reusable [assertions](https://github.com/ipfs/kubo/blob/v0.19.2/test/sharness/t0124-gateway-ipns-record.sh). |
| 59 | + |
| 60 | +:::issue |
| 61 | +Until vendor-agnostic fixtures are added to the conformance test suite ([tracking issue](https://github.com/ipfs/gateway-conformance/issues/3)), |
| 62 | +IPNS records for testing can be generated in Kubo by creating an IPNS record: |
| 63 | + |
| 64 | +```bash |
| 65 | +$ ipfs key gen <key-name> |
| 66 | +k51Key |
| 67 | + |
| 68 | +$ ipfs name publish /ipfs/bafyHash --key=<key-name> --ttl=<record-ttl> |
| 69 | +Published to k51Key: /ipfs/bafyHash |
| 70 | + |
| 71 | +$ ipfs routing get /ipns/k51Key > key.pb |
| 72 | +``` |
| 73 | +::: |
| 74 | + |
| 75 | +## Design rationale |
| 76 | + |
| 77 | +The current gateway already supports different response formats via the |
| 78 | +`Accept` HTTP header and the `format` URL query. This IPIP proposes adding |
| 79 | +one more supported format to that list. |
| 80 | + |
| 81 | +### User benefit |
| 82 | + |
| 83 | +By providing IPNS records through the gateway, IPFS light clients are able |
| 84 | +to race multiple gateways in search for an IPNS record for a certain IPNS key. |
| 85 | +This way, IPFS light clients do not necessarily need to implement the required |
| 86 | +machinery to fetch IPNS records from other IPFS nodes through the DHT or PubSub. |
| 87 | + |
| 88 | +In addition, the retrieval of IPNS records is trustless in the sense that they can |
| 89 | +be verified by the client since the IPNS record includes a cryptographic signature |
| 90 | +provided by its creator. |
| 91 | + |
| 92 | +### Compatibility |
| 93 | + |
| 94 | +This IPIP proposes a new format to be added to the gateway, but does not change |
| 95 | +any prior format. Therefore, this IPIP is backwards compatible. Please note |
| 96 | +that IPNS records are also added to the :cite[trustless-gateway] specification. |
| 97 | + |
| 98 | +### Copyright |
| 99 | + |
| 100 | +Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). |
0 commit comments