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

Truncate function issue #1966

Open
AnkushinDaniil opened this issue Jul 24, 2024 · 4 comments
Open

Truncate function issue #1966

AnkushinDaniil opened this issue Jul 24, 2024 · 4 comments

Comments

@AnkushinDaniil
Copy link
Contributor

Truncate function
There is a commit with a fuzz test and a possible solution.
Input:

k.len = 7
k.bitset = [32]uint8 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64]
length = 2

output:

k.len = 2
k.bitset = [32]uint8 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]

Shouldn't the length be 0?

@kirugan
Copy link
Contributor

kirugan commented Jul 24, 2024

Sorry I thought this is a PR. Cleared assignees

@obasekiosa
Copy link
Contributor

@AnkushinDaniil

Could you explain some more.
I don't understand the question/statement?

@AnkushinDaniil
Copy link
Contributor Author

@obasekiosa

64 = 0b1000000
If truncate to length = 2, we have 0b00 or 0b0, and if we count significant figures, the length should be 0 or 1.

@obasekiosa
Copy link
Contributor

This issue raises the concern that Truncating a key to a particular length might result in a key with a value which can be stored using a much smaller key length.

e.g a key 0b1000000 of length 7 if truncated to length 2 clears the first 5 = (7-2) bits and results in a value of 0b00.
which technically is equivalent to a value of 0b0 which requires just a key length of 1 to store.

My opinion is that, the Truncate function alters the structure of the key. so a key length of 2 for the above operation is the correct output.

seeing that the current implementation uses a fixed size 256 bit array to store each key of varying length, even after truncation 0b00 or 0b0 is still stored as 0b00....0 (256 bits, all zero)

Basically a STRUCTURE vs VALUE CONTENT interpretation of key.length, does it refer to the minimum bits needed to store the key (in which case we have a bug) or does it refer to simply to the length we want the key to be in (in which case we don't have a bug and can close this issue).

@AnkushinDaniil AnkushinDaniil changed the title Truncate function bug Truncate function issue Aug 20, 2024
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

No branches or pull requests

4 participants