Simple Explanations

On this page I collect intuitive explanations of something that appeared complicated to me and I didn't understand immediately.

How RSA works

"you can take a number [representing original text], multiply it by itself a number of times to get a random-looking number [the cyphered text], and then multiply that number by itself a secret number of times to get back to the original number."

from: http://arstechnica.com/security/2013/10/a-relatively-easy-to-understand-primer-on-elliptic-curve-cryptography/

How OTP works

The basic idea is that in the sequence of generated OTP codes, the current code happens to be the hash of the next code. The server saves last seen code in the database in order to match it against the hash of the next code. If a hacker steals the data in the database, he will only know the hash of the next code, not the actual next code.

The robustness feature comes from the fact if user skips a code and sends the next-next code, then by applying the hash function twice to the received code, sever can match it with what is in the database.

Reference: http://tnlandforms.us/cns06/lamport.pdf

Diffie-Hellman exchange of a secret key

Diffie-Hellman exchange allows two sides to agree on a shared secret using which they can encrypt all their further communication. The main idea is math identity (g^a)^b = (g^b)^a (mod p). Here a and b are private keys, but instead of sending them, g^a and g^b are communicated to the other side. This way the private keys are never exposed, but both sides can compute shared secret K = g^a^b (mod p).

Also, if it so happens that the two computations yielded different values K1 and K2, that means that there is a man-in-the-middle (MITM) attack! A man in the middle would have to also use a Diffie-Hellman exchange with each of the sides, but he would have to pick his own private keys c1 and c2, yielding K1=g^a^c1 for one side, and K2=g^b^c2 for the other.

To verify the key, people would have to use an outside communication channel, like a phone call. On a call, however, it is hard to read a long key, and it is also hard to read its fingerprint (a hash of the key) because it is still too long. Of course, a hash can be made as short as possible, but then there's a chance that two different keys will hash to the same value, and the MITM will not be detected. To arrange for this, a MITM would have to carefully choose c1 and c2 with such a property, that short-hash(K1) = short-hash(K2).

In order to allow for a shorter hash anyway (called SAS for Short Authentication String), an additional step is used in the protocol, called a "commit". Before sending g^a, that side first sends T = hash(g^a). If the MITM relays it as is, and later sends g^c2, then the receiving side will see that T and hash(g^c2) are different. Therefore, the MITM will send T = hash(g^c2). But he doesn't know how to choose "c2" so that the resulting SAS will be the same, because he doesn't know g^a yet. He has to pick a random "c2" and hope that the SAS will be the same. If the SAS is just 4 hex digits, that's the probably of 1/65536 to guess it right. The only alternative way for him would be to collide hash(g^a): this means that he has to find g^c2, such that hash(g^c2) = hash(g^a). If the exchange is expected to happen under say 10 seconds, the attacker would need tremendous resources to find such a collision in such a short time.

Reference: http://mathworld.wolfram.com/Diffie-HellmanProtocol.html

Zero-Knowledge Proofs

This youtube video has a good explanation for what is a zero-knowledge proofs.

https://www.youtube.com/watch?v=0Sy6nb72gCk

I extracted just one example from the video, will describe it here quickly.

The diagram shows a tunnel through which Peggy (P) goes in, and Victor (V) observes her. In the middle of the tunnel there is a door, which opens with a secret password. Peggy wants to prove to Victor that she knows this password, but without revealing the password itself.

Victor observes Peggy going into the tunnel, but doesn't know which path A or B she takes. He then enters the tunnel, and calls loudly for either path A or B. Let's say he called for path B, and Peggy indeed came out from B side. This experiment alone doesn't prove anything to Victor, because Peggy may have taken path B in the first place. But, if this scenario is repeated many times, and Peggy always comes out on the side that Victor calls for, then Victor gets convinced with a high probability that Peggy crosses through the door.

Observe that if Victor records everything he sees with a video camera, the video will not prove to someone else that Peggy knows the password. The reason is: Victor and Peggy may have colluded to record a movie so that Peggy always knows which side Bob will call for. This where the name Zero-Knowledge derives from, because an outside observer doesn't gain any new knowledge.

There should be many applications for this. One of them is Zcash, which is a crypto-currency layered on top of Bitcoin's Blockchain. It allows to hide who is sending the money. The Zero-Knowledge part proves that someone sent the money, but doesn't expose who to the public.

What is a Radian

Radians provide an analog for triangulation with circles rather than rectangles.

Triangulation allows to estimate the height HI of the big triangle if its base AI is known, by measuring the base AE and height DE of the small triangle.

Similarly, the arc of the big circle FG can be estimated if its radius AG is known, by measuring the arc BC of the small unit circle. The arc length of the smaller circle is the angle in radians.

How GPS works

A GPS receiver uses satellites orbiting the Earth to find out its own position. But, it doesn't send any signals to the satellites. (That would require too much power, and wouldn't work for small GPS chips.) So, how does it work? The satellites have precise clocks, and they emit a signal every second, at the same time. Your tiny GPS receiver expects to "hear" the signal from all satellites, but the signals don't arrive simultaneously. Why? Because the signals take time to travel, and those that come from closer satellites arrive first. From these delays the GPS receiver figures out its own position. That's because each delay represents the distance to a satellite. The satellites have predictable orbits, and their expected position is encoded in the GPS chip, as a table. Theoretically, three distances are enough to triangulate the location, but actually four are used. This is done to correct the error in the clock inside the GPS receiver. Unlike the clocks that are onboard the satellites that are very precise, the clock in your GPS device is off by a few milliseconds. Using 4 distances, it is possible to find the amount of this error, and adjust the clock by it.

Matrix determinant

A 2×2 matrix deforms space, so that a certain area becomes a larger (or smaller) area. The matrix determinant is the ratio of the new area to the old area. A 3×3 matrix deforms volume, so the determinant would be the ratio of the new volume to the old volume.

A negative sign in a determinant of a 2×2 matrix means that the transformation has flipped the area (e.g. swapped the x and y axis).

If a determinant of a 3×3 matrix is 0, it means that the volume is squashed into a flat surface, loosing one dimension and making the new “volume” 0. This kind of matrix is not invertible, because information was lost as a result of the transformation and the operation cannot be reversed.

Determinants of higher dimensional matrices are understood by extension.

https://towardsdatascience.com/what-really-is-a-matrix-determinant-89c09884164c

Electromagnetic Wave

When an electric charge moves along a wire, there is an electric field that follows it. In the image below the "+" denotes an electric charge that's traveling from left to right. If the voltage along the wire is suddenly increased, the charge accelerates and the field begins to lag behind. Notice the kink between the two circles. This kink starts to travel outward, just like a water wave.

In the next image below, we see two charges traveling towards each other. (This is called a dipole). The electric field between them would normally be convex, as shown by the orange line. But if they start accelerating towards each other, then the electric field lags behind and a kink arises. Now imagine that the two charges move up and down in a yo-yo oscillation pattern. When they meet midway, everything reverses, so the old kink travels out and new kink get created. You can replicate this pattern if you hold two ends of a long rope and swinging you arms like scissors, creating pattens of eights in the rope.

The kinks travel always at the same speed (speed of light), much like waves on a rope always travel in the same speed . The only thing that you can control is the size of the kinks and the number of kinks. This translates directly into wavelength and frequency, because if you try to make a lot of kinks by moving the charges faster, the kinks would be smaller.

Why is it called electro-magnetic field, rather than simply an electric field wave? There's also a magnetic field that arises, and which travels outwards similarly. That's because a change the in electric field creates a magnetic field, and vice versa. There's an oscillation between the two fields. And the whole oscillating package travels outward.