Skip to content

Commit 8959d27

Browse files
committed
ipns: document V1 and V2 signatures
We have to document legacy signature, because it is the only reason for copying 'data' fields into the main protobuf. Added section about backward compatibility so our approach is more clear.
1 parent 3c907b0 commit 8959d27

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

IPNS.md

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ IPNS records provide cryptographically verifiable, mutable pointers to objects.
2525
- [IPNS Record](#ipns-record)
2626
- [Record Serialization Format](#record-serialization-format)
2727
- [Record Size Limit](#record-size-limit)
28+
- [Backward Compatibility](#backward-compatibility)
2829
- [Protocol](#protocol)
2930
- [Overview](#overview)
3031
- [Record Creation](#record-creation)
@@ -175,7 +176,7 @@ message IpnsEntry {
175176
// deserialized copy of data[value]
176177
optional bytes value = 1;
177178
178-
// unused legacy field, use 'signatureV2' instead
179+
// legacy field, verify 'signatureV2' instead
179180
optional bytes signatureV1 = 2;
180181
181182
// deserialized copies of data[validityType] and data[validity]
@@ -216,6 +217,16 @@ Records over the limit MAY be ignored. Handling records larger than the
216217
limit is not recommended so as to keep compatibility with implementations and
217218
transports that follow this specification.
218219

220+
### Backward Compatibility
221+
222+
Implementations that want to interop with the public IPFS swarm MUST maintain
223+
backward compatibility. This means changes made to `IpnsEntry` protobuf or
224+
validation logic should always be additive.
225+
226+
Future changes to this spec should include design decisions that allow legacy
227+
nodes to gracefully ignore new fields and verify compatible records using
228+
legacy logic.
229+
219230
## Protocol
220231

221232
### Overview
@@ -243,8 +254,7 @@ Finally, the network nodes may also republish their records, so that the records
243254

244255
### Record Creation
245256

246-
IPNS record MUST be serialized as `IpnsEntry` protobuf and `IpfsEntry.data` MUST be signed using the private key.
247-
257+
IPNS record MUST be serialized as `IpnsEntry` protobuf, and `IpfsEntry.data` MUST be signed using the private key.
248258
Creating a new IPNS record MUST follow the below steps:
249259

250260
1. Create `IpnsEntry` and set `value`, `validity`, `validityType`, `sequence`, and `ttl`
@@ -256,9 +266,13 @@ Creating a new IPNS record MUST follow the below steps:
256266
- The order of fields impacts signature verification. If you are using an alternative CBOR implementation, make sure the CBOR field order follows [RFC7049](https://www.rfc-editor.org/rfc/rfc7049) sorting rules: length and then bytewise. The order of fields impacts signature verification.
257267
4. If your public key can't be inlined inside the IPNS Name, include a serialized copy in `IpnsEntry.pubKey`
258268
- This step SHOULD be skipped for Ed25519, and any other key types that are inlined inside of [IPNS Name](#ipns-name) itself.
259-
6. Create bytes for signing by concatenating `ipns-signature:` prefix (bytes in hex: `69706e732d7369676e61747572653a`) with raw CBOR bytes from `IpnsEntry.data`
260-
7. Sign concatenated bytes from the previous step using the private key, and store the signature in `IpnsEntry.signatureV2`
261-
8. Confirm that the serialized `IpnsEntry` bytes sum to less than or equal to [the size limit](#record-size-limit).
269+
5. Create `IpnsEntry.signatureV2`
270+
- Create bytes for signing by concatenating `ipns-signature:` prefix (bytes in hex: `69706e732d7369676e61747572653a`) with raw CBOR bytes from `IpnsEntry.data`
271+
- Sign concatenated bytes from the previous step using the private key, and store the signature in `IpnsEntry.signatureV2`
272+
6. Create `IpnsEntry.signatureV1` (backward compatibility, for legacy software)
273+
- Create bytes for signing by concatenating `IpnsEntry.value` + `IpnsEntry.validity` + `string(IpnsEntry.validityType)`
274+
- Sign concatenated bytes from the previous step using the private key, and store the legacy signature in `IpnsEntry.signatureV1`
275+
7. Confirm that the serialized `IpnsEntry` bytes sum to less than or equal to [the size limit](#record-size-limit).
262276

263277
### Record Verification
264278

0 commit comments

Comments
 (0)