SDK EBTC Documentation v0.10.
  • Welcome
  • Getting Started
    • Quickstart
    • Overview of Dapps
  • Basics
    • Terminology
    • Contract function
    • Affiliate
    • Blockchain Data Structure
    • Block Reward Update
    • Random Block Rewards
      • The first random block reward of EBTC has been mined! 🎉
    • Hash Algorithm Design of Blockchain
    • System Security Design and Implementation
    • Activate "Anti-Whale"
    • EBTC Beta 01 Airdrop Program
  • Road Map
    • The Future of EBTC
    • Outstanding Features of EBTC
    • Benefits of Holding EBTC
    • EBTC Decentralized Finance
    • EBTC Meme Sniper Tool
    • COMMUNITY
  • Version 2 - WeBTC
    • Wrapped eBTC ( WeBTC )
    • Convert from EBTC to WeBTC
    • BNB & EBTC Staking Mechanism
    • Technology and Infrastructure
    • Vision and Mission
    • Development Roadmap
    • Update soon
Powered by GitBook
On this page
  1. Basics

Hash Algorithm Design of Blockchain

PreviousThe first random block reward of EBTC has been mined! 🎉NextSystem Security Design and Implementation

Last updated 9 months ago

Hash algorithm is an important technology in the field of information technology, which is widely used in blockchain. After binary data of any length is mapped to the hash function, it is converted to fixed-length output, and the output value is the hash value of the data. There are many hash functions, and the hash algorithm is the most widely used in blockchain technology. Using this algorithm, binary data of any length can be converted into hash values of 256 bits and 32 bytes. The hash algorithm has the advantages of unidirectional, random, timing, fixed length, and so on.

  • (1) Unidirectionality: the output data can be easily extracted from the input data, but the input data cannot be calculated from the output data.

  • (2) Randomness: even if the input data is only slightly modified, the output data may change greatly, so different input data will not produce the same hash value.

  • (3) Timing: any input data with different lengths will consume approximately the same time period through the same type of hash calculation.

  • (4) Fixed length: any input data with different lengths can generate output data with the same length after the hash calculation of the same type.

Hash function is usually defined according to the generated hash value. There are two main methods.

Hash based on addition and multiplication is achieved by returning data elements and then adding each initial value associated with the data elements. Usually, the value of an element is multiplied by a prime number.

The following formulas provide a hash calculation method based on addition and multiplication:

(4)

(5)

(6)

(7)

Like additive hashing, shift-based hashing also uses each element of the data string, but unlike additive hashing, shift-based hashing algorithms prefer to transmit data. It is usually a combination of left and right transfer operations, and the number of transfers is the quality. The result of each shift is only some additional aggregation operations, and the final result of shift calculation is the final result of change hash calculation. The formula of the shift hash algorithm is shown in the following formulas:

(8)

(9)

(10)

Merkel is a binary hash tree. In the Merkel tree, each leaf node is the hash value of a transaction. This article takes the Merkel tree with only four leaves as an example.

  • (1) Use the sha256 hash algorithm twice to calculate the hash value of each transaction and calculate the hash value of each transaction. Here, four hash values of HA, HB, HC, and HD can be calculated, that is, the four-leaf nodes of the Merkel tree. article paper takes HA calculation as an example:

  • (2) Combine the hash values of two leaf nodes HA and HB. This article takes HAB calculation as an example:

  • (3) Perform the same combined hash calculation as in step (2) on the existing two hash values HAB and HCD, and finally, get a new hash value HABCD. The calculation of HABCD is as follows:

At present, the workload proof mechanism is considered to be the most efficient blockchain consensus algorithm, but it takes a long time to reach a consensus, which will consume a lot of computing power and resources, so it is not suitable for large-scale promotion and application. The characteristics of various consensus algorithms widely used in blockchain

  1. Comparison of common consensus algorithms.

Feature
PoS
PoW
DPoS
PBFT

Transaction throughput

General

Low

High

High

Fault tolerance

<50%

<50%

<50%

<50%

Single transaction speed

min

10 min

s

ms

Number of supported nodes

Many

Many

Many

Less

Byzantine fault tolerance

Support

Support

Support

Support

Computing resource consumption

General

High

General

Low

Network resource consumption

General

Lower

General

High

(11)

(12)

(13)