Key configuration, RFC 9540 and a new mechanism for directories to opt in to OHTTP requests from relays #486
Replies: 2 comments
|
cACK |
|
re bikeshedding, i think my favorite idea is encoding the protocols the same manner as TLS ALPN (application layer protocol negotiation) protocol lists. protocol identifiers are u8 length encoded byte strings, and the list itself is u16 length encoded, all tagged with the ALPN extension type. the main counter argument would be that, semantically ALPN supported protocols are perhaps a little weird because the encapsulated requests in OHTTP already specify what ALPN is supposed to specify in the context of TLS, and even more so because a BIP 77 protocol does not make sense in that context. it would still be unambiguous and as such could be argued to be semantically appropriate if the scope of ALPN is taken to be broader than just TLS. alternatively, a different tag can be used. the other reasonable alternative that seems obvious is allowing a limited character set for identifiers, and having one per line, but this seems less in line with the key configuration format and not extensible. |
Uh oh!
There was an error while loading. Please reload this page.
RFC 9540 support in the directory and rust payjoin
tl;dr: the directory and payjoin crate should conform to RFC 9540 where applicable, and the BIP 77 spec should be updated, which plugs a gap in the current form of the BIP.
RFC 9540 extends RFC 9458 (OHTTP), allowing OHTTP capabilities to be discovered via DNS service binding records. When a client looks up some service, the capability (or requirement) for that client to accept OHTTP requests from a relay can be announced in the corresponding DNS entry.
Subsequently an RFC 9540 capable OHTTP client access the service's OHTTP gateway using
/.well-known/ohttp-gateway. In rust-payjoin the OHTTP gateway is available on the/path:rust-payjoin/payjoin-directory/src/lib.rs
Line 190 in 8272492
This endpoint also facilitates OHTTP key configuration fetching using an
Acceptheader, which although currently not specified in BIP 77, is implemented differently in rust-payjoin:rust-payjoin/payjoin-directory/src/lib.rs
Line 191 in 8272492
rust-payjoin/payjoin/src/io.rs
Lines 5 to 23 in 8272492
Although the DNS service entries are not directly useful for BIP 77 (since OHTTP is required by the protocol, not by specific directory policies), the key configuration and gateway discovery mechanism can be standardized.
This is a simple change in the code, move both HTTP routes to
/.well-known/ohttp-gateway, and serve the key configuration from that endpoint if theAcceptheader is provided.In band OHTTP relay <-> gateway configuration
tl;dr - similarly to the key configuration mechanism, querying
/.well-known/ohttp-gateway?purposeendpoint can signal to relays that a directory has opted in to a specific purpose (e.g. BIP 77) without requiring static configuration.RFC 9458 assumes a static 1:1 correspondence between relays and gateways. In a nutshell, if OHTTP relays were allowed send requests to arbitrary servers they could be used to perform DoS attacks on behalf of malicious clients. Even if they are not OHTTP gateways, sending OHTTP encapsulated requests can still exhaust bandwidth resource. A related concern that does not apply to BIP 77 is when the gateway and target resource are on the same server). Note that this is not related to denial of service considerations with respect to a specific OHTTP gateway, which are are also the responsibility of relays to mitigate.
The spec does partly address situations where this may be too conservative:
In the context of BIP 77 this assumption, even with this relaxation is somewhat limiting: receivers select the directory, and both receivers and senders can independently choose relays. Requiring the sender to know which relays support which directory constrains relay diversity, which may increase the likelyhood of censorship by relays, or deanonymization if relays and directories collude.
Since BIP 77 directories only support a narrow use case, and the spec constrains request sizes limiting the potential for DoS, it would be better if directories could publicly announce that they will accept BIP 77 requests from any relay, allowing relays to discover this similarly to the RFC 9540 mechanism for obtaining OHTTP key configurations.
This change would introduce a query parameter
/.well-known/ohttp-gateway?purpose, which can list intended purposes (e.g. BIP 77).Instead of the relay being configured with an allow list of directories to which it will forward requests, the relay will accept client requests with a declared purpose, intended to be forwarded to arbitrary ohttp gateways, and then check with the gateway if it will accept requests for that specific purpose.
The rationale for explicitly declaring the purpose is that this allows the relay to enforce some resource constraints on the encapsulated request.
The same relay responsibilities still apply, this is essentially just allowing dynamic n:m mappings to be negotiated between conforming relays and directories.
The primary rationale is that this reduces the potentially$O(nm)$ space of relay x directory configurations, which wallet developers would otherwise be burdened with, to only a $O(n)$ sized configuration problem for senders, and an $O(m)$ sized one for receivers.
Bikeshedding
This might also be negotiated by a different
Acceptheader, or a different endpoint such as/.well-known/ohttp-purpose.However, it's not clear what new mime type might unambiguously represent a purpose list (whereas a generic one could be used to represent a list of protocols).
Similarly, registering a new
/.well-knownpath for BIP 77, which lacks an RFC, seems fraught.The simplest representation for the list of supported purposes is probably restricting the purpose identifiers to a standard identifier set (subset of ASCII), and listing one per line. JSON or RFC 5322 style value lists might also be considered, but this seems excessive. For non IETF standards, a UUID could be used to identify a purpose.
All reactions