-
Notifications
You must be signed in to change notification settings - Fork 15
change how we calculate inline peer IDs. #30
Conversation
4811d98
to
583ec80
Compare
peer.go
Outdated
if err != nil { | ||
return "", err | ||
var alg uint64 = mh.SHA2_256 | ||
if len(b) <= 40 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you might want to define the algorithm and the magic 40 as consts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And now the world is a little less magical 😿.
i think it's important to ensure that |
It will except for ed25519 keys which, according to @whyrusleeping, nobody is using. |
Wouldn't it be better, in case of ed25519 to skip the protobuf? Public key is bytearray of 32 bytes. Prepend it with ed's multicodec packed and it should be good to go. |
The motivations for this change are:
Currently, we have a separate special function for generating inlined ed25519 keys (that currently slices the serialized protobuf to extract the key 😱) and another for extracting such keys from peer IDs. My first attempt at fixing this issue involved:
However, even after doing this, we'd still have two separate serialization formats which seems kind of silly. Maybe we should have serialized keys as So, we could go with the two format system but it really only saves us 3 bytes. The inlined peer IDs are currently 35 bytes. After this change, they'll be 38 bytes. I picked a 40 byte inline cutoff so we can get a bit of breathing room (although we could also just pick 42 bytes as a nice round number). |
Given that we are going "full breaking change mode"...Is ipfs/specs#58 being taken in consideration here at all? @ianopolous brought some really valid points during forest (Keys will eventually be huge) and we should just treat the key as a File with metadata that we can then chunk and retrieve through IPFS itself. This proposal -- ipfs/specs#58 (comment) (and comments below) -- should meet all the requirements for all types of keys, existing now and future ones. |
@diasdavid we aren't quite going full breaking change mode. This PR won't break any existing IPFS nodes as it doesn't change how we compute RSA peer IDs. Eventually, I'd like to treat keys as files (or, really, IPLD DAGs) but that's a larger change (with backcompat issues). |
Instead of trying to get fancy with multicodecs and such, just inline the public key's protobuf. Eventually, we can try to switch to true IPLD but this is, IMO, a step in the right direction.
0b7a227
to
de78f16
Compare
Instead of trying to get fancy with multicodecs and such, just inline the public key's protobuf (if it's small enough).
Before:
Currently, we always use sha256-256 multihash's except when the user explicitly uses the
IDFromEd25519PublicKey
function. That function returns the identity multihash of the ed25519 multicodec concatenated with the ed25519 public key).After:
Eventually, we can try to switch to true IPLD but this is, IMO, a step in the right direction.
This is a massively breaking change for anyone using ed25519 keys but:
fixes #29