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

GenRandomKey function #116

Merged
merged 3 commits into from
Mar 14, 2023
Merged

GenRandomKey function #116

merged 3 commits into from
Mar 14, 2023

Conversation

guillaumemichel
Copy link
Contributor

Add a GenRandomKey(targetCpl) function similar to GenRandPeerID(targetCpl) but not requiring the list of precomputed hash preimages.

This function generates a random Kademlia key (32 bytes), whose first targetCpl bits are shared with the local key of the routing table.

It is useful as we get to replace string oriented requests with byte oriented requests in go-libp2p-kad-dht). It is a prerequisite for the Double Hash DHT implementation.

@guillaumemichel guillaumemichel self-assigned this Mar 13, 2023
table_refresh.go Outdated Show resolved Hide resolved
@guillaumemichel guillaumemichel requested a review from Jorropo March 14, 2023 08:30
@guillaumemichel
Copy link
Contributor Author

@Jorropo I updated the code with your suggestions, and reduced the amount of inline comments. Let me know what you think now 😄

Copy link
Contributor

@Jorropo Jorropo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minus a last final change this LGTM

table_refresh.go Outdated Show resolved Hide resolved
@Jorropo
Copy link
Contributor

Jorropo commented Mar 14, 2023

@guillaumemichel I'm surprised you are not removing the older preimage based implementation.

This makes me worry of how you are gonna implement the double hashing impl.

Will you do a V2 branch ? (so both modules live in two different branches but can be imported together). Or stay on v0 branch and "manually" write code that handle both DHTs at once.

@guillaumemichel
Copy link
Contributor Author

Good point @Jorropo! IMO this new function is generic enough to be used in other projects, and even the go-libp2p-kbucket repo is pretty generic, so no need to deprecate anything now.

It will certainly be useful to create a V2 branch for both go-libp2p-kbucket and go-libp2p-kad-dht in order to allow kubo to use both the old and the new DHT during the transition period.

@guillaumemichel guillaumemichel merged commit 182a8e0 into master Mar 14, 2023
@guillaumemichel guillaumemichel deleted the gui/genrandomkey branch March 14, 2023 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants