Elliptic Curve Cryptography in Cryptocurrency

Elliptic Curve Cryptography, or ECC, is a branch of cryptography that has been in use since around 2004 and is vital in the running of Bitcoin because of how it is used to generate public/private key pairs. In cryptography, the two main types of encryption are RSA and ECC. RSA, which stands for Rivest-Shamir-Adleman, is the basic type of cryptography, in which 2 prime numbers are multiplied. Here, the trapdoor function comes into effect – there are 2 different directions the function can go, both of which will create cryptographically sound and secure numbers. After this, public and private key encryption come into play – if something is encrypted with a private key, it can be only unlocked with the public key. This can be useful for a variety of reasons; if someone wants to send an encoded message, they can use another person’s public key to encrypt the message, and the receiver has to use their own private key to decrypt it – no other private key will work. Or, if someone wants to check that a message was truly sent by a friend, they can check the digital signature, which is encrypted with the friend’s private key can only be unlocked with that person’s public key. As long as that person is the only one with their private key, the message will only decrypt if the message was truly sent by that person. How exactly does this work?

Elliptic Curve Cryptography in Visual

First, there has to be a maximum value set for the keys, and this maximum value is picked by multiplying two random prime numbers. From here, we get a public and private key pair using elliptic curve cryptography, and encryption/decryption is simple. First, set the private key as a numerical value called priv, and the public key of the person you are sending to as a numerical value called pub. To encrypt, multiply the message by itself pub amount of times, and to decrypt, multiply the message by itself priv amount of times. For this to work, however, priv and pub have to be mathematically related. How does the generation of priv and pub work such that the two are related in such a manner? Here is where ECC comes in. Elliptic curves are a set of points that satisfy a mathematical equation (y2 = x3 + ax + b), and the points in this set have a number of interesting properties that make them great for cryptography. For one, all points have horizontal symmetry, and for another, all lines that aren’t at a 90° angle to the x-axis and y-axis intersect the main curve in at three places. From here, the idea of dotting comes into play: when I move something from point A to B, it bounces off of B in two possible directions (the trapdoor function) and to the opposite side of the curve, an idea used in playing billiards. From here, only knowing the beginning and end points, it is nearly impossible to know how many times the points were dotted (n) from the beginning until the end. Since it is so hard to find n, this mathematical function makes a great trapdoor function and is great for cryptography. A maximum number has to be picked again, and this creates a prime function. From here, theoretically, if the x-coord is dotted by itself y-coord amount of times I will get my coordinate, which is my message, without ever even mentioning the message in my encryption. Since I need to have both the x-coord and the y-coord, or the private and public key respectively to find the message, it is cryptographically protected, since knowing the public key doesn’t mean one can find the private key.

Bitcoin uses ECC to generate public/private keys with frightening accuracy. The software first takes a random string, like a username, that the user types up, and then hashes it by SHA256, a hashing algorithm. Then the hexadecimal number is converted into a decimal number, and a version number is added. On bitcoin, all private keys have version number 5, so 80 is added to the hexadecimal. Then a 32-bit checksum is added because 256 digits are really hard to remember. A checksum is a string of numbers representing the sum of the correct digits in data. To do that, double hash the hexadecimal using SHA256. Then, take the first eight characters of the hexadecimal, or 32 bits, and then add those numbers to the end of the hash. Last, convert the hexadecimal to Base58, creating a final private key. Or in other words, take the key, SHA256, RIPEMD160, then Base58 encode it.

This software uses ECC, and the need for ECC comes from the fact that with RSA, keys have to become longer and longer to keep generating a different set every time, while with ECC keys don’t have to increase in size constantly. It is rather interesting that Bitcoin uses SHA256, out of all the hashing functions. There are many different qualities to a good hashing function, and the main three properties are pre-image resistance, second pre-image resistance, and collision resistance. Pre-image resistance is that it should be close to impossible to find my original message if it has been hashed. Second preimage resistance says that hashing a message should make a hash that is not equal to the hash of another message. Collision resistance is almost the same, making sure that hashing 2 different messages shouldn’t create the same string.

There are a few different hashing functions in use, including MD5, SHA1, SHA2, and Bitcoin’s favorite, SHA256. Hashing functions don’t have to be cryptographic either – Scrypt is a password-based key derivation function, which obtains a secret key from a master value. X11 is a proof-of-work function, though it isn’t in main use because of how rudimentary it is. There are a few issues with using cryptographic hash functions like ECC, the main issue being that a random number generator for keys that uses ECC and promoted by the NSA might have a backdoor that allows those at the National Security Agency to use one key to access every single other account with keys created by that software. It is rather similar to a book I read, Digital Fortress from Dan Brown, in that the government is willing to do whatever it takes to protect the country, even if it violates the privacy of the people. Is such software worth having if it is able to be used in this way? I personally think it is very fascinating how ECC is used to protect things, and how the ECC works because of how cryptographically unbreakable it is, and cannot help but wonder if we ever will be able to crack it, and whether it should even be in use.

Sources:

Click to access encryption.pdf

https://arstechnica.com/information-technology/2013/10/a-relatively-easy-to-understand-primer-on-elliptic-curve-cryptography/

https://arstechnica.com/information-technology/2013/10/a-relatively-easy-to-understand-primer-on-elliptic-curve-cryptography/2/

https://arstechnica.com/information-technology/2013/10/a-relatively-easy-to-understand-primer-on-elliptic-curve-cryptography/3/

http://blogs.mdaemon.com/index.php/2018/05/29/encrypting-vs-signing-with-openpgp-whats-the-difference-2/

https://www.gnupg.org/gph/en/manual/x135.html

Hashing Strings with Python

https://docs.oracle.com/cd/E19683-01/806-4078/6jd6cjru7/index.html

http://nuance.custhelp.com/app/answers/detail/a_id/5518/~/digital-signatures-display-a-question-mark-and-a-validity-unknown-or

https://en.wikipedia.org/wiki/Cryptographic_hash_function

https://crypto.stackexchange.com/questions/43990/what-are-advantages-and-disadvantages-of-sha-256

Comments

Leave a comment