A blockchain system (#blockchain) is a distributed database in a peer-to-peer network. Inside the blockchain system, the transactions are not processed by one computing system, but by many. The blockchain technology was first introduced in 2009, but it recently gained more attentions because of the bitcoin (#bitcoin), a digital cryptocurrency built on top of the blockchain technology. The new digital currency keeps reaching its record high price in 2017. The increasing adoption of the bitcoin makes people feel more confident in this technology. In this blog, I explore the technical details of this technology.
Bitcoin is a worldwide cryptocurrency and digital payment system called the first decentralized digital currency.
1. What is the Blockchain?
To understand the blockchain, you can think of it as a chain of blocks stored in a historical order.
To understand the blockchain, you can think of it as a chain of blocks stored in a historical order.
- The chain of the blocks is called the ledger. This ledger is open to the public and is stored distributively in a peer-to-peer network. In a blockchain system, maintainers maintain the ledger by keeping a local copy of ledger.
- The block in the ledge contains a group of transactions stored in a hash tree called the Merkle Root. Each block has a unique ID, which is known as the block hash, a hash value.
- A transaction defines a data operation typically including a sender, a recipient and the amount (data) to be sent from the sender to the recipient. New transactions have to refer to sender's previous transactions to make sure the sender has enough amounts (of data) to send out. Each transaction also has a unique ID called a transaction hash and the signature of the sender.
2. How does the blockchain system run?
A blockchain system runs based on a set of rules. These rules ensure the system completes transactions securely in public. In summary, blockchain defines a platform that:
A blockchain system runs based on a set of rules. These rules ensure the system completes transactions securely in public. In summary, blockchain defines a platform that:
- Sets up the trust in an untrusted environment
- Ensures no double- or over-spending
- Ensures the correctly maintain the sequence of events
The following are the details of the rules:
2.1 Transactions Have to be Signed
To prevent the transaction forgery, each transaction has a unique ID and has to be signed by the sender. The sender creates a unique signature for each transaction using his private key. This is also known as the digital signature. The signature is then verified with the sender's public key. This can be represented as:
2.2 New Transaction Have to Reference Previous Transactions
To prevent double spending or overspending, each transaction has to reference sender's transaction history to ensure the sender has enough amount (data) to complete the transactions.
2.3 Ledger Only Accepts Blocks with the Resolved "Proof of Work" and The Longest Blockchain Wins
The blockchain creating the processing is a voting process shown as the following:
2.1 Transactions Have to be Signed
To prevent the transaction forgery, each transaction has a unique ID and has to be signed by the sender. The sender creates a unique signature for each transaction using his private key. This is also known as the digital signature. The signature is then verified with the sender's public key. This can be represented as:
- When creating a new transaction, sign the transaction with Sign (Message, Private_Key)=Signature
- When validating the transaction, check the transaction with Verify (Message, Signature, Public_Key) =True/False. True means the transaction is from the sender. False means otherwise.
2.2 New Transaction Have to Reference Previous Transactions
To prevent double spending or overspending, each transaction has to reference sender's transaction history to ensure the sender has enough amount (data) to complete the transactions.
2.3 Ledger Only Accepts Blocks with the Resolved "Proof of Work" and The Longest Blockchain Wins
The blockchain creating the processing is a voting process shown as the following:
- After a block is created, it comes with a "Proof of Work" which is a hash value generated by a cryptographic hash function(CHF), such as SHA256(). Based on the system predefined difficulty, the hash values are created with certain patterns, for example, start with 30 zeros. The hash value is included in each block, which is also called the puzzle with the block.
- The miners pick the blocks and try to resolve the puzzle by finding out the input number to the hash function. Based on the math, to resolve the puzzle, the maintainers can only use computational resources to do the guess-and-check.
- After the puzzle is resolved, the miner will publish the block for all users to update their ledger.
- If the user received two chains of the blocks, the longer one would always win eventually and the transactions in the discarded block return back to the incomplete status. If the block chain length is the same, the ledger is updated after the next block is updated.
What is the Cryptographic Hash Function?
A cryptographic hash function is a hash function which takes an input (or 'message') and returns a fixed-size alphanumeric string. The string is called the 'hash value', 'message digest', 'digital fingerprint', 'digest' or 'checksum'). (From Wikipedia)
A cryptographic hash function is a hash function which takes an input (or 'message') and returns a fixed-size alphanumeric string. The string is called the 'hash value', 'message digest', 'digital fingerprint', 'digest' or 'checksum'). (From Wikipedia)
The puzzle resolving process can be described as:
2.4 Blocks Are Stored with Reference to the Previous One
To maintain the correct order of block in the ledger, each block in the ledger has to refer to the block hash of the previous block to keep the ordering information.
- Creating the "Proof of Work" for each block: find the Number, where CHF(Number) =Hash_Value. The Hash_Value is in a predefined pattern.
- Resolving the puzzle: knowing the hash value in CHF(Number) =Hash_Value , find the Number.
2.4 Blocks Are Stored with Reference to the Previous One
To maintain the correct order of block in the ledger, each block in the ledger has to refer to the block hash of the previous block to keep the ordering information.
3. Why would I use a blockchain system?
There are some reasons to consider a blockchain system:
There are some reasons to consider a blockchain system:
- Hacking to a single ledger is not enough. The intensive compute resources needed to update all/majority of ledger makes hacking very difficult. It's under the philosophy of "When everyone accepts it, it's the truth."
- No intermediary or bookkeeper is needed for the data sharing. This is also called peer-to-peer transaction processing. [2]
References
- Subramanian Iyer, The Benefits of Blockchain Across Industries, April 2016
- Marco Iansiti and Karim R. Lakhani, The Truth About Blockchain, Harvard Business Review, January 2017
- How Bitcoin Works Under the Hood (YouTube), Jul 14, 2013
- Ever wonder how Bitcoin (and other cryptocurrencies) actually work? (YouTube), Jul 7, 2017
- Satoshi Nakamoto, Bitcoin: A Peer-to-Peer Electronic Cash System
- Blockchain Use Case by Industry