Quantum resistant blockchain and cryptocurrency, the full analysis in seven parts. Part 2.
In part 2, I will take a further look into the mathematical concepts that are used in blockchain. Understanding these concepts is very helpful for the comprehension of the next parts of the series. So bear with me. I’ll skip the actual math and just explain the concepts. It should be interesting, even if you don’t like math.
As mentioned in the previous chapter, two mathematical concepts are used:
- Hashing algorithms
- Public key cryptography
What are hashing algorithms:
A hashing algorithm, or hash function, is a mathematical formula that reduces an amount of data to a smaller amount of data with a set amount of characters. No matter how large the input is, the outcome is always the same size. So whether your input is a digital movie, an mp3, or a few lines of text, the output will always have the same amount of characters. What that size is, depends on the hashing function that is used. Here are some examples, using the hashing algorithm “SHA256”:
If the input is “Blockchain”
The output is: 625da44e4eaf58d61cf048d168aa6f5e492dea166d8bb54ec06c30de07db57e1
If the input is the paragraph above, (From “A hashing […] algorithm “SHA256”:”)
The output is: 973f48304184375dd6d78a84b756b2f6d15940d337c45078990be0ccd073dfcf
So no matter the input, the output is always a set amount of characters (for SHA-256, this is always 64 characters.) You can play around with this concept here: https://www.xorbin.com/tools/sha256-hash-calculator
What type of hashing algorithm is used in blockchain?
There are a lot of different hashing functions. In blockchain we use a type of hashing function called a “cryptographic” hash function. These hashing functions have certain properties that make them considered to be secure and suitable for blockchain. The most important properties are:
- Calculation speed. This is pretty obvious. The faster an output can be calculated, the more efficiently it will be to handle transactions.
- Deterministic. Using the same input always results in the same output, no matter how many times you try.
- Even small changes to the input will completely change the output. For example, again using SHA-256:
- One-way hashing function. This means that it should be close to impossible to derive the input from the output. Close to impossible means here that it would take far longer than a human lifetime to do so. It is theoretically possible, but it takes so long that it just doesn’t matter.
- Collision resistant. This means that it should be close to impossible that the outcome of two different inputs will have the same output. Close to impossible means here again: it’s possible, but the chances are so slim that in practice it can be referred to as impossible.
All the above qualities make these kinds of hashing functions suitable for blockchain use.
Hashing is used in blockchain in two ways:
- To save space while storing public keys. Some blockchains (not all) only publish the hash of a public key. So you personally have a full public key, but on the blockchain, funds are stored on the hash of the public key.
- To “summarize” and at the same time prove the authenticity of the last block. A complete block with all the info it contains is hashed. This means it is reduced in size to one line of characters. The next block contains the hash of the previous block and all transactions that are part of that block and some other info. Then that block is hashed again and so forth. Since every small change in the content of something that is hashed will completely change the outcome of the hash, this means you can’t insert a forged block in an existing chain, or even a small change in a transaction. You would not even be able to change a single digit in one of the previous blocks, because then the hash of that block would change and you would need to change all hashes of all following blocks. So if you were to change something in a signed block, you wouldn’t be able to do the necessary math fast enough to catch up with the following blocks.
What is public Key Cryptography:
Private-public key cryptography is used to sign and authenticate transactions. It is commonly referred to as a signature scheme. Using a mathematical algorithm, a keypair is generated: a public key and a private key. These keys are a set of characters. The private key is used to create a mathematical signature that will authenticate any message or transaction you send. The receiver uses the public key to verify the signature (again through math). The signature is unique for every message or transaction, and similar to a hashing function, even a small change in the message will make it so that the signature doesn’t match and the verification fails. Even if just a single character in the message is changed or removed, the signature won’t match. This way, messages can be sent over an insecure network while still guaranteeing the authenticity and originality of the message.
Public Key Cryptography in blockchain:
In blockchain public key cryptography (signature schemes) is used as follows: In a secure environment (the wallet), a keypair is generated: a public key and a private key. The private key you keep for yourself. You will use the private key to log in to your wallet and to create a signature if you want to send funds from your address.
The public key can be made public. As described in the part about hashing functions, some blockchains only publish the public key in hashed form to safe space. In that system, funds are registered to the hash of your public key. But as soon as you want to send a transaction, you will need to make your public key in original form public. This is because without the public key, the blockchain network can’t verify the authenticity of your transaction. The public key is included in the transaction, that way the network receives the public key. The public key only needs to be made public in its original form if you want to withdraw funds but not if you want to receive funds, because receiving funds doesn’t need your signature. So as long as you don’t withdraw funds from your address, you don’t need to publish your original public key.
So public key signature systems give you the ability to send transactions to someone who doesn’t know you, over an insecure network, while still being able to prove you were authorized to send that transaction and at the same time to verify the message is unchanged.
So the messages/ transactions are not encrypted. Rather, they are openly transmitted but are signed and in a way that they are authenticated and unforgeable.
There are several types of public key cryptography. EDCSA and RSA are the most commonly used in blockchain.
The blockchain itself works in a secure way by using hashing algorithms. While communication between users and the blockchain is securely performed using public key cryptography, also referred to as signature schemes.
It’s important to make this distinction because the next article will cover the quantum resistance of blockchain. The hashing algorithms used in blockchain will prove to be something not to worry about any time soon, while the signature schemes used in blockchain are mathematically proven to be at risk somewhere along the path of development of quantum computers.