How Blockchain Works: An Overview

Designing a Blockchain

In our previous article, we highlighted that blockchain is the technology that enables secure and verifiable data transfer in a peer-to-peer network.

In the financial sector, the movement of data often equates to clarifying and transferring ownership. In this article, we will embark on a journey to “invent” blockchain in 9 steps to address these two financial problems.

1. Defining Ownership Status

Object-Owner Relationship

An individual can both own an object and use it.
To prove ownership of an object, one must provide identification for both the object and the owner, as well as establish a mapping between the owner and the property (ledger). If the owner wishes to use the object, authentication (to confirm the individual’s identity) and authorization (to grant access) are also required.

Current Status=Transaction History

The ownership status of an individual changes with every transaction they make or receive. The traditional method of displaying ownership status is straightforward but also prone to manipulation.

An alternative method of displaying ownership status is by aggregating all of the person’s transaction history. The transaction data provides a clear justification and explanation of the current ownership status.

Transferring Ownership

The transfer of ownership occurs when a person’s ownership status changes hands from one individual to another. This can occur through various methods such as sales, gifts, inheritance, or exchange. To initiate a transaction in blockchain, the following information is required:

  1. Identifier of the current owner
  2. Identifier of the new owner
  3. The quantity of goods to be transferred
  4. Transaction time
  5. Transaction fee
  6. Owner’s authorization

Recording History

Every transaction is recorded in the blockchain data structure, and each node in the blockchain network holds a complete copy of the blockchain, ensuring its decentralization and protection from control by a single entity.

Ensuring Integrity

Maintaining a valid transaction history is central to ownership management. To ensure the integrity of every transaction, the following three key aspects must be examined:
• Formal correctness – Required information is provided in the correct format
• Semantic correctness – The intended effect of the transaction aligns with the initiator’s intent and is lawful and applicable
• Authorization – Access is granted by the owner

2. Securing Ownership Status

Identification

In order to design a well-functioning blockchain, it is crucial to identify and uniquely represent each piece of information in a manner that is simple and easy.

Hash Value

The hash function is an effective tool for information identification. It is a mathematical function that converts data of any length into a fixed-length number, known as the hash value.

The hash function is like a computer program that takes an input and returns a fixed-digit output. Additionally, the hash value has several important properties that enhance the security of the identification process:

  1. The same input will yield the same output.
  2. If the input changes, the output will change unpredictably.
  3. Different inputs will yield different outputs.
  4. The output cannot be used to derive the input.

The hash function can only process one piece of information at a time, so further manipulation is necessary if the transaction involves multiple pieces of information. This can be achieved through:

  1. Independent hashing: x-y
  2. Repeated hashing: the hash value of the hash value, x-y-z
  3. Combined hashing: using symbols to connect multiple pieces of data into one, and then applying the hash function, (x+y)-z
  4. Repeated+combined hashing: update as new data arrives.
  1. Hierarchical Hashing
    Yield to hash value respectively and combined them to derive the final hash value. x-y, a-b, (y+b)-c
    The process involves dividing the information into smaller pieces, hashing each piece individually, and then combining the resulting hash values to form a final hash value. This approach allows for a hierarchical organization of information.

Implications of Hash Values

Hash values have many valuable applications in blockchain technology, including:

  1. Data comparison: comparing two strings of bytes is easier than comparing two entire files.
  2. Data reference: hash values can be used to represent data uniquely.
  3. Change detection: hash values are highly sensitive to changes.
  4. Hash puzzles (will be explained later).

Authentication

Authentication is a crucial aspect of blockchain design, as it ensures that only the rightful owner of the property has access to it. The challenge is to maintain the privacy and security of the owner’s property, while at the same time allowing for an open platform for communication.
Asymmetric cryptography provides a solution for this challenge by offering both openness and security. This system works similar to email, where anyone can communicate with an address (public key), but only the person with the corresponding private key can read the email.
Asymmetric cryptography involves using a public key for encryption and a complementary private key for decryption. It is mathematically impossible to determine the private key based on the public key. The private key is kept confidential and used to sign messages and create digital signatures, while the public key is freely shared and used to encrypt messages and verify signatures.

As depicted in the image, since they are complementary to each other, it is also possible to use the private key to encrypt and the corresponding public key to decrypt it.

In such cases, asymmetric cryptography is used to protect authorship. Although anyone with the public key can read the information, only the owner can create it.

Authorization

To use or transfer ownership, one must be authorized. A digital signature serves as the tool for authorization.

Digital Signature

A digital signature is similar to a handwritten signature that is used to approve something. Instead of using a particular style of writing, a unique and secure private key is used to encrypt the data. To create a digital signature, data must first be converted into a hash value. Then, a private key is used to encrypt the hash value into a digital signature, which is signed under the original data.

The digital signature is unique and derived from the original data, which means that the receiver can use the complementary key to decrypt it and compare the hash value of the data to verify the identity and detect any changes.

3. Storing And Organizing Data

Effective data storage demands security, organization, and an index system.
To ensure security, the blockchain data structure converts information into a hash value, which is extremely sensitive to changes. Every block header, which includes the hash value that references all the transaction data (Merkle root), the reference hash for the previous block, time stamp, difficulty target, and so on, much like a library’s catalogue.

For the purpose of being organized, within each block header, both the hash of the content and the hash of the previous block are recorded, allowing one to trace the history of transactions like flipping through pages in a book backward.

For instance, in the illustration, the hash value B2 represents the combined hash values of B1 and R34.

4. Immutable Record Keeping

There is a risk that dishonest participants could manipulate or forge the transaction history to their advantage. Therefore, it is crucial to design a tamper-proof system. Immutable record keeping relies on three mechanisms:

  1. Information stored in the blockchain can detect changes easily, as any modifications made in the middle of the blockchain will cause the chain to break
  1. The way block headers connect with each other determines the all-or-nothing nature scenario when changing data: one either changes the data structure starting from the point that causes the change until the head of the whole chain, or leaves it unchanged in the first place.
  2. Rewriting the data not only requires a lot of effort, but also consumes massive computational power, incurring a potential cost that substantially surpasses the reward. Creating a new block requires at least the following compulsory data:
    • The root of a Merkle tree containing transaction data
    • A hash reference of the preceding block header
    • The difficulty level of the hash puzzle
    • The time when the solving of the hash puzzle started
    • The nonce that solves the puzzle (answer)

5. Synchronized Update

In a peer-to-peer (P2P) system utilizing blockchain technology, there is no central entity that stores and distributes information. As a result, it is the responsibility of each node to possess a distributed ledger of the complete version of transactions and to update synchronously with the latest data. The Internet provides solutions to our problems:

  1. Every node can communicate with each other directly, without intermediaries.
  2. Every node has a unique address.
  3. Information can be transmitted between nodes.

However, as nodes can disconnect from the Internet at any time, several issues arise:

  1. Ensuring that every piece of information is received by all nodes on the Internet.
  2. Ensuring the order of arrival of information.
  3. Avoiding duplicates of the same information.

To address the first problem, all nodes must adhere to the same protocol. Every node that receives new information will forward the message to its peers. Peers are maintained through sending specific messages and receiving complementary responses. If a node fails to respond repeatedly, it will be removed from the peers list.

Nodes can request to join the P2P system, and they will be added to the peers list after their request has been confirmed. For the second issue, the chronological order of information can be determined by examining the timestamp. Finally, the unique hash value ensures that no duplicate copies of information are stored.

6. Security and Integrity

In step three, we discussed the implementation of adding new transaction data to the blockchain. However, the challenge of ensuring the integrity and security of this information remains unresolved.

This is because there is no central authority to oversee the incoming information, hence the need for a reward and punishment mechanism to regulate the system. Additionally, with the absence of a central supervisor, all participants can assume the role of a supervisor and be empowered to perform this task.

Validation Rules

To ensure the validity of new transactions, validation rules are established. These rules dictate the necessary conditions that a transaction must meet to be considered valid and added to the blockchain. This typically includes rules for transactions and block headers, specifying the required information and format. For instance, in a proof-of-work blockchain like Bitcoin, validation rules might include verifying that the solution to the cryptographic puzzle in the block header meets the difficulty target.

Rewards an Punishments

The creation of valid blocks is incentivized through rewards, compensating participants for their efforts. On the other hand, punishments, such as the retraction of rewards, are imposed on participants who create invalid blocks or repeat blocks.

Competitions

Not all participants who contribute to creating valid blocks will be rewarded. Blockchain sets up two ongoing competitions, the speed competition and the quality competition, for all participants. To win the reward, a participant must win both competitions.

The rules of these competitions are as follows:
1) the first participant to claim victory in the speed competition becomes a “temporary loser,”
2) the “losers” act as referees to validate the winner’s block, and
3) if the block is found to be error-free, the winner is granted the reward. If not, the invalid block is discarded and the speed competition is reopened to all participants.

These rules divide the participants into two groups: those who evaluate the work of other nodes and those who work for the reward

7. Vote for Truth

Although various approaches have been implemented to ensure that every node has the same version of data in its ledger, transaction histories may still differ due to delays or errors in message transmission.

Therefore, it is essential to find a way to resolve conflicts among different versions of history without introducing central referees. A consensus mechanism provides a means for collectively deciding the truth.

Proof of Stake (PoS)

Proof of Stake is the consensus mechanism used by Ethereum. The essence of the Proof of Stake mechanism is the “longest chain rule,” which states that the single blockchain representing the truth is the one with the most blocks.

Proof of Work (PoW)

Proof of Work is the consensus mechanism used by Bitcoin and many others. The “heaviest chain rule” is adopted in PoW. Instead of counting the number of blocks, the heaviest chain rule compares the aggregated difficulty of each block. The blockchain that has consumed the most computational effort is considered the truth.

For example, in the scenario where multiple conflicting blocks arrive at the blockchain, PoW requires calculating and comparing the aggregated difficulties to determine the “real” block. In this scenario, 33FF-A397-AB12-CCCC1 is the winner, but this may not be the case if PoS was used instead.

Compared to PoS, PoW is more computationally expensive.

After selection, blocks that are not part of the main path are discarded and referred to as “orphan blocks”. These blocks do not contribute to the integrity of the system, and any rewards that were previously given are revoked. Only the data preserved in the authoritative chain (main path) is considered valid and part of the actual history.

As time progresses, the blockchain may still branch out, while the shared trunk continues to grow, providing the blockchain with more consistency and stability. To commit fraud, one would have to create a chain that surpasses the existing one, which is unlikely as it would require taking control of the majority of computational resources.

Automation (See next article)

In this section, I will introduce the concept of smart contracts, which undoubtedly deserves its own separate article!!