ipfs / go-cid

Content ID v1 implemented in go
MIT License
157 stars 47 forks source link

Allow CID to reference public keys (possibly make it extensible) #15

Closed mildred closed 4 years ago

mildred commented 7 years ago

See message on IRC: https://botbot.me/freenode/ipfs/msg/78509267/

Currently, when looking up public keys, the generic value store interface of the DHT is used.

This has the effect that when, for example looking up a public key (but this is the same for naming), the DHT is queried twice. Once for the correspondance between the public key fingerprint to know the block id and once more to get the list of peers that can provide the block with the id we just got.

Instead, the key could be directly lookup up using the content lookup interface of the DHT. This interface takes a CID and respond with a list of peers directly. This is exactly what we need.

I suggest that we add an encoding in the CID to represent a public key from the key hash to avoid the two phase lookup. This is what this ticket is for.

I also suggest that instead of taking a pointer to a CID value, the routing interface references an interface type instead, that could be implemented differently. This is to be tracked in libp2p/go-libp2p-routing.

Don't hesitate to chat with me over IRC, realtime makes it easier to remove ambiguities

whyrusleeping commented 7 years ago

@mildred agreed on wanting a CID codec to easily reference keys. We want to use ipld to do this, and call the format multikey.

However, we could address the problem you bring up without that. If peers added their public keys into the blockstore then you could move them around with bitswap, and peers could fetch public keys that way instead of requiring a dht query

lidel commented 4 years ago

FYSA we now have libp2p-key multicodec, it is used for representing PeerIDs as CIDs: https://github.com/multiformats/multicodec/issues/130

This issue is pretty old, so I am closing this. A lot changed since then, revisited DHT improvements can be proposed in upstream go-ipfs or libp2p repos.