4 ms·
I have no ability to judge the quality of this algorithm or implementation, but I do thoroughly approve of the usage of unicode in variable names: ρ, σ :=
by gnfargbl 3y ago
I have no ability to judge the quality of this algorithm or implementation, but I do thoroughly approve of the usage of unicode in variable names:
ρ, σ := G[:32], G[32:]
Somehow much better than seeing "rho", "sigma".
- clktmr 3y agoI must say, I don't like it at all. As with all characters that aren't part of my keyboard, the extra steps to type these add so much friction. Also, I would probably misread ρ as p, giving me the weirdest compile errors. How would you feel about adding acutes and cedilles to characters? It just adds complexity. Let's stick to the smallest common denominator.
- eviks 3y agothe smallest common denominator for math is math symbols, full ascii notation instead of those is the extra complexity in reading comprehension, which, as the saying goes, is a more frequent occurence
- Philip-J-Fry 3y agoGotta disagree. It's neat, but I don't like to see it in the real world. For a start, I don't know how to type these on a keyboard. Secondly, most people wouldn't know what these symbols are called. Granted, those looking at the code probably have a greater chance of knowing. But it isn't friendly code in my opinion. I think clarity is key, and "rho" or "sigma" are pretty clear. Also, add in that there's a constant "n" and a constant "η". Just begging for confusion.
- curiousgal 3y ago[flagged]
- zare_st 3y ago[flagged]
- curiousgal 3y agoI am not saying you should use Unicode symbols in your code... What I am saying is that not knowing how to read greek alphabet, a corner stone of math and physics, does not bode well for someone working on cryptography algorithms, arguably one of the most practical uses of math.
- maleldil 3y agoI think you misinterpreted their comment. It's not that only people who use Unicode characters should be doing crypto math. It's that if you're doing crypto math, you certainly know what the symbols mean since they're used in the original specification, so reading the code shouldn't be a problem.
- tuhriel 3y agoYeah, so they don't actively handle them as greek letters and translate the variable name. Nevertheless, if you don't know what those mean, there is a great chance that you do not understand the whole thing enough, that way you shouldn't touch any crypto code. following the old adage: "never roll your own crypto"
- Retr0id 3y agofwiw modern compilers are fine with unicode variable names https://godbolt.org/z/hd14rd13e https://godbolt.org/z/hd14rd13e
- Retr0id 3y agoIn a more general sense I'd agree, but in this instance, the ML-KEM draft specification (FIPS 203) uses the exact same greek symbols. This code will be read many more times than it is written, and anyone auditing its correctness will be comparing against the spec. If the variables are spelt out, then you have to do the mental (or otherwise) translation before you can compare the two, adding overhead. For comparing the symbols visually, you don't even need to know their names.
- xenophonf 3y ago> the ML-KEM draft specification (FIPS 203) uses the exact same greek symbols I'm as proud of my heritage as the next Greek-American, but just because mathematicians use unintelligible symbols in their manuscripts doesn't mean we have do the same thing in code. Let's prioritize comprehensibility and give variables meaningful names, instead.
- Retr0id 3y agoFIPS 203 is not a math paper, it's a specification, giving concrete algorithms that use aforementioned variable names. Maybe they should use more descriptive variable names in the spec (you could tell them about it - they accept and respond to feedback from the public), but in the meantime, I think it's more useful for an implementation to use the same variable names as the spec.
- riquito 3y ago> For comparing the symbols visually, you don't even need to know their names. Well, no, this was the main issue with homograph attacks in domain names [1] that brought us to the use of punycode in browsers [2] In particular for a cryptographic library, I wouldn't want to constantly have to watch out for sneaky malicious variables put in the right place (e.g. try to compare visually the Cyrillic а, с, е, о, р, х, у with the ascii a, c, e, o, p, x, y (no, they're not the same characters). EDIT: I realize that many programming languages today allow the use of unicode variables and I like that it's a possibility, it's just not the best when you need to be paranoid about the code - [1] https://en.wikipedia.org/wiki/IDN_homograph_attack https://en.wikipedia.org/wiki/IDN_homograph_attack - [2] https://en.wikipedia.org/wiki/Punycode https://en.wikipedia.org/wiki/Punycode
- eviks 3y ago> For a start, I don't know how to type these on a keyboard. You can learn how to do that, even find a way to type "sigma", but more importantly, it best benefits readers, not writers, so you don't need to learn to type it > and "rho" or "sigma" are pretty clear. no it's not, where would you get clarity from is all the clarifying literature for these notions use the actual math notation σ? > "n" and a constant "η". Just begging for confusion looks very distinct, one is obviously mathy, another isn't
- deleted 3y ago[deleted]
- tzs 3y agoDoes Go allow unicode subscripts in variable names? Of the languages I've checked, Perl, Python, and JavaScript (in Chrome and Firefox) do not. PHP does.
- sapiogram 3y agoIt does. Not exactly surprising, since Rob Pike and Ken Thompson made both Golang and UTf-8.
- eviks 3y agoit doesn't (that's subscript 1)? > invalid character U+2081 '₁' in identifier Though that's also not surprising given how poor overall Unicode support is
- eviks 3y agodoesn't seem like it > invalid character U+2081 '₁' in identifier But AutoHotkey does allow it super² := 1, sub₂ := 2
- deleted 3y ago[deleted]