Spend Key and Mnemonic Seed

When I first started reading about cryptocurrencies, I didn’t understand the notion of “you hold your own money” or “you are your own bank”. Hopefully this will explain it to you and cryptography’s role in it. But first things first: what is cryptography?

Symmetric cryptography:

Say that you would want to exchange a secret number with me. You’re afraid someone might see this secret code so you decide to encrypt it. For simplicity, let’s say that the secret code is 6. We agree with each other, that our exchanges of secret codes all will be encrypted by adding the number 2. Plain and simple. You send the secret code to me as 8, and when I receive it, I simply subtract 2. “OK, so the secret code is actually 6.” Plain and simple! This is called “Symmetric encryption” (or “Symmetric-key algorithm”), since the encryption key (adding the number 2) and the decryption key (subtracting number 2) work both ways, you simply reverse the process. This comes with drawbacks; if you know the encryption key, you know the decryption key. The solution to this is “Asymmetric encryption.”

Asymmetric cryptography:

This works in a more complicated manner, both in encrypting and decrypting messages, and the process of creating a pair of encryption and decryption keys (numbers). One of the most well-known (if not the most well-known) is RSA. The two keys are known as the public key and the private key. The public key can encrypt a message but cannot decrypt it, it can only be decrypted by the private key. In the same manner, encryption can be performed by the private key and the message can only be decrypted by the public key. For RSA, it works in this manner:

m^a mod b=n

n^c mod b=m

where m is the number to encrypt, ^ is raised to the power of, mod is the Modulo operation (that is, finding the remainder. For example, the remainder of 5/2 is 1 therefore 5%2 is 1, the remainder of 11/3 is 2 therefore 11%3 is 2), and n is the encrypted number. The public key is (a,b) and the private key is (c,b). Ones the number is encrypted it can’t be reversed with the same key.

A simple example from the website https://www.cs.utexas.edu/~mitra/honors/soln.html and how the keys are created is presented: the two keys are (7,33) and (3,33). Say you want to encrypt the number 6 and send it to me. You have the public key (7,33), I have the private key (3,33).

6^7 mod 33 = 30

30^3 mod 33 = 6

Notice that you can’t decrypt the message with the key you used to encrypt it with. Give it a try if you don’t want to take my word for it! As mentioned above, the private key can also encrypt messages which in turn only the public key can decrypt. As an example:

4^3 mod 33 = 31

31^7 mod 33 = 4

There is another very powerful application for this, and that is that messages can be signed to prove authenticity. As an example, let’s say that I want you (Bob) to have 50 USD from me. I can publish a message in this post that says “Victor owes 50 USD to Bob from 22 April 2017”. To prove that my site just hasn’t been hacked and someone else has posted this, I also leave the same message but encrypted with my private key (encrypted after it has been converted to a set of numbers). You can then use my public key which should be known to the public to decrypt the message and compare that it has been encrypted correctly with my private key. Then, you are to assume that my private key has not been stolen and only I can produce this encrypted message. This is my digital signature.

Cryptography in cryptocurrency

In cryptocurrency, cryptography is employed to ensure the security of the funds owned. To spend your funds, you have to prove ownership of them. As an example, Bitcoin works in the following manner and uses another encryption algorithm (approach) called ECDSA; when sending funds from your address A to address B, the transaction (message) is broadcasted to the Bitcoin network. This message is signed using your private key. Your address A is simultaneously your public key, which the Bitcoin network uses to check that the transaction has been signed with the correct private key. When it is confirmed, your transaction is saved in a ledger (for more information on how this part is performed, the original paper published by Satoshi Nakamoto is a great source of information, found here). Thus, the one who owns the private key connected to the address owns the funds. When you have bitcoins stored “on a unit”, it is actually your private key (and public key) which is stored on it, usually encrypted with a password or pin that you have chosen.

If the private key is lost, your money is lost, so it should be backed up on several locations; encrypted or written by hand on a piece of paper. If your private key is stolen, then your money can be stolen. The private key is a long string of numbers and letters which is hard to memorize. Luckily, it can be memorized using a so called mnemonic seed which, in Bitcoin’s case, is a set of 12 or 24 words.