Blockchain (1.0) is a cryptographic-based distributed ledger that is easily verifiable and immutable. It is generally considered that the blockchain combined with smart contracts is blockchain 2.0. For example, Ethereum is a typical blockchain 2.0. Many people only know about Bitcoin, but do not know about blockchain. Blockchain is the future. I hope developers care less about currency price and more about technology. This article will explain how blockchain 1.0 technology is implemented.
The hash function
Before we talk about blockchain bookkeeping, let’s talk about hash functions. The raw information can be any information, and the Hash results in a short summary
Hash functions have several characteristics:
- The same original information and the same hash function always get the same summary information
- Any slight change to the original information hashes out an unrecognizable summary of the information
- The original information cannot be back-inferred from the abstract information
For example: Hash(Zhang SAN lends Li Si 1 million yuan, 1% interest, principal and interest will be repaid after 1 year… ..) There is such a record as AC4635D34DEF in the books.
You can see that the hash function does four things:
- The simplified message is easy to understand, the hashed message is shorter.
- Identifying information can be identified by AC4635D34DEF as the original information, and summary information is also called the ID of the original information.
- Hidden information ledger is a record such as AC4635D34DEF, the original information is hidden.
- Verify information If Li Si deceives in repayment that Zhang SAN only lends Li Si 100,000, both parties can use AC4635D34DEF to verify the original information
These four functions of hash function are widely used in blockchain technology. (A hash function is a group of functions or algorithms that will be covered in a future article.)
Blockchain accounting method
Suppose there is an account page with account number 0 and the transaction record is as follows:
account | booked | Enter an item of expenditure in the accounts | The balance of | descr |
---|---|---|---|---|
The king 2 | 100 | 190 | Receiving payment for XXX | |
Zhang SAN | 100 | 30 | xxxx | |
Li si | 120 | 90 | 170 | xxxx |
The accounting time is: 2017-10-22 10:22:02
In accounting, blockchain will Hash account page information (including serial number, accounting time, and transaction record) as the original information to get a Hash value, such as 787635ACD, which can be expressed as the function:
Hash(Hash 0, charge time, transaction record) = 787635ACD
The account page information is combined with the Hash value to form the first block.
The Bitcoin system takes about 10 minutes to account, which means that each block is generated about 10 minutes apart
When the second account page is recorded, the Hash value of the previous block and the current account page information will be used as the original information for Hash, namely:
Hash(previous Hash value, serial number 1, charge time, transaction record) = 456635BCD
Thus the second block contains not only the page information, but also the information of the first block indirectly. If this method continues in turn, the latest block always indirectly contains all the previous page information.
All the blocks are combined to form the chain block, this block chain will constitute a convenient for validation (as long as the validation of the last block of Hash value is equivalent to validate the entire book), cannot be changed (any transaction information of the change, can let all blocks Hash value after the change, when the validation so cannot pass) of the total books.
Learn blockchain, build the best blockchain technology blog
WeChat pay