-
Notifications
You must be signed in to change notification settings - Fork 30
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
faster hash
for Address
#688
Conversation
|
||
# Addresses are more or less random so we should not need a fancy mixing | ||
# function | ||
copyMem(addr a0, unsafeAddr a[0], sizeof(a0)) |
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.
These will be more efficient if EthAddress
also is required to be aligned, which nim-eth
does not require and array[20, byte]
might not automatically trigger since its base type has sizeof() == 1
. But that'd have to be changed in another repo, and it's cleaner to keep the changes separate. Both can help, but this works and is useful on its own.
nimbus-eth1 also using a lot of Hash256 as lookup key, maybe add one hash function for Hash256 too? |
One problem here would be that we use the same alias of One thing I wasn't sure of was whether to use all bytes of cc @cheatfate wdyt of adding the hash from beacon chain to nimcrypto? |
Such trick should not be used for SHA256 because you significantly lowering its chance for uniform distribution while taking only first 8 bytes. Such trick could work with 3rd generation of digests like KECCAK/BLAKE2 (this algorithms has such function), but not with second generation like SHA256. 256 bits of cryptographic hash will have uniform distribution but 64 bits of 256 bits will not have such property. |
For the purpose of That said, I don't think it's the end of the world if we use this The question is more whether we can add it to nimcrypto? |
cheatfate/nimcrypto#79 adds some infrastructure so we can unroll an xor implementation for |
nim-lang/Nim#23678