Use SHA256 again for from_public_key #1444
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reverts parts of #1413 (which hasn't been published yet)
Summary of the story:
Libp2p 0.12 only hashes public keys using SHA2256, which is not conforming to specs. Keys less than 42 bytes have to be encoded using the identity hash.
Libp2p 0.13 and above no longer sees an identity peer ID as an error by itself.
However we forgot a detail: if we try to connect to a node that has an identity peer ID, it would always fail because the public key sent by secio/noise is always locally encoded using SHA256 before comparison.
#1413 fixes that and makes it possible to connect to nodes with an "identity" hash, and also encodes small public key using the "identity" hash by default.
Unfortunately, upgrading from a network before #1413 to a network after #1413 is kind of tricky. Nodes with #1413 will send peer IDs with the identity hash to nodes without #1413, which will then fail to connect. It could cause a netsplit.
What this PR does is revert the identity hashing part of #1413, but keep the part where we compare keys equal.
The intent is that we release version 0.16 with this PR, then later we fully apply #1413 and release 0.17.
Then 0.16 will be fully compatible with both 0.15 and 0.17.