Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kademlia uses SHA256(SHA256(publickey)) #694

Closed
tomaka opened this issue Nov 28, 2018 · 5 comments
Closed

Kademlia uses SHA256(SHA256(publickey)) #694

tomaka opened this issue Nov 28, 2018 · 5 comments
Labels
difficulty:moderate priority:important The changes needed are critical for libp2p, or are blocking another project

Comments

@tomaka
Copy link
Member

tomaka commented Nov 28, 2018

The libp2p Kademlia in fact rehashes everything with SHA256 before inserting into k-buckets. This needs to be fixed in our code base.

Let's wait for #580 before doing this.

@tomaka tomaka added priority:important The changes needed are critical for libp2p, or are blocking another project difficulty:moderate labels Nov 28, 2018
@tomaka tomaka mentioned this issue Feb 5, 2019
@dvc94ch
Copy link
Contributor

dvc94ch commented Feb 14, 2019

I see what you mean since you are using the hash as a key into a hash table. While it may be better for performance if it weren't rehashed, it shouldn't change the correctness of the lookups no?

@anacrolix
Copy link

Could you clarify? Do you refer to the fact that peer IDs are a hash of a public key, and then the key used in the DHT is a hash of the peer ID?

@dvc94ch
Copy link
Contributor

dvc94ch commented Feb 14, 2019

@anacrolix Mmh, so the comment refers to the PeerId being wrong not to the fact that a multihash is used as a key into FnvHashMap?

/// List of values and peers that are providing them.
///
/// Our local peer ID can be in this container.
// TODO: Note that in reality the value is a SHA-256 of the actual value (https://github.com/libp2p/rust-libp2p/issues/694)
values_providers: FnvHashMap<Multihash, SmallVec<[PeerId; 20]>>,

@tomaka
Copy link
Member Author

tomaka commented Feb 14, 2019

Could you clarify? Do you refer to the fact that peer IDs are a hash of a public key, and then the key used in the DHT is a hash of the peer ID?

Yes!

@romanb
Copy link
Contributor

romanb commented Apr 26, 2019

Isn't this resolved by #1025?

@tomaka tomaka closed this as completed Apr 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty:moderate priority:important The changes needed are critical for libp2p, or are blocking another project
Projects
None yet
Development

No branches or pull requests

4 participants