Hacker News new | ask | show | jobs
by namkt 1299 days ago
I think the point behind "constant time" here is that the comparison always takes the same amount of time, and not based on how many characters in the two strings are equal, to prevent a timing attack. "Constant time" isn't very accurate here because given a choice of hashing algorithm, the hash is a fixed-length string and therefore even a trivial string comparison technically "runs in constant time", at least if we allow the typical abuses of language in CS.
1 comments

Yes, but my point is that there are only a few use cases for this, mostly in cryptography, and to ensure something is genuinely constant time you have to write in assembly. The routines needed are small enough and compilers hard enough to trust that you just bypass them in practice, so it's an odd choice for something to build into a language syntax.
My assumption is that it's not just the syntax, but that their compiler does the right thing. Though someone said it's based on LLVM, so who knows how much control they get.