by max_ · 1y ago · 0 comments
Is this elitist culture in cryptography.
Alot of algorithms are described incomprehensively.
Let me give you an example.
You might get a well documented specification for implementation of ECDSA.
But it will lack something very 2 important concepts.
1. You should only use it with "safe curves"
2. It's does provide you with a list of "Safe curves"
Same goes for Shamir Secret Sharing. You can know how to implement the algorithm.
But there is so much extra "insider knowledge" or "tribal knowledge" that isn't obvious to non-cryptographers, that you need, for it to be secure.
Such knowledge is often (if not always) not documented. It's in obscure forums, papers and blog posts like this one.
There is no comprehensive encyclopedia for cryptography algorithms.
Developers write bad encryption code because cryptographers have bad documentation.
I would blame the cryptographers, not the developers.
https://en.wikipedia.org/wiki/Shamir's_secret_sharing?wprov=...
The arithmetic used is not constant time, meaning the actual computational steps involved leak information about the secret, were either the recombination of the shares or the initial splitting were observed via side channels.
The arithmetic does not guard against party identifiers being zero or overflowing to zero, although it is not likely to occur when used this way.
I think that specific attack is pretty hard to pull off pratice (in normal scenarios, Vault secret unseals do not happen very often). But it can be a big problem if you were using a scheme where Shamir Secret sharing is used frequently (e.g. it can be triggered by a request sent by the attacker) and (I believe) with different parts of the secret every time.
It's probably safer to use an audited library, but here's a library library that has been audited by two firms, and it's still using lookup tables:
https://github.com/privy-io/shamir-secret-sharing/blob/main/...
The strangest thing is that the audit report by Cure53 mentions this issue, and says it was fixed, but it doesn't seem fixed (at least not in the way that I would expect and the way that HashiCorp fixed it, which is simply removing the tables and using constant-time math). The library maintainers seem to be very proactive and diligent about fixing other issues[1], so it really is strange.
[1] https://privy.io/blog/zero-leading-coefficients-cryptography
(Ironically, this stuff is documented, cryptographers just aren't good at marketing.)
https://www.zkdocs.com/docs/zkdocs/protocol-primitives/shami...
It's a good guide to learn about Secret Sharing, but it doesn't give you even 1% of what you need to know implement it safely by yourself.
That isn't actually a problem, although I've seen a lot of people that think it is.
The problem is framed as "if you have a leading zero coefficient, it's equivalent to a threshold of t-1", but you'd need a zero leading coefficient for every polynomial.
With a 32 byte secret and GF(2^8), you expect at least 1 leading zero coefficient in 11% of random secrets, but a threshold reduction from t to t-1 only occurs with 2^-256 probability (that is, every leading coefficient has to be 0).
You might think you can detect this condition, but SSS is kind of like a one-time pad if you don't have sufficient shares.
> it doesn't mention any other concern like constant time implementations, cache side channel attacks
These are table stakes for secure cryptography. ZKDocs is a guide to algorithms, not implementations.
1. Never invent your own primitives. Only professional cryptographers do that in algorithm competitions like AES, SHA-3, or PHC.
2. For interoperability, use BoringSSL, LibreSSL etc. Hire developer who knows how to do this. Or, hire a professional applied cryptographer to build TLS from low level primitives if you have a reason it's needed.
3. For closed ecosystems, use opinionated, misuse-resistant, high level libraries like libsodium, or libraries binding to it https://libsodium.gitbook.io/doc/bindings_for_other_language...
4. Use kernel CSPRNG to generate all secrets.
5. Have the implementation audited by professionals. E.g. Kudelski Security or NCC Group.
6. Have a bug bounty program that compensates well, and that allows disclosure of the attack.
7. If you're in a market where the competition has open source clients, you should have an open source client too, so that anyone can verify your cryptography is correctly implemented.
8. Keep anything that's WIP, under "research prototype, do not use in production" banner. That's not a cone of shame. If Dan Boneh can do it (https://crypto.stanford.edu/balloon/), so can you.
9. Realize that 90% of the work in cryptography is key management. Use OS keyring when possible.
10. Deploy end-to-end encryption everywhere you can. Data is a toxic asset. https://www.schneier.com/blog/archives/2016/03/data_is_a_tox...
So yeah, sorry, no "Use XChaCha20-Poly1305 or AES-GCM only", or "Use X25519/ed25519" or "remember to hash the X25519 shared secret". That's too in-depth for a ten point list. At that level, it's more of a top-ten book list.
1. Has this problem been solved using a proven cryptographic protocol? Which guarantees does this protocol offer? What are all the important considerations?
2. What's the next closest thing?
3. Can we safely modify the protocol in any way to accommodate our use case, and what are some common pitfalls?
Some people will ignore all that advice and do dumb things anyway, but if we want systems to be more secure, it's on cryptographers to make cryptography more approachable and on developers to actually listen when they do.
It's elitist in the same way quantum physics, string theory and molecular biology are. A hard science with lot's of moving parts not everyone can manage.
>But there is so much extra "insider knowledge" or "tribal knowledge" that isn't obvious to non-cryptographers, that you need, for it to be secure.
Misuse-resistant cryptography is an open research problem. Claiming it's "tribal knowledge" makes it seem nefarious. Academics are not always good teachers, and collecting all the lessons from all papers you read into a book, is time away from doing more research that advances your career.
>Such knowledge is often (if not always) not documented. It's in obscure forums, papers and blog posts like this one.
You can pay for the papers, and you can pay for the school to learn to understand those 'obscure' papers. Or you can hire someone who has done that. If you're a developer expected to implement algorithms of theoretical physics, you're not complaining about the papers being obscure, you're hiring a physicist with double-major in computer science.
There's way too much frustration towards cryptographers, and way too little frustration towards bad hiring practices, and incorrectly assigned work.