Skip to content

Commit fddaa93

Browse files
committed
ipip: ipns signed records response format
1 parent 21bbab6 commit fddaa93

File tree

3 files changed

+97
-3
lines changed

3 files changed

+97
-3
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# IPIP 0351: IPNS Signed Records Response Format on HTTP Gateways
2+
3+
- Start Date: 2022-11-29
4+
- Related Issues:
5+
- [ipfs/specs/issues/320](https://github.com/ipfs/specs/issues/320)
6+
- [ipfs/specs/pull/351](https://github.com/ipfs/specs/pull/351)
7+
- [ipfs/kubo/pull/9399](https://github.com/ipfs/kubo/pull/9399)
8+
9+
## Summary
10+
11+
Add IPNS Signed Records response format to the [HTTP Gateway](https://specs.ipfs.tech/http-gateways/).
12+
13+
## Motivation
14+
15+
Currently, the gateway allows for trustless retrieval of data under the `/ipfs`
16+
namespace, bu fetching the data as a CAR, or Block, and then verifying it locally.
17+
This is especially important for light IPFS clients, so that they can retrieve
18+
data from other gateways without delegating any of the trust to them. Unfortunately,
19+
this is not possible under the `/ipns` namespace.
20+
21+
In contrary to DNSLink, IPNS provides cryptographically-verifiable records that
22+
can be verified by the client. This means that, if a gateway is able to provide
23+
the IPNS signed record to an HTTP client, trustless retrieval would also be available
24+
under the `/ipns` namespace.
25+
26+
In this IPIP, we propose adding [IPNS signed records][ipld-record] as a response
27+
format to the gateway under the `/ipns` namespace, allowing for trustless
28+
retrieval of IPNS records.
29+
30+
## Detailed design
31+
32+
The solution is to allow the Gateway to provide an IPNS signed record by
33+
requesting it using either the `Accept` HTTP header or the `format` URL query.
34+
35+
## Test fixtures
36+
37+
IPNS records for testing can be generated in Kubo by creating an IPNS record:
38+
39+
```bash
40+
$ ipfs key gen <key-name>
41+
k51Key
42+
43+
$ ipfs name publish /ipfs/bafyHash --key=<key-name> --ttl=<record-ttl>
44+
Published to k51Key: /ipfs/bafyHash
45+
46+
$ ipfs routing get /ipns/k51Key > key.pb
47+
```
48+
49+
## Design rationale
50+
51+
The current gateway already supports different response formats via the
52+
`Accept` HTTP header and the `format` URL query. This IPIP proposes adding
53+
one more supported format to that list.
54+
55+
### User benefit
56+
57+
By providing IPNS records through the gateway, IPFS light clients are able
58+
to race multiple gateways in search for an IPNS record for a certain IPNS key.
59+
This way, IPFS light clients do not necessarily need to implement the required
60+
machinery to fetch IPNS records from other IPFS nodes through the DHT or PubSub.
61+
62+
In addition, the retrieval of IPNS records is trustless in the sense that they can
63+
be verified by the client since the IPNS record includes a cryptographic signature
64+
provided by its creator.
65+
66+
### Compatibility
67+
68+
This IPIP proposes a new format to be added to the gateway, but does not change
69+
any prior format. Therefore, this IPIP is backwards compatible. Please note
70+
that IPNS records are also added to the [Trustless Gateway](https://specs.ipfs.tech/http-gateways/trustless-gateway/)
71+
specification.
72+
73+
### Copyright
74+
75+
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).
76+
77+
[ipld-record]: ../ipns/IPNS.md#ipns-record

src/http-gateways/path-gateway.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
maturity: reliable
3-
date: 2023-02-27
3+
date: 2023-03-30
44
editors:
55
- name: Marcin Rataj
66
github: lidel
@@ -132,6 +132,7 @@ For example:
132132
- [application/vnd.ipld.dag-cbor](https://www.iana.org/assignments/media-types/application/vnd.ipld.dag-cbor) – requests [IPLD Data Model](https://ipld.io/docs/data-model/) representation serialized into [DAG-CBOR format](https://ipld.io/docs/codecs/known/dag-cbor/). If the requested CID already has `dag-cbor` (0x71) codec, data is validated as DAG-CBOR before being returned as-is. Invalid DAG-CBON produces HTTP Error 500.
133133
- [application/json](https://www.iana.org/assignments/media-types/application/json) – same as `application/vnd.ipld.dag-json`, unless the CID's codec already is `json` (0x0200). Then, the raw JSON block can be returned as-is without any conversion.
134134
- [application/cbor](https://www.iana.org/assignments/media-types/application/cbor) – same as `application/vnd.ipld.dag-cbor`, unless the CID's codec already is `cbor` (0x51). Then, the raw CBOR block can be returned as-is without any conversion.
135+
- [application/vnd.ipfs.ipns-record](https://www.iana.org/assignments/media-types/application/vnd.ipfs.ipns-record) – requests a verifiable [IPNS Record](../ipns/IPNS.md#ipns-record) to be returned. Produces 400 Bad Request if the content is not under the IPNS namespace, or contains a path.
135136

136137
### `Range` (request header)
137138

@@ -196,14 +197,16 @@ parameter, if present)
196197

197198
Optional, `format=<format>` can be used to request specific response format.
198199

199-
This is a URL-friendly alternative to sending an [`Accept`](#accept-request-header) header. These are the equivalents:
200+
This is a URL-friendly alternative to sending an [`Accept`](#accept-request-header) header.
201+
These are the equivalents:
200202
- `format=raw``Accept: application/vnd.ipld.raw`
201203
- `format=car``Accept: application/vnd.ipld.car`
202204
- `format=tar``Accept: application/x-tar`
203205
- `format=dag-json``Accept: application/vnd.ipld.dag-json`
204206
- `format=dag-cbor``Accept: application/vnd.ipld.dag-cbor`
205207
- `format=json``Accept: application/json`
206208
- `format=cbor``Accept: application/cbor`
209+
- `format=ipns-record``Accept: application/vnd.ipfs.ipns-record`
207210

208211
<!-- TODO Planned: https://github.com/ipfs/go-ipfs/issues/8769
209212
- `selector=<cid>` can be used for passing a CID with [IPLD selector](https://ipld.io/specs/selectors)
@@ -570,6 +573,8 @@ The following response types require an explicit opt-in, can only be requested w
570573
- Arbitrary DAG as a verifiable CAR file or a stream, see [application/vnd.ipld.car](https://www.iana.org/assignments/media-types/application/vnd.ipld.car).
571574
- TAR (`?format=tar`)
572575
- Deserialized UnixFS files and directories as a TAR file or a stream, see [IPIP-288](https://github.com/ipfs/specs/pull/288)
576+
- IPNS Record
577+
- Protobuf bytes representing a verifiable [IPNS Record](../ipns/IPNS.md#record-serialization-format) (multicodec `0x0300`)
573578

574579
# Appendix: notes for implementers
575580

src/http-gateways/trustless-gateway.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
---
22
maturity: reliable
3-
date: 2022-11-09
3+
date: 2023-03-30
44
editors:
55
- name: Marcin Rataj
66
github: lidel
7+
- name: Henrique Dias
8+
github: hacdias
9+
url: https://hacdias.com/
710
---
811

912
# Trustless Gateway Specification
@@ -30,6 +33,14 @@ Downloads data at specified CID.
3033

3134
Same as GET, but does not return any payload.
3235

36+
## `GET /ipns/{key}[?{params}]`
37+
38+
Downloads data at specified IPNS Key. Verifiable :cite[ipns-record] can be requested via `?format=ipns-record`
39+
40+
## `HEAD /ipns/{key}[?{params}]`
41+
42+
same as GET, but does not return any payload.
43+
3344
# HTTP Request
3445

3546
Same as in :cite[path-gateway], but with limited number of supported response types.
@@ -47,6 +58,7 @@ Below response types MUST to be supported:
4758

4859
- [application/vnd.ipld.raw](https://www.iana.org/assignments/media-types/application/vnd.ipld.raw) – requests a single, verifiable raw block to be returned
4960
- [application/vnd.ipld.car](https://www.iana.org/assignments/media-types/application/vnd.ipld.car) – disables IPLD/IPFS deserialization, requests a verifiable CAR stream to be returned
61+
- [application/vnd.ipfs.ipns-record](https://www.iana.org/assignments/media-types/application/vnd.ipfs.ipns-record) – requests a verifiable :cite[ipns-record] (multicodec `0x0300`).
5062

5163
# HTTP Response
5264

0 commit comments

Comments
 (0)