| title | Routing V1 HTTP Delegated Routing Reader Privacy Upgrade | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| description | This specification describes Delegated Routing Reader Privacy Upgrade. It's an incremental improvement to HTTP Delegated Routing API and inherits all of its formats and design rationale. | ||||||||||||||||||||
| date | 2023-05-31 | ||||||||||||||||||||
| maturity | reliable | ||||||||||||||||||||
| editors |
|
||||||||||||||||||||
| order | 0 | ||||||||||||||||||||
| tags |
|
This specification describes a new HTTP API for Privacy Preserving Delegated Content Routing provider lookups. It's an extension to HTTP Delegated Routing API and inherits all of its formats and design rationale.
All salts below are 64-bytes long, and represent a string padded with \x00.
SALT_DOUBLEHASH = bytes("CR_DOUBLEHASH\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")SALT_ENCRYPTIONKEY = bytes("CR_ENCRYPTIONKEY\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
Magic values are needed to calculate different digests from the same value for different purposes. For example a hash of a Multihash that is used for lookups should be different from the one that is used for
key derivation, even though both are calculated from the same original value. In order to do that the Multihash is concatenated with different magic values before applying the hash funciton - SALT_DOUBLEHASH
for lookups and SALT_ENCRYPTIONKEY for key derivation as described in the Glossary.
encis AESGCM encryption. The following notation will be used for the rest of the specificationenc(passphrase, nonce, payload).hashis SHA256 hashing.||is concatenation of two values.deriveKeyis deriving a 32-byte encryption key from a passphrase that is done ashash(SALT_ENCRYPTIONKEY || passphrase).CIDis the Content IDentifier.MHis the Multihash contained in aCID. It corresponds to the digest of a hash function over some content.HASH2is a second hash over the multihash. Second Hashes must be ofMultihashformat withDBL_SHA_256codec. The digest must be calculated ashash(SALT_DOUBLEHASH || MH).ProviderRecordis a JSON with Provider Record as described in the HTTP Delegated Routing Specification.ProviderRecordKeyis a concatentation ofpeerID || contextID. There is no need for explicitly encoding lengths as they are already encoded as a part of the multihash format. MaxcontextIDlength is 64 bytes.EncProviderRecordKeyisNonce || enc(deriveKey(multihash), Nonce, ProviderRecordKey). MaxEncProviderRecordKeyis 200 bytes.HashProviderRecordKeyis a hash overProviderRecordKeythat must be calculated ashash(SALT_DOUBLEHASH || ProviderRecordKey).Metadatais free form bytes that can represent such information such as IPNI metadata. MaxMetadatalength is 1024 bytes.EncMetadataisNonce || enc(deriveKey(ProviderRecordKey), Nonce, Metadata). MaxEncMetadatalength is 2000 bytes.
Note: maximum allowed lengths might change without incrementing the API version. Such fields as contextID or Metadata are free-form bytes and
their maximum lengths can be changed in the underlying protocols.
200(OK): the response body contains 1 or more records404(Not Found): must be returned if no matching records are found422(Unprocessable Entity): request does not conform to schema or semantic constraints
{
"EncProviderRecordKeys": [
"EBxdYDhd.....",
"IOknr9DK.....",
]
}Where:
EncProviderRecordKeysa list of base64 encodedEncProviderRecordKey;
200(OK): the response body contains 1 record404(Not Found): must be returned if no matching records are found422(Unprocessable Entity): request does not conform to schema or semantic constraints
{
"EncMetadata": "EBxdYDhd....."
}Where:
EncMetadatasis base64 encodedEncMetadata;
Assembling a full ProviderRecord from the encrypted data will require multiple roundtrips to the server. The first one to fetch a list of EncProviderRecordKeys and then one per
EncProviderRecordKey to fetch EncMetadata. In order to reduce the number of roundtrips to one the client implementation should use the local libp2p peerstore for multiaddress discovery
and libp2p multistream select for protocol negotiation.