Skip to content
New issue

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

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

Already on GitHub? # to your account

Generic kadkey #51

Closed
wants to merge 6 commits into from
Closed

Generic kadkey #51

wants to merge 6 commits into from

Conversation

iand
Copy link
Contributor

@iand iand commented Jul 5, 2023

When golang/go#44253 is implemented we could replace any by [...]byte

@guillaumemichel
Copy link
Contributor

In order to remove the errors returned from KadKey methods, we can simply accept any size of key, and move the responsibility to check the key size to the caller.

When an method is called on 2 keys of different size, consider that the shorter one is a prefix (aligned left). Just like if we pad right zeros to the shortest key.

  • Equal would return true iff the keysize is the same for both keys, and all bits are the same
  • Compare with 2 different key sizes would compare the bits of the 2 keys up to the size of the shortest key. If key0[:shortestKeyLen]==key1[:shortestKeyLen], consider that shortest_key < longest_key. Return 0 iff key0.Equal(key1).
  • CommonPrefixLength returns the actual CPL (given that the shortest key is a prefix, and not a suffix), so CPL <= shortestKeyLen
  • Xor normally xors longestKey and shortestKey+"00"*(longestKeyLen-shortestKeyLen). So the last bits of longestKey stay unchanged

@iand iand closed this Jul 5, 2023
@dennis-tra dennis-tra mentioned this pull request Jul 6, 2023
@iand iand deleted the generic-kadkey branch July 25, 2023 09:59
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants