Saturday 31 October 2015

Learning Languages

Prerequisite: none

My incentive for learning languages is not for conversation (me conversing with a stranger? What a joke!) but for the linguistics. For the sake of language itself. The way it is and its relation to other languages. As of now I know Chinese and English very well, and minimal Japanese, Dutch, Italian, Irish, Turkish, and maybe some Thai.

And also for curiosity. What is masculine or feminine noun? A gender or neuter noun? What are cases? When to use which cases? What is an agglutinative language? An eclipsis? A lenition? Go find out!

Duolingo

Great site to proceed at your own pace. What I like most about it is the convenience of definitions and audio. The interface design is very simple and there are many languages available. And why not, it is completely free. Completely free of additional purchases.

Readlang

The web browser feature similar to Google Translate but waaaaay better. You can read a page in foreign language and click on words you do not know for its definition. No need to flip the dictionary a billion times.

Invest in a language now~

Saturday 24 October 2015

Fermat's Last Theorem

Prerequisite: as much math as possible

Somewhere in a copy of Diophantus' Arithmetica, Fermat jotted down this. Fermat’s Last Theorem:

There is no whole number solution to xn + yn = zn, where n > 2

Brilliant. Except that he never passed down a proof:

“I have a truly marvelous demonstration of this proposition which this margin is too narrow to contain”

So he left mankind to suffer.

It does seem like a simple problem at first, until you realize that it actually represents an infinite amount of equations:

x3 + y3 = z3
x4 + y4 = z4
x5 + y5 = z5
...

and on and on..

Unfortunately, I do not have the mathematical knowledge to comprehend the proof. But even if I can, you probably cannot. Most people cannot. The official proof by Andrew Wiles is over a hundred pages long and contains advanced material (understatement). What I can do though, is break down the process qualitatively (and vaguely).

Pierre de Fermat

contribution: proof for n = 4 (and therefore 8, 12, 16..)
method: infinite descent (on the equation x4 + y4 = z2)

Infinite descent is a form of proof by contradiction. It first assumes the opposite to be true (that there is a solution), then feeds the hypothetical solution into a recursion. There appears to be infinitely many smaller solutions which cannot be true, since there are finitely many whole numbers in the decreasing direction. This contradiction proves that there cannot be a solution.

All n in multiples of 4 are proven since they can all be written as powers of 4.

Leonard Euler

contribution: proof for n = 3 (and therefore 6, 9, 12..)
method: infinite descent involving imaginary numbers

The proof of n = 3 is essentially an adaptation of Fermat's proof for n = 4, except that several unknowns could be filled with imaginary numbers.

Sophie Germain

contribution: proof for n = Germain Prime (2, 3, 5..)
method: proof by contradiction

A Germain prime is a prime p such that (2p +1) is also prime. Assuming that there is a solution where n = Germain Prime, either x, y, or z is a multiple of n. This assumption restricts the solutions to none at all.

Yutaka Taniyama and Goro Shimura

contribution: Taniyama-Shimura Conjecture
method: comparing Dirichlet L-series of elliptic equations and modular forms

The E-series of a particular elliptic equation tells how many solutions there are using each clock arithmetic. There is an M-series for modular forms. When these mathematicians noticed that the series matched for certain elliptic equations and modular forms, they came up with the Taniyama-Shimura Conjecture:

For every elliptic equation, there is a modular form with the same Dirichlet L-series.

Basically: every elliptic equation has an equivalent modular form.

Gerhard Frey

contribution: correlate Fermat's Last Theorem with Taniyama-Shimura Conjecture
method: rearrange xn + yn = zn into elliptic equation

It so happens that the rearranged elliptic equation of xn + yn = zdoes not have a modular form.

If the Taniyama-Shimura Conjecture is true, then this rearranged elliptic equation should have a modular form, which it does not. Such an equation that does not have a modular form would not exist, and so this rearranged equation would not exist, and the original equation would not exist, and there would be no solution to the original equation. Then Fermat's Last Theorem would be true.

In summary: if the Taniyama-Shimura Conjecture is true, then Fermat's Last Theorem is true.

Andrew Wiles

contribution: the proof
method: proving the Taniyama-Shimura Conjecture with Galoisian group theory, Kolyvagin-Flach method, and Isawa theory

To tackle the Taniyama-Shimura Conjecture, one must handle an infinite amount of equations and their infinitely long series. Group theory allowed solutions to be condensed by common properties. As for the rest, I have no idea what is the Kolyvagin-Flach method or the Isawa theory.

Of course this post is an oversimplification. You may refer to http://fermatslasttheorem.blogspot.com/ if you like but personally, I had enough~

2 Corinthians 2:4

"For I wrote to you out of much affliction and anguish of heart and with many tears, not to cause you pain but to let you know the abundant love that I have for you".

This verse of Paul's gospel to the Corinthians just about clears up the common misconception of spreading gospels. It is not out of haughtiness or self importance that we spread Christianity. It is not for the sake of elevation or dominance. It is because we believe Christianity to be a necessity of life, and we want to save as many people as possible. It is anguishing to see people without Christ.

To be honest, the worst way I can curse someone is to prevent Christianity from reaching that person, and then hope that it will cause the person to burn in hell. This idea is so terribly evil, I do not wish it on anyone. It takes a lot of hatred to withhold Christianity from someone. Paradoxical?

And what about the people who harness Christianity for power? Of course there are such rotten people. But anyone can take the Christianity label and attach it to the front of their shirt. The word "Christian" gets thrown around too much. Who is or is not a Christian is not for people to judge. It is not for me to judge either. But I know for a fact selfish intentions are discouraged in the Bible, and that abusive power is not at all Christian-like.

Okay, even with good intentions, how does that make it okay to force the gospel on anyone? Are we not all entitled to making our own decisions? Consider a parent and a child. You want your child to have choices, yet you want your child to make the right decisions, even if disagreement makes your relationship go awry. If you really cared about these people, you would do your very best to make sure these people accept the right decision. In this case, the ticket to heaven (as well as the ticket out of hell, if that makes Christ any more desirable).

Then there are the various degrees in which people try. There are those who nag like a mother. Then there are those who utilize brutal force. The ones you probably want to ask about are the violent ones. Do they not demonstrate anger from religion? I suppose "anger" is not the best word. "Frustration" is more fitting. The day everyone stops fighting will be the day everyone no longer cares about each other. Not that this justifies such behavior, but life is full of paradoxes.

At least you now know that someone cares about you. When that person stops nagging you, that is when you should be worried.

But the most important question you want answered is: how do we know that Christ is indeed the ticket to heaven? First consider Fermat's Last Theorem. It is complicated enough in itself. There are relatively simpler ways to explain the theorem's proof, but if you must chase every step of logic it takes more than one hundred pages of hardcore mathematics to prove it (understatement).

Then consider God. God is immeeeeense. If you must know the details to the proof of God, you actually have a better chance understanding the proof of Fermat's Last Theorem. So nobody has proven God huh? In this particular context, not a proof that I know of. But people were not too daft after all for believing in Fermat's Last Theorem, which turns out to be true. Am I too daft for believing in God?

I will not deny that I secretly (not so secretly anymore) hope for people to change their minds from reading my posts, but only because I believe that people need Christ. It is not as if I get recognition for converting my readers. My name is not splashed all over this blog. Not that I even have followers. But I do hope that this gets to the meager readers that I have.

Know that just as how Paul wrote to Corinth, I write to you out of much affliction and anguish of heart and with many tears, not to cause you pain but to let you know the abundant love that I have for you.

Wednesday 21 October 2015

Language Decryption

Followup of Code Decryption

Prerequisite: none

The Code Book by Simon Singh has a nice chapter on cracking ancient languages.


People first assumed that hieroglyphs were semantic pictographs and ideographs, and nothing more. No one bothered to challenge the assumption since the Ancient Egyptians were supposedly too "primitive" to come up with a phonetic system.

Then Rosetta Stone came around which contained hieroglyphs, demotic, and Greek on one slab, making a convenient crib, except that the Ancient Egyptian language has not been spoken for centuries. When Thomas Young spotted a cartouche on the Rosetta Stone, he suspected that it signified a pharaoh's name and that hieroglyphs might actually be phonetic.


He considered the historical context of several artifacts and associated names with cartouches. He could then deduce the sound values of each character. But his idea died down when he convinced himself that the alphabet was only applied to foreign names. Even with a collection of sounds, it did not seem to make meaning in regular text. At least, it made no sense to him..


Jean-François Champollion came across a cartouche. He figured that the the repeated letters are probably the repeated "s" in "Ramses". Being fluent in Coptic, he further suspected that the circumpunct reads "ra" as a rebus image.


And it worked. Ramses. After much substitution, it turns out the Egyptian hieroglyphs represented an ancestor of the Coptic language where some characters are phonetic and some are semantic. When Champollion traveled to Egypt he could really read hieroglyphs. Read-read hieroglyphs. Read. Hieroglyphs.


The Linear B tablet was found on Crete so the first speculation was that it is in Greek. But many Greek words end in "s", and the lack of a common last letter refutes that. Since the consensus was that the tablet contained a lost Minoan language, there was not much deciphering effort.


Alice Kober noted that there are around 100 characters, too much to be alphabetic and too few to be logographic, which makes it syllabic. She also noticed commonly occurring root words and suffixes, indicating an inflective language. It allowed her to associate syllables with the same consonants. Take Japanese as an example (except that Linear B had longer root words):

かく --> かきます
kaku      kakimasu
よむ --> よみます
yomu     yomimasu
つくる --> つくります
tsukuru      tsukurimasu
あぶ --> あびます
abu        abimasu
ぬぐ --> ぬぎます
nugu      nugimasu

Kober did the same analysis and grouped the Linear B characters by consonant, although she did not know what the consonants were.

Michael Ventris examined Kober's work and considered the geographical context of the tablet. He associated a regularly appearing word with "Knossos" and used it as a crib to identify other words such as "Pylos". Soon, he had enough cribs to substitute most of the text and fill in the gaps himself. The text was indeed in Greek, although there were some words he could not recognize. John Chadwick further identified the language as a kind of Archaic Greek. The ending "s" was dropped as a convention.

Saturday 17 October 2015

Proverbs 3:5

"Trust in the Lord with all your heart,
and do not lean on your own understanding".

How blind is that, to accept something without questioning? For someone like me going into the science major this sounds like the worst advice ever. But I must say, there is some profound truth behind this.

First of all this verse does not specifically tell us not to question. We can doubt all we like, as long as we get the deed done. God likes to save the Q and A for later. Is it not the same with a lecture? Your question just might be answered before you ask it. Just listen and follow along, and everything will come clear at the end.

There is a common question among us all: why cannot God be clear and straightforward? Why the ambiguity? Why are there so many leaps of faith that require trust? If God could explain everything thoroughly, there would be no need to "trust in the Lord with all your heart". Is it too hard to do even that? There are two ways you can look at this:

1) Actually, if God were to unleash everything it would be too hard for us mortals to understand. Would God still be God if our understanding equalled His? Of course God is difficult to understand. The Bible is difficult to understand. Rather than spend an eternity comprehending, it is simpler to trust. God will let you know what you need to know.

2) If one were to know beforehand the terrible consequences of each and every way that is not God's way, one would complain "that leaves me no choice!". Is freedom not all the rage these days? We complain that God is too ambiguous, but if He were to constantly walk someone through life, it would make the average person flip. Where is my freedom? To keep us fretful mortals complacent it is much easier to not elaborate too much, and let us exercise our trust.

This is why He says: "Do this. Trust me. Your choice". At least, some reasons I can think of.

The bigger question for most people is: why trust God? Of all things, why something less tangible than thin air? Why God? If one must know, the only way is to get to know God Himself. I dare say I am only just getting to know Him even after all these years. I may be a fool for trusting God, but I would be a greater fool for trusting myself.

Then why is it wrong to rely on logic? It is only wrong when it is the only thing you rely on. But then why not, is science not all about logic and reasoning? Oh dear mortals, the wisest of you, from Confucius to Shakespeare, know themselves to be fools! We can have all the knowledge in the world but not have wisdom. Do you consider your wisdom superior to that of the Creator's? Do you make a decision because you trust God, or because you trust yourself? Once you think that you know everything, you will have made your worst mistake.

Maybe you are still doubtful and think me a fool. I have my doubts too, otherwise I must be some magical sage. God is as paradoxial as the world He has created, which our understanding fails at paradoxes. I cannot really answer why I would rather trust an invisible man in the sky than try to untangle a paradox. It only comes down to what you know about God. If God were a stranger to me, I would not understand why I should trust Him. I imagine it is the same for everyone.

If you insist on knowing why you should trust God, the best way is to get to know Him personally. And the best way to know God is to seek Him.

Infinite

With the addition of another category, this blog just about sums up my life.

The Blue Giraffe and I have discussed on this category for a while now. We felt reluctant to share this content as it is understandably unfavourable to most people. But it is a central piece to the adventures of me and the Blue Giraffe, in fact more personal than the introspective category. It is what I feel matters the most. It is the things that I really ought to tell someone about.

The new category is infinite. It is the things I will never stop pursuing. One day I may stop informing, inspiring, instructing, introspecting, interluding, or even introducing.. but what is infinite will stay with me forever.

Break In

First find out about introspective.

through this fortification
a tessellation of anxiety
a defence against itself
the heart invaded after nightfall
frightening echoes
worst fears confirmed
penetrating to the very core
of confidentiality
of buried shame
in fact a liberator
the heart mended before sunrise
gentle words
make me whole
reassembling the broken pieces
of grace
of forgotten charm
in truth a scalpel
remove all festers
dislodge all burdens
rebuild this internal kingdom
so that no other mortal
breaks in

The Imagery

Overnight invasion on a castle.
Healing.
Rebuilding the damage.

The Content

Not that anyone has dug me up in such a way before. But I wish very much that someone would. But I wish even more that no one would. Which is why no one has. Which is why the walls are even there in the first place.

I have not considered why that is. The first half is unwilling to let anyone in, and the second half is relieved that someone came around. Indeed, why? Because two cannot keep a secret? Because I have trust issues? Maybe it has something to do with my evilness (refer to Aşk).

The most likely reason is probably that I do not communicate clearly enough. Or quickly enough. For clarity I must compensate with speed, and for speed with clarity, so I can never have both. And people are usually not patient enough to wait half an hour before I finally string the right words together. Not that I expect anyone to. That would be insane.

So I fabricated the second half? Ya, I pretty much did. I imagine that the treatment would hurt at first, but that it would be liberating in a way I have never known.

At the very end I specify "mortals" since God is always allowed in. Always allowed.

Friday 16 October 2015

Aşk

First find out about introspective.

suspended over the lake
a torn penumbra
lingering lost
hunched towards the depths
where untold fears
gloomily gaze back
through the opaque veil
a subconsciousness that abhors
warmth and illumination
and so hides in the dark deep
chasing shades
all things bright and beautiful
flit overhead
while the swan
on the blurry waterline
stranded on the edge
of submergence
and flight
of hatred
and love

The Imagery

Swan on a lake.
Birds in bright skies.
Creatures in dark waters.

The Content

If you have read the introspective post and considered the last line of this piece, you can deduce that "aşk" means "love". It is, and it is in fact Turkish.

This is one of my heavier entries. The mood is indeed gloomy. It is about choosing between right and wrong. I find it interesting that I focus more on the darker side than the brighter side. It seems that I am very conscious about keeping corruption at bay.

People have no idea how evil I can be deep down. I know about it, and yet I cannot get rid of it. Some days I feel optimistic about the battle, but other days I just want to be the meanest, most selfish, unforgiving person.

All this is pretty dark for a piece titled "love". Maybe for me the meaning of love is to overcome all that. That is what makes love so great. To love without overcoming hatred is no feat, whereas loving despite the hatred is the epitome of love.

Wednesday 14 October 2015

Quantum Cryptography


Prerequisite: physics

Modular functions seems impregnable enough but cryptographer just had to take it one step further, harnessing the random unpredictability of light polarization.

Photons can travel as transverse waves. What a polaroid does is filter out waves that oscillate in other directions. Some polaroids allow many oscillation directions while in this diagram below, the polaroid filters out all light waves except ones that oscillate vertically.. but not really.


Diagonal waves have a 50% chance of passing the filter and becoming vertical at the other side, according to Schrödinger's concept of superposition. Another key feature is that one cannot directly observe the polarization of photons due to Heisenberg's uncertainty principle, but one knows for sure the polarization of photons that come after a polaroid.

Let the madness begin.

As a setup for an example of quantum cryptography:

Message is translated into binary.
For the sake of simplicity, assume four possible wave polarizations.
Vertical ( | ) and horizontal ( - ) waves can pass through rectilinear polaroids (+).
Diagonal waves ( / and \ ) can pass through diagonal polaroids (x).
( | ) and ( / ) represents 1.
( - ) and ( \ ) represents 0.

Alice wants to send a key to Bob, and comes up with a pre-key 10011011.
She sets a scheme of randomly alternating polaroids +x++xx+x, then sends polarized photons ( | \ - | / \ | / ) through specific |, -, /, and \ polaroids to Bob, accordingly with her scheme.

A summary of Alice's transmission:

pre-key:         1 0 0 1 1 0 1 1
scheme:         + x + + x x + x
polarization:   | \  -  |   / \   |  /

(The only way to detect the polarization of a photon is by trial and error, where there is only one trial. Eve cannot possibly guess which polaroid to use for an upcoming photon, and using the wrong one will either block out or repolarize a photon, neither of which are desired. She cannot even deduce whether she used the correct polaroid or not, since a photon entering an incorrect polaroid has a 50% chance of getting through. Tampering with the photons with polaroids can also reveal Eve's act of eavesdropping).

Bob on the other end tries to receive the photons with a random polaroid scheme of his own.
Alice and Bob then identify where they used the same scheme, which is also where they both know the correct polarizations, and the resulting fragmented sequence can be used to generate their key (1110 in this example):

pre-key:                     1 0 0 1 1 0 1 1
Alice's scheme:         + x + + x x + x
polarization:               | \  -  |   / \   |  /
Bob's scheme:           + + x + x x x +
filtered scheme:        +        + x x
key:                           1        1 1 0

Eve can overhear what schemes they filtered out, but she cannot know what Bob correctly observed, which is essentially the key. The only way for Eve to know the key is to use the exact same scheme as Bob, which is highly improbable when the key is extremely long.

The incorporation of photons started with Charles Bennett's idea of quantum foolproof money. Last time I checked, a quantum key was successfully exchanged over one kilometer.

Oh dear mortals, what next?

Monday 12 October 2015

Modular Functions in Encryption

Followup of Code Decryption

Prerequisite: algebra

The toughest of ciphers in Code Decipherment are not impregnable, because algorithms can be thought of as a function. No matter how complex the procedure, the systematic nature gives it away and like algebra, functions can be worked backwards.

Another problem is with key distribution. For the recipient to be able to decrypt a message, the recipient must have the key as well. This is particularly significant to digital communications where the key cannot simply be handed over in person (which defeats the purpose of digital communication!). To send the key digitally requires another key to secure the first key, and another for the second.. like an infinite Matryoshka doll. No way.

The thing to do then, is to 1) find an irreversible function and 2) find a way to decrypt a message without exchanging keys.

The breakthrough idea was formed separately first by James Ellis, Clifford Cocks, and Malcolm Williamson, then Whitfield Diffie, Martin Hellman, Ralph Merkle, Ronald Rivest, Adi Shamir, and Leonard Adleman. The concept can be described with the following analogy:

Alice is trying to send a message to Bob while Eve is eavesdropping.
Alice puts her message in a box.
Alice puts lock A on the box using key A, which she keeps secret.
Alice sends the box to Bob.
Eve cannot open the lock A on the box.
Bob puts another lock B on the box using another key B, which he keeps secret.
Bob sends the box back to Alice.
Eve cannot open lock A and B on the box.
Alice unlocks lock A using key A
Alice sends the box back to Bob.
Eve cannot open lock B on the box.
Bob unlocks lock B using key B.
Bob opens the box and reads Alice's message!

This solves the key distribution problem since no keys are exchanged, but it requires the function to be commutative as well as irreversible. So what kind of function fits the description?

The modular function~

There are two ways to understand it. One is to think of it as a clock. 12 (mod 7) = 5 would be 12 jumps around a 7 hour clock, landing at 5. Another way is to take 12 divided by 7, then state the remainder 5.


The following example applies modular functions not as an algorithm of the message itself, but as the algorithm to exchanging keys.. without exchanging keys:

Alice and Bob agree on a the function 3^x (mod 7) = y.
Eve overhears this function.
Alice chooses 6 as her key A, solves 3^(6) (mod 7) = 1, and reports the answer "1" to Bob.
Bob chooses 10 as his key B, solves 3^(10) (mod 7) = 4, and reports the answer "4" to Alice.
Eve overhears the exchange "1" and "4" but cannot reverse them with the function or do anything.
Alice solves B^A (mod 7), which (4)^(6) (mod 7) = 1.
Bob solves A^B (mod 7), which (1)^(10) (mod 7) = 1.
And so "1" is the agreed key for their message!
(I should have chosen better numbers where in reality the numbers are veeeeeeery large and do not coincide)

One may reverse the function through rigorous trial and error, but it is simply too exhausting when the key can reach astronomical lengths. The way to encrypt messages directly is as follows:

Alice choose two veeeeery laaaaarge prime numbers p and q, which she keeps secret.
Alice multiplies the two numbers to get N, and picks another number n. These two numbers she announces as a public key.
Bob wants to send Alice the letter "B", which he has to digitize first with ASCII binary digits or something.
Bob uses Alice's public keys to encrypt his letter "B" with the formula B^n (mod N) = C, solves for C, and sends it to Alice.
Eve overhears the message C but cannot do anything with it, not even with Alice's public keys since modular functions are not reversible.
Alice solves for a private decryption key d with the formula nd = 1 (mod (p-1)(q-1)) using Euclid's Algorithm (whatever that is).
Alice then deciphers Bob's message with the formula C^d (mod N) = B to get B.

It only gets crazier when you cross cryptography with physics. Just you wait. Be prepared to encounter some photons in a followup post..

Code Decryption

Prerequisite: algebra

Been reading The Code Book: The Science of Secrecy from Ancient Egypt to Quantum Cryptography by Simon Singh. It is a very fascinating read between history, cryptography, and linguistics. In this post I compile some deciphering techniques. Some are simple while others are pure genius. But first, some terminology.

plaintext: original message (notated in lowercase)
ciphertext: enciphered message (notated in capitals)
algorithm: the method of enciphering a message
key: the premise of an enciphering method


A person needs to know both the algorithm and the key in order to decipher a ciphertext. But in many cases, the algorithm is obvious and the key can be traced from it.

Alphabetic Substitution

This is the simplest of algorithms where the alphabet is scrambled up to make a cipheralphabet. A good knowledge of English (or whatever the plaintext is written in) is enough to crack the ciphertext.

If a lone alphabet appears commonly throughout a ciphertext, one can deduce that is either "a" or "i". Similarly, a recurrence of a three letter cipherword is probably "and" or "the". If there is no vowel in a four letter cluster, one of the letters is probably a "y". The letter after the "q" must be a "u". If the spaces are eliminated, one can still guess common suffixes for a start. Lingual rules provide many handholds to decipherment.

Know your spelling rules, substitute what you can, and play a little hangman until you get the whole plaintext. That was how I cracked the Gnommish Alphabet in the Artemis Fowl series back in seventh grade.

Caesar Shift

Actually I lied. The Caesar Shift is even simpler. It shifts the alphabet several places, then uses it as the cipheralphabet. The number of shifts is agreed with the recipient beforehand.


This encipherment was used for extremely short messages, such as one phrase. There are not enough clues to reason with, but this is still a weak cipher considering that one only needs to test twenty six cipheralphabets at most to reach the plaintext. If that sounds like a lot of work to you, read on. You will much rather confront a Caesar Shift.

Vigenère Cipher

"The Indecipherable Cipher" utilizes the Vigenère Square, which is essentially all possible Caesar Shifts lined systematically to make a square:


What happens is that the sender and receiver agree on a keyword, such as "BLUE". To encipher a message, the first letter would be enciphered with the Caesar Shift starting with "B", the second letter with the shift starting with "L", the third with the shift starting with "U", the fourth with "E", and the fifth with "B" again. So the message "pig is hungry" enciphered with the keyword "BLUE" will be "QTAMTSORHCS".

B L U E B L U E B L U
p  i  g  i  s  h u n g  r  y
Q T A MT S O RH C S

This enciphering technique is a polyalphabetic cipher, which alternates between more than one cipheralphabet. This makes it harder to pick out letters by frequency as opposed to a monoalphabetic cipher, where you can almost guess correctly that the most common cipherletter probably represents the plainletter "e".

Charles Babbage figured that frequency analysis plays a big role concerning the nature of Caesar Shifts in the Vigenère Cipher. Arabs first came up with frequency analysis, the association of cipherletters with plainletters by occurrence. What happens is you get an graph describing the frequency distribution of alphabets in a language..


..then compare it to the frequency distribution of cipherletters in your ciphertext (similarly can be done with Zipf's Law for whole words). Match corresponding frequencies of letters and cipherletters, substitute, do some tweaking, and you should have the plaintext. This technique is not particularly significant for general Alphabetic Substitution since logical reasoning is enough to crack the cipher, but it gives a handhold in Vigenère decipherment.

Homophonic Cipher

The previous ciphers were especially vulnerable to letter frequencies. To make up for that, the homophonic cipher uses numbers as the cipheralphabet, and adds more cipherletters to even out the frequencies. Each cipherletter should appear just as often as another.


It takes much more thought to crack this cipher, but it is still possible. One can consider spelling rules, estimate the amount of extra cipherletters for each plainletter, and take both into account. There is much more trial and error, but it is not such a horror compared to the next cipher..

The Enigma

This is where encryption escalates quickly. Why read my words when you can see for yourself? This video on the Enigma Machine tells what you need to know.

Hooooo, what is this monster? From left to right, the machine components are lamp letters, keyboard, plugboard, first scrambler, second scrambler, third scrambler, and reflector. If you trace this diagram carefully, hitting the "C" key gives the output "F".


The Germans with their Enigma Machines changed their agreed scrambler setting everyday in order to securely encipher the scrambler setting of their actual messages. So a person receiving a message would set their Enigma Machine to the agreed day setting, decipher the new scrambler setting, set to the new setting, and then proceed to decipher the actual message. The plugboard setting stays the same.

The Machine is the algorithm and the scrambler setting is the key. The key is six letters long, where the first three are the starting letters of the scramblers and the last three is a repetition. The key in plaintext "pigpig" may be enciphered as "GXWLDN".

To obtain the key, Marian Rejewski cleverly mapped out the chains of letter relations. He analyzed numerous keys of one day setting and paired up the first and fourth letters of each six letter key, since they are repetitions of each other. A relation for A, B, C, D, E, and F can be:

A B C D E F
D A F E B C

Then he organized this relation into chains. In this example there are two separate chains:

four links: A --> D --> E --> B --> A
two links: C --> F --> C

The significance of this organization is that the plugboard cannot interfere with the amount of chains or links, so that it is useful for cracking the scrambler setting. Instead of finding one key among ten thousand million million keys, he had only 105,456 possible chain-link characteristics to consider. And then there was the manual labour of recording the number of chains and links for each scrambler setting, but they did it. It took a year.

When the Germans found out about their flaw they stopped repeating their keys. To find the key, Alan Turing used Rejewski's idea on cribs. A crib is a ciphertext in which you know its plaintext as well, which in their case had to be guessed. A common crib that the Germans provided was "weather" (or "wetter" in German) in their weather reports.

Then he had to figure some plugboard settings as well. The trial and error went something like this:

He had some data based on a crib.
Given that ciphertext "A" is plaintext "b",
assume that "A" is connected to "S" on plugboard.

A --> plugboard --> S --> scramblers --> ? --> plugboard --> b
A --> plugboard --> S --> scramblers --> F --> plugboard --> b

So he joined "A" to "S" on the plugboard, then saw which letter lighted up. If "b" lighted up, it shows that "b" is not connected to any letter on the plugboard. If "F" lighted up, which he knew should be "b", he then assumed that "F" is connected to "b".

All that is good, but what happens when there is a contradiction? Say, three letters seem to be plugged to each other. Yes, those would be incorrect deductions from an incorrect assumption. To turn mistakes into an advantage, Turing realized that all these incorrect deductions are definitely incorrect, and do not need to be tested further. I am still trying to get my head around this one.

And he threw these testings into a bombe.


For more historical context alongside the logic, you ought to read The Code Book. It is pleasant for leisure as well as for study. If this article makes you insecure about your internet privacy, I have another post coming up that will calm your nerves. Wait for it~