-
-
Notifications
You must be signed in to change notification settings - Fork 90
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
Add support for SipHash128 with all-zero key #40
Comments
See also discussion in typst/comemo#3. Note that I'm suggesting adding support for the weaker SipHash 1-3 with 128-bit output, not the default stronger SipHash 2-4 with the default 64-bit output. |
Does rust currently uses 64-bit TypeIds ? |
What would happen if there was a collision? |
It used to, but has been changed to 128-bit a while back.
You can transmute one type to another if they have the same |
Only transmutation by choice? But no bad side consequences that could creep up on people? |
As @bjorn3 said, various "safe" APIs in Rust, basically anything that uses See rust-lang/rust#10389 (comment) for an example from back when the shorter TypeIds were used. |
The The SipHash-based hasher is also used for some equality comparisons within the compiler, so potentially when compiling one type could be silently substituted for another. So in theory just compiling two crates (or a single crate) that defines types with typeid collision could result in a miscompilation. There is effort underway to further use SipHash for other uses, e.g. rust-lang/cargo#13171 (comment). I find the discussion about that a bit confusing still. |
But a collision of course must follow the apropriate format of how types are converted to a message input to siphash. Is there a (simple) description of this format? |
See also rust-lang/rust#41215 which seems to imply that it is used in the incremental compilation cache. See also the use in the mold linker: rui314/mold@fa8e95a. My understanding is that when Siphash(k, x) = Siphash(k, y) all references to the the object code y will be replaced to instead refer to the object code x (i.e. x and y will be "folded" together as identical code). IIUC from the twitter discussion, mold may use a random key. |
It depends on the rustc version and isn't directly written down in the rustc source code but created using code generation while compiling rustc (to be precise Take the index of the TyKind variant and hash it as 64-bit(?) little endian number (counting from zero). Then hash all the fields. For simple enums recurse the same way. For |
How hard would it be to create a program that takes a source code representation of a |
If you ignore |
Another motivating example: rust-lang/cargo#6529 (comment) |
I referenced your work on the ASCII identifier MD5 collision in rust-lang/rust#10389 (comment). It would be cool if we could extend your tools to also work on SipHash128 with an all-zero key being used as a hash function. Is that something that you would accept? Any tips for contributing it?
The text was updated successfully, but these errors were encountered: