-
Notifications
You must be signed in to change notification settings - Fork 354
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
constant time Ord and PartialOrd implementations #267
base: master
Are you sure you want to change the base?
Conversation
along side similar functionality
Thank you for putting in the work to write this. I'm leaning against landing it, for two reasons:
(Side note: the CI failures are because we test this crate in |
Yeah, given that discussion I'd be inclined toward the original PR.
That makes a lot of sense! |
Actually I should've said that it's not clear (to me) that we want any |
Fixes #202.
This does not follow the recommended path of utilizing subtle as it does not provide any helpers to do constant time ordering on containers.
The overall method is to compare each u32 in the hashes, turn each of those into -1, 0, or 1, accumulate them into a single signed word, and then finally compare that word to 0.
The optimized object code on x86-64 is somewhat large but appears to be constant time - no jumps, early returns, or anything like that. This is, of course, not a guarantee that it will never face optimization in hardware or software in the future.