DNS Stamps Specification

4 points by zk


dzwdz

I'm not sure why this was submitted here, but I've been messing with DNSCrypt recently and this, imo, is one of the more dubious parts of its spec.

DNS Stamps look like URLs but, being base64-encoded blobs, they're opaque to humans. Yet it doesn't seem like there's any reason for them being base64-encoded - most of the encoded data is already in an URL-safe, human-friendly format.

Take, for example, this stamp: sdns://gRlbMmEwZDo1NjAwOjEzOjcxOjo1M106NDQz. Decoding its body, we get "\x81\x19" + "[2a0d:5600:13:71::53]:443". Notice that the address and port are encoded exactly as in URLs. The first byte is the protocol identifier for DNSCrypt relays, and the second byte is the length of the string.

A (hypothetical) equivalent representation would be dnscrypt-relay://[2a0d:5600:13:71::53]:443. This stores exactly the same data, is human readable, arguably simpler to implement, yet it's also shorter.


As another example, can you tell what sdns://AQMAAAAAAAAADDkuOS45Ljk6ODQ0MyBnyEe4yHWM0SAkVUO-dWdG3zTfHYTAC4xHA2jfgh2GPhkyLmRuc2NyeXB0LWNlcnQucXVhZDkubmV0 means? How about dnscrypt://9.9.9.9:8443/2.dnscrypt-cert.quad9.net/Z8hHuMh1jNEgJFVDvnVnRt803x2EwAuMRwNo34Idhj4=/?dnssec=yes&nolog=yes?

I don't think that hypothetical encoding is perfect[1] - for one, it only had a few minutes of thought put into it - but it still seems like such an improvement. I don't understand why DNS Stamps took the choices it did.

[1] Due to how DNSCrypt/DoT/DoH work, you have to specify a domain name alongside the IP of the resolver. I'm not sure if there's a "standard" way to do it - I just slapped it in there as a path component, but perhaps that's bad. The public key could perhaps just be URL-encoded instead of using base64, to remove one potential library dependency. &nolog=yes is confusing, but I wanted to keep the naming from the DNS Stamps spec - and some URL schemes require query components to have values, so I didn't want to just do ?dnssec&nolog.