Understanding blockchain 1.
Blockchain brings us to a wide new array of technology, plenty of new possibilities, a whole new amazing world! But as responsible adults, we can not just jump into blockchain without examining the basics of how the blockchain works, and looking into safety and security.Protecting our information, digital assets and our identity is a crucial matter for all of us. In times were so many of our important information is online, the security of any system we use is a must. We need to invest a bit of effort into understanding the basics of technology, online safety and security, in order to protect ourselves and our assets effectively.
Blockchain uses sophisticated mathematics, cryptography and innovative software to perform transactions and protect information. But what parts of this technology exactly makes it safe to use?
In today's article we are going to look at 2 of the components: public-key cryptography, hashing which work together to ensure safety and security. During the next couple of weeks we will extend our investigation to see consensus protocols, and the critiques on blockchain security.
Let's dive in!
Cryptography is the science of applying mathematical functions to pieces of data to guarantee their security.
Cryptography can be traced back to Ancient Egypt, and was used ever since- Julius Ceasar used in his communication the Ceasar cypher wheel, in Wolrd War II the German army concealed their messages with the help of Enigma. With cryptographic methods a piece of secret information is converted into ciphertext, which contains the form of the original text but it is unreadable. We need to use a cipher key to decrypt the text to its original readable information.
Modern technology and computers enabled us to make more and more complex ciphers, and enhanced the possibilities of cryptanalysis- breaking the encryption. With computers we can encrypt not only language texts, but any kind of digital information. The algorithms are designed around computational hardness assumptions- while it would be theoretically possible to break a decrypted information, they prove to be infeasible by our current means- meaning it would take too much time, computational power to decode without the key.
The expansion of the cryptographic field in the recent years covers e-commerce, credit cards, digital currencies, password management, messaging and many more areas, it is something we use every day.
In blockchain technology the asymmetric encryption system, alias public key cryptography is used. This means that the information in concealed by 2 keys- a public and a private key, which are connected by a mathematical algorithm.
The public key is meant to be shared- it is like an address, or a bank account number. The private key is a secret, and is used to create the digital signature to prove authenticity of our messages.
Let's see this via an example:
B decides to send a message to A in secret. B encrypts the message with A's public key, and sends her the data. When A receives the data, she will decrypt it with her private key, and get the information from B. The information would not be possible to recover with anything else than A's private key.
To make it even more simple. Let's say the public key is like a box with a lock. B gets A's box, and puts all kind of fun stuff inside, then shuts it close. After closing the box the lock automatically closes. B sends this box to A, and only A will be able to open it with key own key.
There is some very cool mathematics behind asymmetrical cryptography, if you feel like grinding your thought-muscles go for it!
In the blockchain world your public key is the address of your wallet, where you keep your assets, and your private key gives you access to the contents. This is why keeping your private key safe, secure and secret is super important.
The reliability of the blockchain lies in recording data, and linking it to a chain, making the individual transactions linked and unchangeable within the chain. The cornerstone of this technology is hashing.
Hashing takes any data of arbitrary size, and transforms it to a data of fixed size via a mathematical algorithm. For example, on the Bitcoin chain transactions go through a hashing algorithm (SHA-256) which gives an output of fixed length- 256 bits. If the data is smaller, the hashing algorithm packs it to reach the desired length, and if it is longer it cuts it down to this size.
Blockchain uses cryptographic hash functions, which have 4 properties that make them secure to use:
- Same input = same hash value: it is not possible to make 2 different hashes from the same input, neither to have different hashes from the same input
- Change in the input changes the hash itself
- Quick to produce a hash for any message
- Can not determine input based on the hash value: as in asymmetrically encrypted messages above, you can not determine the original message from the encrypted format without the key
You can read the tech details here in this Blockgeeks article. With hashing you can verify the authenticity of a data- if the data you have provides a certain hash, and another data provides a different hash your data is has been altered. If the hash is the same, the data is the same.
Hashes in blockchain represent the current state of the chain. Each block is connected with the hash of the previous block. As the hash represents all the block connected before, it includes by connection the whole chain.
The hashes are connected in a data structure called Merkle-tree on the blockchain. Merkle trees are created by making pairs of hashes repeatedly, until there is only one hash left. They are made from bottom up from the hashes of individual transactions, or leafs.
The Merkle root is the one hash summarizing all of the data, at the top of the tree, and contains all of the hashes under it. The individual branches can be downloaded, but if modified the whole Merkle tree and root changes.
Merkle trees provide an efficient way to verify data, prove validity and require little memory and computational power. Merkle trees help to prove that all previous transactions from the blockchain are recorded, and the shared ledger is complete, unchanged, and in chronological order.
Together public key cryptography and the hash technology lay down the groundwork for making blockchain possible. These concepts are not necessarily new- cryptography can be traced back thousands of years, and the Merkle tree itself was patented in 1979 by Ralph Merkle. Connecting these concepts with modern technology is what gives us the possibility to look at transactions and information in a whole new way.
Tune in next week to see more about consensus protocols on the blockchain and to explore more on blockchain security! Think along!