Discussion on the principle of blockchain example Ethereum

Abstract
The essence of blockchain is a decentralized database. It uses the related methods of cryptography to generate data blocks. Each data block contains all the information of a Bitcoin network transaction, so it can be used to verify the validity of its information and generate the next block.
The blockchain format was first applied to Bitcoin. In October 2008, in Satoshi Nakamoto's paper, the words "block" and "chain" were used separately, and were collectively referred to as block-chain when they were widely used, until 2016. Was turned into one word: "blockchain".
Ethereum is an open blockchain platform that enables anyone to create and use decentralized applications based on blockchain technology. Like Bitcoin, no one controls or owns Ethereum, it is an open source project created by many people around the world. Unlike Bitcoin, Ethereum is designed to be flexible and modifiable on demand.
The Ethereum platform applies many technologies related to information security and cryptography, such as timestamps, asymmetric encryption, hash functions, Merkle trees, etc.

one. Ethereum Overview
Ethereum is an open blockchain platform that enables anyone to create and use decentralized applications based on blockchain technology. Like Bitcoin, no one controls or owns Ethereum, it is an open source project created by many people around the world. Unlike Bitcoin, Ethereum is designed to be flexible and modifiable on demand.
The above introduction to Ethereum is official, and I have some understandings after consulting a lot of information. Regarding Bitcoin technology, we can imagine that there is a ledger. This ledger has a characteristic: every participant in the world has its copy, that is, any one records a transaction on it, then the record immediately It will appear on all copies in the world, all participants will know the transaction, and no one can erase any records on the ledger.
Based on the above example, let's introduce a transaction process:
1. Alice wants to transfer 10 bitcoins to Bob.
2.Alice needs to provide Alice's address (obtained by hashing Alice's public key), Bob's address, and the number of transfers. At the same time, Alice signs the transaction with her private key.
3. The transaction is sent to the pool of signed transactions, pending verification.
4. After the system has verified that Alice's account does have wealth greater than 10 bitcoins, the transaction is considered valid.
5. After the verification is completed, the transaction is sent to the verified transaction pool. After all the transactions are verified, they are packaged into a block, which is signed encrypted and added to the blockchain.
6. The blockchain is updated, and all participants download the new blockchain, which means that Alice's transaction is displayed on everyone's ledger.
7. Bob has received 10 bitcoins from Alice at this time.
The above process briefly introduces the principle of Bitcoin, and Ethereum has further developed on this basis, and can create some automatically executed small programs. For example, Alice can add an applet: "If the Thunder wins the Lakers in the NBA game on January 4th, transfer 10 bitcoins to Bob." This applet can automatically obtain the game results after the game, so as to determine whether it needs to be transferred to Bob. The official name for such a small program is a smart contract.
Smart contracts have two features. One is that any participant can check the source code, which ensures credibility. The other is that smart contracts cannot be deleted suddenly. For example, Alice watched the first half of the game and felt that the Thunder was about to win. , I want to go back and delete the applet, but this operation is not allowed.
two. Key Technologies
of Ethereum Ethereum adopts many technologies related to information security and cryptography, roughly 5 of which are Proof of Work (POW), Elliptic Curve Cryptography, Hash Function, Merkle Tree, and Electronic Timestamp Mechanism. 2.1
Proof of Work Proof of Work (POW) is the key technology of blockchain, which is simply used to confirm that you have done a certain amount of work.
The main feature is that the worker needs to do some difficult work to get the result, but the verifier can easily check whether the worker has done the corresponding work based on the result. The process is shown in the figure below.

As shown, the miner on the left needs to solve a cryptographic puzzle to "mine" a block and add it to the blockchain. This process requires a lot of power and computing. In the system, these puzzles have been designed to be difficult and onerous. When a miner solves a puzzle, they publish their block to the network for verification. The person on the right verifies that a block belongs to a chain is a very simple and fast process.
The hash function is also used in the workload proof mechanism. After the miners complete the calculation, they use the Hashcash algorithm as the POW for the calculation result. Other nodes can use the relevant mathematical formula to easily verify whether the value (new block) is efficient.
However, at present, there are many problems with proof of work. First and foremost, proof-of-work is an extremely inefficient system because it consumes a lot of power and energy.
Second, proof-of-work is not ASIC-resistant, which means that people and institutions that can buy faster and more powerful ASIC equipment can generally mine blocks with a higher probability than others.
In response to these shortcomings, Proof of Stake (POS) has been proposed, which will virtualize the entire mining process and replace miners with validators. First, validators must lock up some of the coins they own as a deposit. After this, they will start validating blocks. At the same time, when they find a block that they think can be added to the chain, they validate it by placing a bet. If the block is successfully chained, validators will receive a reward proportional to their stake.

2.2 Elliptic Curve Cryptography

The public key cryptographic algorithm used in the blockchain is an elliptic curve algorithm developed based on the properties of elliptic algebra. The security of elliptic curve algorithms relies on a well-known mathematical problem, the discrete logarithm problem. The encryption and decryption process of elliptic curve cipher is shown in the figure below.
write picture description here

As shown in the figure above, user Alice selects an elliptic curve Ep(a, b), and takes a point on the elliptic curve as the base point P; user A selects a private key k and generates a public key L=kP; user A Send Ep(a, b) and points L and P to user Bob; after receiving the information, user Bob encodes the plaintext to be transmitted to point M on Ep(a, b), and generates a random integer x (x is less than r); user Bob calculates point C1=M+xL, C2=xP; user Bob transmits C1 and C2 to user Alice; user Alice calculates C1-LC2 after receiving the information, and the result is point M.
The emergence of elliptic curve cryptography is also inspired by the RSA algorithm. The advantages of the RSA method are mainly that the principle is simple and easy to use. However, with the progress and perfection of the method of decomposing large integers, the improvement of computer speed and the development of computer networks, the requirements for large integers as a security guarantee for RSA encryption and decryption are increasing. In order to ensure the security of RSA, the number of bits of the key has been increasing. However, the increase of the key length has led to a great decrease in the speed of encryption and decryption, and the hardware implementation has become more and more unbearable. The application of RSA brings a heavy burden, especially for e-commerce that conducts a large number of secure transactions, which makes its application scope more and more restricted.
Compared with the RSA method, the elliptic curve encryption method has the following advantages: (1) The security performance is higher. The security performance of an encryption algorithm is generally reflected by the anti-attack strength of the algorithm. Compared with several other public key systems, ECC has an absolute advantage in anti-attack. For example, 160bitECC and 1024bitRSA have the same security strength. (2) The processing speed is fast. In the private key processing (signature and decryption), ECC is much faster than RSA. (3) The storage space is small, and the key size of ECC is much smaller than that of RSA.

2.3 Merkle Tree
Merkle Tree is mostly used for comparison and verification processing. The user first obtains the Merkle Tree root of the file from a trusted source. Once the root of the tree is obtained, the Merkle tree can be obtained from other sources that are not trusted. Check the received Merkle Tree by its trusted root. If the Merkle Tree is corrupt or bogus, get another Merkle Tree from other sources until you get a Merkle Tree that matches the root of the trusted tree.
Merkle Tree can be regarded as a generalization of the hash table, so its main feature is the main feature of the hash function, that is, a slight change in the input data will cause the result of the Hash operation to change beyond recognition, and the original input is reversed according to the Hash value. The characterization of the data is difficult, so it can be used for verification processing.
The Merkle Tree protocol is arguably critical to the long-term sustainability of Ethereum. The memory space required by nodes that store all the data for all blocks in a blockchain network is growing rapidly. The Merkle Tree protocol enables Ethereum to simply download the block header, confirm the proof-of-work with the block header, and then download only the Merkle tree "branch" associated with its transaction. This allows nodes to securely determine the status of any Bitcoin transaction and the current balance of an account by downloading only a small portion of the entire blockchain.

2.4 Timestamp mechanism
In Ethereum, it is required that all parties involved in the transaction cannot deny their actions. This requires a trusted timestamp on digitally signed transactions, solving a range of practical and legal issues. The workflow of the timestamp service is roughly as follows: first, the user performs hash digest processing on the file data; the user requests a timestamp, and the hash value is passed to the timestamp server; the timestamp server signs the hash value and a date/time record, A timestamp is generated; the timestamp data and file information are bound and returned, and the user can perform the next electronic transaction operation.

2.5 Hash function
First , let’s briefly introduce the hash function. A reliable one-way hash function must have the following characteristics: (1) input data of any length must output a fixed-length hash value; (2) can quickly calculate the hash value (3) Small differences in input data will also lead to large differences in hash values; (4) It is unidirectional, and the original data cannot be deduced from the hash value. Common one-way hash functions include MD4/MD5, SHA-1/SHA-256/SHA-384/SHA-512, RIPEMD/RIPEMD-160, and the Keccak algorithm as a standard SHA-3 series of functions. Among them, MD4/MD5, SHA-1, and RIPEMD have already broken algorithms, and it is not recommended to use them in extremely sensitive environments. Commonly used hash functions in Ethereum are SHA-256, Keccak-256, etc.
write picture description here

As shown in the figure above, each packaged block has a prehash value, which refers to the hash value of the previous block (usually the block header). In Ethereum, the SHA-256 algorithm is used here. When all blocks need to be traversed and verified, the preHash value is used to index to the previous block until the creation block. At the same time, there is another member worthy of attention in the above figure: MRH (Merkle Root Hash), which is the hash value of the root node of the Merkle tree. A certain number of transactions packaged by miners are stored in each block of the blockchain, and the transaction records of the blockchain cannot be tampered with. The detection of whether the transaction in the block has been tampered with is based on whether the value of the root hash of the Merkle tree is consistent.
Merkle tree has been introduced in 2.3. The essence of Merkle tree is a generalized hash table. When we need to verify whether a transaction in the block has been tampered with, we only need to verify the hash of the transaction. At the same time, the Merkle tree has the advantage that we can only verify a part of the large block of data, which greatly reduces the workload.
There are also many places in Ethereum that use hash functions, such as: addresses on the blockchain are obtained by hashing public keys. An Ethereum account address is obtained by computing a public key with the Keccak-256 hashing method. A signature on Ethereum is generated by hashing the private key and the data that needs to be signed.

three. The future of Ethereum

There are still many problems with current Ethereum, such as scalability problems that have always existed. Since Ethereum nodes need to store everything that happens on this blockchain network, the storage cost is very expensive, and this cost may increase with time. Exponential growth as the system expands. In response to this problem, the founder of Ethereum proposed a "sharding" solution. The specific idea is to shard the state in some form, so that multiple applications that are independent in most cases can run in parallel. way of processing. Naturally, we will doubt that after sharding, initiating a transaction will only cause fluctuations among the several nodes involved, and can we still ensure the authenticity of the information they transmit to each other? In response to this problem, Ethereum relies on verification management contracts to ensure authenticity. Every block, and every shard, will be verified and verified by a random and reliable verification management contract. So, if you want to deceive and make a "lying" validator acceptable to the system, you have to break it and take over most of the validators in the system.
Another example is the privacy risk issue. In Ethereum, privacy protection is very important. Currently, the most popular solution to this problem is zk-SNARKs (concise non-interactive zero-knowledge proof). The principle of this solution Yes, letting a prover, without providing any additional useful information, convince the verifier that a certain assertion is correct, is a probabilistic proof rather than a deterministic proof. Taking Alice and Bob as an example, Alice now has a key and she needs to prove to Bob that she owns the key. There are two ways. The first is that Alice gives the key to Bob, and Bob takes the key to open the door. Bob knows that Alice does have the key to enter the door. Another way is that Bob knows that there is an object in the house, he tells Alice, Alice goes to the room and takes it out to Bob to see. Since Alice can do this, Bob knows that Alice has the key to open the door. This second method reflects the idea of ​​zero-knowledge proof. Of course, this is a probabilistic proof, not a deterministic proof.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325391187&siteId=291194637