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 8 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
3 changes: 3 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,7 @@ Max Weinstein
<br>
Gibus Wearing Brony
<br>
Julian
<br>
Arun Sahadeo
<br>
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)
53 changes: 53 additions & 0 deletions contents/cryptography/cryptography.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Cryptography

For a long time humans wanted to send secret messages that only the reciever understands.
The first encryption algorithms go back to the ancient greeks and romans.
Copy link
Member

Choose a reason for hiding this comment

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

A bit clunky. Maybe something like:

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).

One of the most well known encryptions is the so called "Caeser Cipher" which was supposedly used by Julius Caeser.
Copy link
Member

Choose a reason for hiding this comment

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

Unsurprisingly, one of the first methods of encryption was supposedly developed by Julius Caeser and called the "Caesar Cipher."
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.
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.

The Caesar cipher obviously needs it's own chapter, so we'll link to that when it exists.

In general there are two different principle of encryption, symmetric and asymmetric encryption.
Copy link
Member

Choose a reason for hiding this comment

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

This sentence seems out of place. You mention these two methods, but don't talk about what they are until later. It' might be better to move this to the bottom.

To explain the two principles I have to introduce you to two people. Enter Alice and Bob.
These two names are very common when reading about cryptography.
A third and (usually) evil person is also needed and that person is called Charlie.
The way these three people are set up are so that Alice and Bob want to exchange messages without Charlie knowing what they said.
Copy link
Member

Choose a reason for hiding this comment

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

This paragraph is rather long. Maybe something like:

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).
These names are consistent even with quantum cryptography, so they are here to stay.


Copy link
Member

Choose a reason for hiding this comment

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

We need to connect to the next section. I think it flows better to talk about the different types of encryption before talking about the general principles... Simply because the the general principles section also provides advice.

I would maybe add the sentence from above here:

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

## General principles of Cryptography
Copy link
Member

Choose a reason for hiding this comment

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

Capitalize the p

Copy link
Member

Choose a reason for hiding this comment

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

I don't know if I understand this section. It seems to be talking about implementation details for creating your own cryptographic system, but that is beyond the scope of the AAA. We care about the algorithms, but not about protecting someone from an attack.

Maybe we should say something like:

Cryptographic systems are a cornerstone to modern information technology and lie at the heart of everything from WiFi passwords to bank passwords.
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:

From here, I don't know what to add, though. I kinda feel this section should be removed, as none of the following points seem relevant.


* Don't underestimate the attacker.
This is important because you don't know what resources an attacker has.
It is always better to assume that they have a considerable amount of knowledge and computing power of the current global computing power.
* If you devise a new algorithm let a cryptanalyst meassure a robustness of your algorithm.
Do *NOT* claim it is strong (unless you have the knowledge and proofs needed) without talking to a specialist because only they, if at all, should be able to determine whether the algorithm is good or not since cryptography and security go hand in hand.
* 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.
* Adding complications don't necessarily make the algorithm better or safer.
* Always account for wrong design, implementation and usage of cryptosystems.
A good example for a wrong implementation is WPA2 (the algorithm which encrypts WiFi traffic). This algorithm was mathematically proven to be safe yet an error in the implementaion allowed for the "Krack" attack.

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 way you encrypt a message is the same as the way to decrypt a message.
Copy link
Member

Choose a reason for hiding this comment

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

A bit clunky because of using "symmetric" too much.

With symmetric encryption, the encoding and decoding methods are the same, similar to the Caesar cipher above.

Copy link
Author

Choose a reason for hiding this comment

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

Okay after reading through that sentence again I realized that this sentence isn't actually correct. The thing that is the same is the key not the encryption/decryption method.

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:
* The afore mentioned Caeser Cipher. Here Alice and Bob have to know the rotation of the alphabet which is the key in this algorithm.
Copy link
Member

Choose a reason for hiding this comment

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

remove "The afore mentioned" so it fits with the rest of the items on the list.

maybe change the formatting of all items to:

Ceasar Cipher: Alice and Bob rotate the alphabet by $$n$$ characters and use that as a table to encode and decode their message.

* Rot13 is a special case of the Caeser Cipher. The alphabet gets rotated by 13 (that is why it's called Rot13) so it would be Caeser with the key of 13.
Copy link
Member

Choose a reason for hiding this comment

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

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
Member

Choose a reason for hiding this comment

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

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.

* XOR encryption. Here you generate a bit string which is exactly as long as the message you want to encrypt and just XOR them together.
Copy link
Member

Choose a reason for hiding this comment

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

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.

* 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.

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 public and a private key of which they only share the public key.
Copy link
Member

Choose a reason for hiding this comment

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

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 has numerous fields of application. It is not only used for encrypting messages, but also for digital signing.
Copy link
Member

Choose a reason for hiding this comment

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

Clunky

This can be used for a number of different applications, like digital signing (add more)

Add a newline here to start a new paragraph.

You wrote "numerous," so there are probably a few more examples to add.

Digital signing is used to make sure that the recieved message actually originates from the person who claims to have written it and you can also make sure nothing got altered.
Copy link
Member

Choose a reason for hiding this comment

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

This can probably be removed?

So for example Alice wants to send a message to Bob and Bob wants to make sure the message is actually from Alice and arrived the way it was send out.
For that Alice encrypts the message with her private key.
This is *NOT* so that Charlie can't read the message, since both Bob and Charlie have Alices private key.
What both of them don't have is the private key.
So Charlie can't decrypt, alter and encrypt the message again without Bob noticing it, because it wouldn't decrypt anymore with Alices public key.
Copy link
Member

Choose a reason for hiding this comment

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

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.

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.

Both of these should be changed to the other format:

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.

At the end of this section, we need to mention the same thing as above:

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"
}
]
}