A collection of fragments of understanding in the pursuit of deeper questions.
Applying Hash Functions... for real Different applications:
Comparing data
Detecting changes in data
Referring to data in a change-sensitive way (very important!)
Storing data in a change-sensitive way
Causing time-consuming computations
Hashing to Compare Data The goal is to compare data without looking at their content. Also, the comparison should be fast and completely independent on the type of data and its size. So here is the idea: just compare hash values. How: if all the hash values are different, then all the data chunks are different as well. It works because hash functions are collision resistant.
Hashing to Detect Changes in Data If we can compare, we can also detect changes. We want to be able to say if data which should remain unchanged, has changed at a certain point in time. So we throw a comparison between two hash values belonging to the same chunk of data. If both hash values are identical it implies no change. Once again, detecting changes in data that are supposed to stay unchanged works due to collision resistance of cryptographic hash functions.
Having to Refer to Data in a Change-Sensitive Way Comparing and detecting changes are the basics. A more advanced approach is hash references and then ensure the data remain unchanged. To achieve this, we combine the hash value itself associated with stored data with information about where that data is located. The moment there is a change, both information will be no more consistent: the hash reference becomes invalid. Example: a cloakroom ticket is a hash reference to your jacket.
Computers use reference addresses to remember where they store things that we told them to store. Hash references refer to data and at the same time they verify the data has not changed since the reference was created. Example: the cloakroom ticket points at an empty cloaca hook.
We use hash references to protect users from retrieving wrong data (i.e. unintentionally or intentionally changed). The whole idea is properly based on the fact that hash values are encrypted: it is very unlikely that different chunks of data have identical hash values.
We can do the same with data and form a chain of data. If at any point in time either the data or the hash references are changed all the hash references are broken. But this is the warning that advises us that a change occurred after the initial reference was created. There exist two patterns that can be used to store data in a change-sensitive way:
Hash Pointers and Data Structures
Definition: a hash pointer is simply a pointer to where some information is stored together with a cryptographic hash of the information. Whereas Ed a regular pointer gives you a way to retrieve the information, a hash pointer also gives you a way to verify that the information hasn't changed.
The Chain Pattern
Here is an example of a blockchain with hash pointers. Each block tells us where the value of the previous block was and a digest of that value which allows us to verify that the value itself hasn't changed. This comes in handy when we know data will arrive step by step.
The Tree Pattern
This structure is called Merkle Tree and was proposed by the computer scientist Ralph Merkle in 1979. It is an important structure because it allows to group distinct pieces of data available at the same time and make them accessible via a single hash value.
The process of just trying all the combinations implies no knowledge nor reasoning of any sort. You just put hard work on this task. Hash puzzles (games) are computational games which can be considered as the equivalent of opening a lock.
Authorizing Transactions with Digital Signature We know a bit about cryptography. We know a bit about hash functions, how they work and how we could use them. Now, we need to understand how to rightfully transfer a property from one account to another. In other words, we need an authorization. We obtain authorization through digital signatures. Think about handwritten signatures: through them we state agreement. We accept them because we think they are unique. Now, we transfer this concept tot the digital world of the blockchain. Digital signatures is a crucial concept for the security of individual transactions in a blockchain.
The Importance of Ordering One of the fundamental problem with blockchain is that the order of blocks doesn't always reflect the one of transaction. Recognizing the order in which transactions occurred is key to achieve the same identical results. Changing the order of transaction data implies a change in the aggregation of them. Receiving a payment from a friend seems to be the trivial case.
Integrity of the Transaction History The history of transactions is really the core of the blockchain. Why? Because history is the way we reconstruct the state of the ownership. We want the history of data to be safe, complete, correct and consistent such that the integrity of the system is maintained. We need a system to validate transaction:
The Double-Spending Problem The idea: if we spend $1 to buy an apple, we can't use that same $1 to buy an orange. Why? Just because you have to give $1 to the vendor. With digital currencies, or assets, there is no such thing. We can spend the same currency for two or more transactions, in principle. Let's imagine we have a P2P system for managing ownership of real estate. Ledgers is maintained by individual computers so each peers has its own copy. The minute the ownership of a house is transferred from one account to another, all the ledgers must be updated to match the latest version of reality.
Issue: someone who already know the latest info could do something bad to someone else who is not up-to-date.
Example: Frodo is sick and tired of carrying the ring around. So he decides to sell it but before doing it, he hides the ring where no one can spot it. He then goes to one of his fellow hobbits telling him about the ring and closes the deal for a considerable amount of pipeweed. However, Frodo is very smart. He wants more pipeweed so he quickly goes to another hobbit and sells the same ring for another honest amount of pipeweed.
The term double-spending can be used to refer to different concepts: