Skip to content
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

Add a Cryptography Chapter #278

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,6 @@ mukundan314
<br>
Trashtalk
<br>
Cyrus Burt
Cyrus Burt
<br>
Liikt
1 change: 1 addition & 0 deletions SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@
* [Data Compression](contents/data_compression/data_compression.md)
* [Huffman Encoding](contents/huffman_encoding/huffman_encoding.md)
* [Quantum Information](contents/quantum_information/quantum_information.md)
* [Cryptography](contents/cryptography/cryptography.md)
77 changes: 77 additions & 0 deletions contents/cryptography/cryptography.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Cryptography

Humans have almost always been interested in sending secret messages that only the sender and receiver understand.
The reason for this is obvious: secret messages should remain secret.
The easiest way for this to happen is to talk behind closed doors, but that simply doesn't work if the the sender and receiver are separated by a significant distance.
In this case, they need to rely on a messenger or mailman to send the message.

For simplicity, let's assume they are sending a written letter for the purpose of negotiating war tactics in ancient Greece or Rome.
Obviously, the message can remain secret if both the sender and receiver also trust the messenger; however, what if the messenger is actually an evil spy?
What if the messenger is killed and the letter is stolen?
What if (in an elaborate ruse), some third party slips into the messenger's tent in the dead-of-night and replaces the letter with another one entirely different?

These are all important questions cryptography addresses.

The idea is simple: we procedurally scramble the message we are sending and only provide the unscrambling procedure to trusted parties.
In this way, the message would seem like utter gobbledygook to anyone other than the sender and receiver.
It doesn't matter if the messenger is evil.
They cannot read the message anyway.
It's also fine if the message is replaced, because then the receiver won't be able to properly decode the message and can just ask for another message to be sent (probably on another path with a different messenger).
Unsurprisingly, one of the first methods of encryption was supposedly developed by Julius Caeser and called the "Caesar Cipher."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

People have been using ciphers since well before 44BC. Substitution ciphers, in particular, have been around almost as long as writing -- there are Mesopotamian tablets which use it. And, naturally, it was to protect someone's trade secrets. See this. That said, the Caesar cipher is a good introductory example of a cipher; I think it can and should stay, just... don't call it the first.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point

Here, every character in the message is replaced by another character based on some pre-defined table or chart that only the sender and receiver have.
The table is created by simply rotating the alphabet by $$n$$ spaces, where $$n$$ is chosen in a discussion between the sender and receiver before-hand.
Liikt marked this conversation as resolved.
Show resolved Hide resolved
It is certainly not the most complicated scheme out there, but it is generally the first encryption scheme people come up with when trying to encode secret messages to one another.
Honestly, I remember sending messages back and forth to friends in elementary school, but we would never provide the necessary table to decode the message.
Instead, we would provide enough text that they could find the table themselves from context.
If a bunch of elementary school kids can figure out how to break this encryption scheme, it cannot be too robust.
In fact, it's interesting to see how the field of cryptography has grown since the Caesar cipher was developed.
In the cryptographic literature, there is always a sender, receiver, and eavesdropper.
For some reason beyond my own comprehension, these three people are almost always given the names Alice (sender), Bob (receiver), and Charlie (attacker or eavesdropper).
Liikt marked this conversation as resolved.
Show resolved Hide resolved
These names are consistent even with quantum cryptography, so they are here to stay.

In general, there are two different types of encryption: symmetric and asymmetric.
Both of which are described in the following sections.

Cryptographic systems are a cornerstone to modern information technology and lie at the heart of everything from WiFi passwords to bank passwords.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This phrasing is... odd. They're not at the heart of passwords. Maybe more like:

Encryption algorithms are a cornerstone to modern information technology and keep everything from cat pictures to bank information safe.

Though the "information technology" bit is still awkward.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well i guess you are right. I'll be taking out the password

If an attacker manages to crack modern cryptographic algorithms, they could cause serious damage.
For this reason, it is important to keep a few things in mind:
* Because crypto has become such an advanced field cryptosystems should be analyzed by trained professionals.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe make clear that both algorithms and implementations need to be vetted?

Meaning whenever possible use a widely accepted cryptography library instead of writing your own cypher.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent by four spaces to continue the previous bullet point instead of dropping a random paragraph between points.

* Kerckhoffs's principle says that when determing the robustness of a cryptosystem it should be assumed that the attacker knows the encryption and decryption algorithm.
This does not include any pre-shared or secret keys.
* With the advances in technology cryptography often hits it's limits.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*its

Also, not all that often -- modern crypto typically stays well ahead of the technological curve, and modern crypto is designed with configurable strength. See, for example, bcrypt, which has a configurable number of rounds, to scale the work done without changing the algorithm. That'll probably stay relevant for decades, unless someone finds a fundamental flaw in the algorithm.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant here that we always had to scale the algorithms and are looking for better and better algorithms (i.e. ec instead of rsa, md5 being utter garbo for crypto,...)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Liikt Ahh gotcha. Maybe rephrase it a little, then? Something like:

Cryptography is always improving as old algorithms get weaker and technology gets more powerful.

Either way works, though, I just misunderstood it the first time.

Many formerly thought hashing algorithms became obsolete because the computer used to crack them got faster and better.
Another field that cryptography will have to face is Quantum Computing.
Quantum Computers will have a big impact on cryptography and especially asymmetric crypto.
This whole set of problems is summarized in the field of Post-quantum cryptography.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somewhere in this article, we need to mention quantum computing. One of the major reasons it is such a big deal is because it has a heck of a lot of raw power that will completely blow modern cryptographic systems out of the water. This is why quantum cryptography is such a hot topic.

I don't know if it should be added here or with the asymmetric stuff.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should probably be with the asymmetric stuff, since quantum computing only really affects that because it's good against the descrete logarithm which asymmetric crypto relies on. Symmetric crypto and hashing stays relatively untouched by it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leios There are also several basic assumptions that modern cryptography relies on (if you multiply two large primes, it's hard to get the original primes back out) which other quantum computing techniques (carefully sculpted waveforms + observation) could invalidate, but it's unknown if they will yet. That's... probably too much detail for an introductory thing on crypto in general, though; maybe a linked chapter on quantum-resistant crypto?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would settle for a small post quantum crypto chapter in which we explain the problems and how they are delt with. Though I agree that this would exceed the "Intro to crypto" part of the chapter

## Symmetric Cryptography

Symmetric cryptography is called symmetric because the key that is used is the same for encrypting and decrypting.
For this to work Alice and Bob both need the same key, which they have to share before communicating.
Some examples for symmetric cryptography are:
* **Ceasar Cipher**: Alice and Bob rotate the alphabet by $$n$$ characters and use that as a table to encode and decode their message.
* **Rot13**: This is a special case of the Caeser Cipher where the alphabet is rotated by 13, hence the name "Rot13."
* **Permutation Cipher**: Here you choose a permutation $$\pi$$ (i.e. $$\pi=(3,1,2,4)$$) and reorder the the letters according to that $$\pi$$ which is the key.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pi may well be the variable typically used for the permutation, but for clarity's sake, we should probably call it p or something less likely to be confused for 3.14159...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i was going with what i learned at uni and since the AAA is a pretty scientific collection in general i'd say pi is fine here

* **XOR encryption**: This method works on bitstrings and combines the message with a second message of equal length with a XOR operator.
To decrypt, simply XOR again with the same second message.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"second message" should probably be "key", for consistency.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed

* **DES or Data Encryption Standard**: This is a newer encryption algorithm which was standardized in 1977.
It has since been deemed unsecure and is superseded by AES.
* **AES or Advanced Encryption Standard**: The actual algorithm is called "Rijndael".
Like with XOR or DES you generate a bit string (depending on which AES you use 128/192 or 256 bit long) which is your key.
* **Blowfish**: This algorithm also was a good contender for the AES but lost to Rijndael.

This section is currently a work-in-progress, and all of these methods will have corresponding chapters in the near future.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to also add some citations here? just add {{ "thing" | cite}} and

### Bibliography

{% references %} {% endreferences %}

at the end. Be sure to add the citations to literature.bib


leios marked this conversation as resolved.
Show resolved Hide resolved
## Asymmetric Cryptography

Asymmetric cryptography is sometimes called "public key cryptography" because Bob and Alice both need a shared public key and a private key they keep to themselves.
This makes these algorithms asymmetric because what is encrypted with the public key can only be decrypted with the private key and vice versa.
This can be used for a number of different applications, like digital signing, encrypted communication or secretly sharing keys.
For example, if Alice wants to send a message to Bob and Bob wants to make sure the message from Alice was not altered, Alice can encrypt the message with her private key.
If the message is altered (possibly by Charlie), then the message can no longer be decrypted with Alice's public key.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also add a sentence about how, without Alice's private key, Eve can't make a message which could be decrypted with Alice's public key.

Some examples for public key cryptography:
* **RSA**: This algorithm calculates a public and a private key from two very large primes. It is (hopefully) near impossible to factor the product of two such primes in a feasable amount of time.
* **ECC or Elliptic-curve cryptography**: Here you calulate the private and public key from two points on an elliptic curve. This has the positive side effect that you need smaller numbers than non-ECC algorithms like RSA to achieve the same level of security.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like before, a few references would be nice

This section is currently a work-in-progress. These methods will also have corresponding chapters in the near future.
4 changes: 4 additions & 0 deletions redirects.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@
{
"from": "chapters/QI/QI.html",
"to": "contents/quantum_information/quantum_information.html"
},
{
"from": "chapters/cryptography/cryptography.html",
"to": "contents/cryptography/cryptography.html"
}
]
}