What is a tree measure?
The creator of the Hesh-Derev concept is Professor Ralph Merkle. He invented a way to present digital signatures in 1979. Stanford University owns a technology patent for technology.
The scientist suggested using a binary hash-Vreyevo. Merkle also made a significant contribution to the development of cryptography. It is known for the publication of 1987 “Digital signature based on the usual function of encryption”.
Why do you need a tree measure?
The centralized system provides data from one source that all users rely on. The latter guarantees the correctness of the information received.
Blockchain is a distributed database. Information in it is stored on many independent nodes (GCD). Noda cannot accept messages from other participants without checking them. The node must determine whether the block contains correct transactions.
To reduce computational costs, you can use the trees of Mercla. They allow you to reduce the volume of loaded data and optimize their verification due to the hash.
The method is used in bitcoin networks, Ethereum and other cryptocurrencies. With its help, a string of data is obtained, which verifies the transaction group. The algorithm is also used in file systems and databases. With the help of trees, the information is checked for errors and synchronization is carried out.
How the tree works Mercla?
The construction of the tree of the measure is performed from the bottom up. The values in the sheet peaks are done with the hash of data fragments. Nodes of the next level contain a hash from the sum of two subsidiaries. To combine data, concatenation is used. The operation is repeated for the nodes of the following levels until one hash is obtained. If the number of elements is odd, one of them is duplicated or transferred to the next level unchanged.
When building a tree, a single hash is obtained, which is called the root. The latter represents all data fragments. Thus, the tree of the measure is a unidirectional hash function.
The algorithm allows you to build a binary structure in which nodal values are formed from two lines. The last property provides the ability to verify a large amount of data without recalculating hashes for all fragments. Computational costs when determining the authenticity of one element in this case is much lower.
To verify the correctness of the array and its integrity, the root hash must be compared with the reference value. Fragments may be data on transactions or part of files.
How a measure of measure is used in bitcoin?
Bitcoin blockchain is formed from fragments that are recorded at the end of the chain. The latter contain data on translations between users. The number of transactions, as well as the volume of information is changeable, so the block does not have a fixed size.
To optimize calculations, the nodes of bitcoin form headlines. They include the following elements:
-
;
- the hash of the previous block;
- The root of the tree is measured;
- temporary mark;
- the purpose of the complexity of mining;
- one -time code used in the generation of the block.
The title does not include transactions and takes 80 bytes. Since it is formed every ten minutes, the amount of data increases by 4.2 megabytes per year.
Information about transactions is drunk, which allows you to get their identifiers. Translation data are stored in hexadecimal format. Root hash represents all block transactions. To find the latter, a tree is built. Data is processed according to the algorithm:
- There are hashs (identifiers) of transactions included in the block: hash (l1), hash (l2), hash (l3) and so on. They form wood leaves.
- Heshes from the sum of two neighboring identifiers are placed at the next level: Hash (Hash (L1) + Hash (L2)). In a binary tree, the number of nodes at each level should be even. Otherwise, the hash from the last cell is duplicated and placed in an additional element.
- The process of hashing the data amount is repeated until the root is obtained.
The resulting hash confirms the validity of each transaction. When forming a blockchain of the noda, only headlines of previous blocks are used.
In August 2017, the Segregated Witness Protocol was updated. The latter uses another structuring of transaction data, which allows you to reduce the size of the block. The adoption of the update reduced the load on the blockchain bitcoin.
What are the advantages of a tree measure?
The hash-brow can simplify the verification of the transaction affiliation to a particular block and ensure the integrity of information when transmitting it. The method is necessary for simplified verification of payments. Satoshi Nakamoto suggested using SPV in White Paper Bitcoin.
If the node has significant computing resources, it can download all the blocks and find the hash of each transaction. After which the trees of Mercla are formed. The latter allow you to check the integrity of the data and the validity of each operation. If the resources of the unit are limited, it can only request a block header and transaction identifiers.
Light customers load the heading and authentication (proof of merchant) for the verified transaction. They request information at the full node. The authentication path includes hashs from each pair of wood nodes located on the way from the top to the transaction.
To verify the operation, you need to find the root of the measure. The transaction is confirmed if the resulting hash corresponds to the line contained in the block header. It is almost impossible to choose the necessary root in a different set of data, which guarantees the validity of the operation.
The SPV method allows an easy client to effectively interact with the blockchain and reduces the volume of uploaded information. For example, the size of the block with five transactions can be 500 kilobytes, and the proof of Merchal takes only 140 bytes.
What hash wood is used in Ethereum?
The binary tree is well suited for an array presented as a list. Its structure remains unchanged, which is convenient for drifting transactions. Ethereum uses another method of presenting data – a prefix tree.
The latter allows you to store information in an associative array. Lines are keys that determine the provisions of its elements. To form the structure of the branch of the tree are indicated by various symbols so that the element key unambiguously identifies it.
Unlike bitcoin, the Ethereum blockchain uses three hash-derevas:
- transactions;
- states;
- tree containing data on the results of transactions.
The heading of the block includes three root hash. Ethereum allows you to create light customers who are able to perform a basic set of operations:
- Check the presence of a transaction in the block;
- confirm the existence of a certain address;
- determine the balance of the user;
- find out the result of the operation or smart contract.
These actions are carried out without full loading of the blocks. The hash-brow simplifies calculations, which allows you to run light clients on personal computers, laptops and smartphones.
The transactional processing algorithm for Ethereum is similar to such for bitcoin. Interaction with a tree of states is more complex. The key element key will determine the user’s address, and its value represents the balance of the account.
A feature of the hash-dereva is the need for frequent data updating and the need to add and delete addresses. To implement the algorithm, a variable structure is required. Its parameters are limited in order to prevent the DDOS attack that allows the attacker to create too deep a tree. Otherwise, updating the structure and conduct of operations will occupy a considerable time.
The root of the tree should be determined exclusively by data and not depend on its parameters. Accordingly, it is necessary to make updates in any order.
The prefix tree allows you to solve these difficulties. In Ethereum, each element of the structure has 16 subsidiaries. This approach is optimal for coding nodes in hexadecimal format.
In the prefix tree, to obtain the key, it is necessary to specify the symbols corresponding to the branches in a row. They determine the path from the root to the selected element. Key value is dynamic, which allows you to add or delete new nodes.
No Comments