Open NIC619 opened 5 years ago
Doesn't go-libp2p and js-libp2p, and the general libp2p spec, use sha256 for peer IDs by default and by recommendation?
Just looked it up, go-libp2p uses sha256:
(Edit: I just saw that other link above, but in this link is it's network peerID hashing counterpart used in its identify protocol)
I realise this is even more important, as else py-libp2p is not able to join the current established network, which uses sha256
There are two different things going on here -- peers in libp2p
have an ID
which is generally encoded as a multihash
value like you see here: https://github.com/libp2p/py-libp2p/blob/master/libp2p/peer/id.py#L83-L89. So the specific hash function is specified by the creator of the multihash.
This issue refers to the value used as a key into the kademlia
DHT which does happen to use SHA256
per the link in the first comment here: https://github.com/libp2p/go-libp2p-kbucket/blob/3752ea0128fd84b4fef0a66739b8ca95c8a471b6/util.go#L43-L46.
Hmmm, I'll look at that and see if I can update/refactor that to use a default hashing function (sha256 cuz why not) in a generic function, or maybe even work it away in utils
i replied to the PR w/ my thoughts on code organization for this one function
Which in my eyes sounded similar to what i was implying here, i generally wanna take https://github.com/libp2p/py-libp2p/blob/master/libp2p/peer/id.py#L83-L89 (like you mentioned), the specific multihash.Func
class, and implement that uniformly
What's wrong?
https://github.com/libp2p/py-libp2p/blob/1727ba48d9e5cff4fb00d3972aee0a7cd1871eb0/libp2p/peer/id.py#L87-L90 sha1 is used in calculating a DHT ID
How can it be fixed?
Change it from sha1 to sha256 Go: https://github.com/libp2p/go-libp2p-kbucket/blob/3752ea0128fd84b4fef0a66739b8ca95c8a471b6/util.go#L43-L46