by grog454 · 3y ago · 0 comments
> Mathematical Background
> Before we tackle cryptography we need to cover some basic facts from mathematics.
Nit: we really don't. This reminds me of how dry and uninspired the cryptography and cryptology (less so) classes I took almost 20 years ago were.
But, when learning any cryptographic scheme, in order to understand what is going on, it is certainly necessary to learn the corresponding mathematical tools. Even to define what it means for a scheme to be secure requires a good grasp of probability (and negligible functions in the asymptotic regime).
It’s my understanding that every cryptographic algorithm is based on math, much of it not so simple.
There's two strategies: substitution and permutations. Substitutions is when you replace a set of bits with another set of bits (ex: ABCD might become IAQN). Permutations is when you move bits around (ex: ABCD might become CADB).
When you mix substitutions with permutations, and then loop like 10+ times, it becomes really hard to follow. Bam, cryptography algorithms.
----------
How do you build substitutions and permutations that are hard to follow? Well, it seems like substitutions are the hard one, permutations seem relatively straight forward to me in most block ciphers (AES is really easy: a rotation to the right, and then a column-wide rotation. All of the bytes are in a 4x4 matrix, for the 16-bytes. Its actually super easy to follow AES's permutation steps).
Substitutions need to be done in such a way that is resistant to pattern-matching / cryptoanalysis. Choosing random numbers is not sufficient. For this, we enter "math", such as galois fields.
Galois Fields looks complex, but that's only because you haven't learned them yet. All a Galois Field is... is a set of numbers (such as 0, 1, 2, 3, 4, in the GF(5) field) that have addition, addition-inverse, multiplication, and multiplication-inverse.
Note: Galois Fields manage to accomplish this by reinventing the definition of addition and multiplication. Ignoring this... weirdness... its rather straight forward. Every operation can be inverted (not just addition and multiplication... but also complex algorithms like exponents, logarithms, square roots and more).
Once we're assured that both addition and multiplication can be perfectly inverted, we can build substitutions that are perfect... and then use math to prove that it should be hard to invert (though always possible to invert, due to both addition and multiplication having inverting-steps).
Proving that these things are "hard to reverse" with cryptoanalysis is beyond the scope of most student's study. So Cryptography courses go into Galois fields but forget to tell you why the hell you're studying it in the first place.
--------
In practice, we just show off AES's S-box (substitution box), that says which bytes get replaced with new bytes. And vice versa (https://en.wikipedia.org/wiki/Rijndael_S-box).
The GF(2^8) extension field just is a complex way of saying 8-bit numbers using this weird "addition-changed / multiplication-changed" math system that has guarantees of reversal / invertions.
Not to mention this is basically an eli5 for what is a block ciphers (or aes specificly). If you are actually studying block ciphers you'll need to learn much more than that. Additionally, Block ciphers are just one part of cryptography - i think this thread was more about ECC.
Encryption needs to be inverted. So that's easy enough to understand. Hashing (and cryptographic hashes) need to be inverted because of the pigeon-hole principle. If we have a space of 1000 numbers, we want 1000 unique hashes to 'maximize the space'.
Turns out that the easiest way to accomplish this is through invertible functions, because if there's 1000 numbers that hash into 1000 other numbers, that's called a 1-to-1 and onto function, which is also the requirement for invertibility.
Any other setup, say 1000 numbers that turn into 500 numbers, weakens the hash obviously (two numbers collide for no reason), while the reverse 1000 numbers into 1500 numbers, is impossible.
---------
Once you realize that invertibility is the key to all of these algorithms, then its very straightforward. Its just a bunch of math that most simply accomplishes the goal.
The reason why crypto-math "looks" hard is because no one teaches the motivation behind the primitives. Its not like Galois Fiels are randomly used you know, mathematicians liked the properties of Galois Fields... and how easy it is to invert those operations.
Because of this, modern ciphers prefer Add-Xor-Rotate ciphers instead of Galois Field operations. As it turns out, Add-Xor-Rotate groups are provably invertible too, and are far, far more efficient to run than Galois Field operations.
I dont see how aes use of gf(2^8) based sboxes have any implication for speed, but maybe i am out of my depth.
Here's a discussion of cryptography that has 0 occurrences of "ring" (for example): https://en.wikipedia.org/wiki/Cryptography
If you allow me to substitute “ring” with “field,” the phrase immediately appears in technique-specific pages (see elliptic curve cryptography: https://en.m.wikipedia.org/wiki/Elliptic-curve_cryptography)
Undergraduate/graduate cryptography courses don’t teach from Wikipedia articles for a reason. It would be a disservice to those learning cryptography to discount the pivotal role of mathematics in the field.
I’ll just be blunt here. This is incredibly nitpicky to the point where I’m not even sure what you’re trying to accomplish or add here.
And how do you explain elliptic curves without using fields?