Introduce a unified trait or struct for things that have relay identity keys
(This comes out of a discussion on !433 (merged).)
There are lots of places in Arti where we hard-wire the status quo that Tor relays have an Ed25519 identity and an RSA identity fingerprint. There are a few places where we define types that encode both of these (like FirstHopId
) too.
This leads to needless code duplication and a lack of forward compatibility. I propose that we solve the issues as follows:
- There should be a trait in
tor-linkspec
for "Something that has the keys to identify a relay". This trait should be a parent trait ofChanTarget
, and should be implemented by all the things that currently have a an ed25519 identity and an RSA identity fingerprint. If we need to add a third key type in the future, we can add a new method to it with a default interface, something like:
fn falcon_id(&self) -> Option<FalconFingerprint> { None }
- There should probably be a structure in
tor-linkspec
holding "all the identity keys that a relay has". It should probably have owned and by-reference versions. It should be opaque enough that we can add an additional, optional key type in the future if we need to.