-
Notifications
You must be signed in to change notification settings - Fork 152
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
fix: Fix blobHash collision #2881
Conversation
373c479
to
47b2eac
Compare
The python code to generate the hash value to compare in this PR import hashlib
import codecs
# byte string to be converted
b_string = b'\x04\x00\x00\x00'
# decoding the byte string to unicode string
u_string = codecs.decode(b_string, 'utf-8')
text = u_string+"key0"+"val0"+u_string+"key1"+"val1"
print(u_string)
hashObject = hashlib.blake2b(text.encode('utf-8'), digest_size=32)
digest = hashObject.hexdigest()
print(digest) |
4ebfe58
to
84ba2d7
Compare
values = append(values, v) | ||
all = append(all, v) | ||
all = append(all, []byte(k)) | ||
binary.LittleEndian.PutUint32(prefix[:], uint32(len(key))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should leave a comment explaining why we need this 👍
require.NoError(t, err) | ||
require.Equal(t, resHash, h.Bytes()) | ||
}) | ||
t.Run("with escape separator", func(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this test doesn't make sense anymore
) | ||
|
||
func TestMustGetBlobHash(t *testing.T) { | ||
t.Run("normal", func(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should add a test that asserts the collision doesn't happen anymore, right?
so {"ab", "123"}
yields a different hash than {"ab1","23"}
34d0a46
to
5d00efc
Compare
5d00efc
to
08e1548
Compare
No description provided.