-
Notifications
You must be signed in to change notification settings - Fork 53
Description
The /p2p protocol can only be followed by a PeerId: https://github.com/libp2p/specs/blob/master/addressing/README.md#the-p2p-multiaddr
As per spec, a PeerId can only be a multihash with either SHA256 or the identity hash in case the encoded public key is less than 42 bytes.
Currently, /p2p exposes a Multihash which is more general than that.
I see several options of how we can improve this situation:
- Extract the
PeerIdtype fromrust-libp2pinto a dedicated crate and havemultiaddrdepend on that - Move the entire
identitymodule oflibp2p-coreinto its own crate (keys +PeerId) - Move the
rust-libp2pPeerIdtype intomultiaddr - Define a minimal
PeerIdtype withinmultiaddrthat encodes the above invariants
All of the above have their pros and cons.
Extracting PeerId into its own crate feels a bit odd because it would be a very small crate. On the other hand, it would encode a very important concept in a concise form so it may be worth it.
The next step up would be a crate that encapsulates everything around keys in libp2p into its own crate, i.e. libp2p-identity. That is basically this module + the peer_id module.
Personally, I'd be in favor of option (2). I think it makes sense to break out this part into a separate crate. We can heavily feature-flag that one to the point where the multiaddr crate itself only depends on the bits that define the PeerId and doesn't come with any other dependencies.
Input welcome!