为广大币圈朋友提供币圈基础入门专业知识!
当前位置首页 > 区块链知识> 正文

区块链为啥用hash函数表示,区块链为啥用hash函数来表示

发布时间:2023-12-20-03:40:00 来源:网络 区块链知识 区块   函数   hash

区块链为啥用hash函数表示,区块链为啥用hash函数来表示

区块链为啥用hash函数来表示?这里的hash函数是指散列函数,它是一种将任意长度的消息压缩到固定长度的摘要信息的算法。它的特点是即使对于相同的输入,每次结果都是不同的,而且是不可逆的,因此可以用来确保数据的安全性和完整性。那么,为什么区块链要使用散列函数呢?

1. 安全性:散列函数可以有效地保护区块链中存储的数据,因为它可以防止数据被篡改。比特币的区块链系统就是用散列函数来确保数据安全性的,它的散列函数是SHA-256,能够确保数据的完整性和安全性。

2. 可追溯性:散列函数可以让区块链的每一笔交易都可以追溯,因为它可以将每一笔交易都压缩成一个固定长度的字符串,这样就可以让每一笔交易都可以被追踪和记录。

3. 无法篡改:散列函数也可以防止数据被篡改,因为它是一种不可逆的算法,也就是说,一旦数据被压缩成固定长度的字符串,就无法再恢复成原来的数据,因此数据就无法被篡改。

因此,区块链之所以使用散列函数来表示,是因为它可以有效地保护区块链中存储的数据,使得每一笔交易都可以追溯,还能有效地防止数据被篡改,提高了数据的安全性。
请查看相关英文文档

㈠ What you must understand is the blockchain digital signature mechanism

The blockchain uses the Hash function to ensure that transaction information and address information cannot be tampered with, ensuring the data transmission process. Integrity in the transaction information, but the Hash function cannot achieve non-repudiation of the transaction information (also known as non-repudiation and non-repudiation), which refers to the fact that both parties in the network communication are convinced of the true identity of the participants themselves and the information provided during the information exchange process. That is, all participants cannot deny or deny their true identity, as well as the authenticity of the information provided and the completed operations and commitments). Blockchain uses the digital signature mechanism in public key encryption technology to ensure the non-repudiation of information.

Digital signature mainly includes signature algorithm and verification algorithm. In the signature algorithm, the signer uses his private key to perform a signature operation on the electronic file to obtain the signature ciphertext of the electronic file; in the verification algorithm, the verifier uses the signer's public key to verify the signature ciphertext of the electronic file. operation, and determines the legality of the signature file based on the results of the verification algorithm. During the signing process, only the signer knows his or her private key, and any person who does not know his or her private key cannot forge or correctly sign an electronic document; during the verification process, only a legitimate signed electronic document can effectively pass verification, and any illegal signature None of the files satisfy its validation algorithm.

Commonly used digital signature algorithms include RSA digital signature, DSA digital signature, ECDSA digital signature, Schnorr digital signature and other algorithms.

We will introduce it with RSA digital signature: People may ask what is the difference between RSA signature and encryption? Encryption and signing are both for security reasons, but are slightly different. People often ask whether to use private keys or public keys for encryption and signatures? In fact, they are all confused about the role of encryption and signature. Simply put, encryption is to prevent information from being leaked, and signature is to prevent information from being tampered with.

Example: After A receives the message from B, it needs to reply "received" - RSA signature process:

First: A generates a pair of keys (public key and private key), the private key is not made public and A keeps it to himself. The public key is public and can be obtained by anyone.

Then: A signs the message with its own private key to form a signature, and passes the signed message and the message itself to B.

Finally: After B receives the message, it obtains A's public key to verify the signature. If the content of the signature is consistent with the message itself, it proves that the message is replied by A.

In this process, there are only two transfer processes. The first time is when A transfers the signed message and the message itself to B, and the second time is when B obtains A's public key, even if both are defeated by the enemy. There is no danger if Party A intercepts the message, because only A's private key can sign the message. Even if the message content is known, a signed reply cannot be forged to B, preventing the message content from being tampered with.

In summary, from books and the Internet, we have an intuitive understanding.

㈡ What is the hashing algorithm in the blockchain?

What is the hashing algorithm? How to ensure the fairness of mining? The hash algorithm is a cryptographic algorithm that can only encrypt but cannot decrypt. It can convert information of any length into a fixed-length string. This string has two characteristics: 1. Even if the input value changes only a little, the output hash value will be completely different. 2. Only exactly the same input values ​​can get exactly the same output values. 3. There is no pattern between the input value and the output value, so the input value cannot be calculated from the output value. To find the specified output value, you can only use the enumeration method: constantly replace the input value and find the output value that meets the conditions. The hashing algorithm ensures that the results of Bitcoin mining cannot be reversed. Therefore, miners continue to perform calculations, essentially brute force the correct input value, and whoever finds it first will be rewarded with bitcoins.

㈢What is the blockchain hash algorithm?

The hash algorithm is also called "hash" and is one of the four core technologies of the blockchain. It is an algorithm that can calculate a fixed-length string (also called message digest) corresponding to a digital message. Since a piece of data has only one hash value, the hash algorithm can be used to check the integrity of the data. The use of hashing algorithms is very common in the application of fast search and encryption algorithms.

In the Internet age, although the distance between people is closer, the trust problem has become more serious. The technical architecture of existing third-party intermediary organizations is private and centralized. This model can never fundamentally solve the problems of mutual trust and value transfer. Therefore, blockchain technology will use a decentralized database architecture to complete data interaction trust endorsement and achieve a major step forward in global mutual trust. In this process, hashing algorithms play an important role.

The hash algorithm is a one-way cryptographic machine in the blockchain that ensures that transaction information is not tampered with.system. Blockchain uses a hashing algorithm to encrypt transactions in a transaction block and compress the information into a hash string consisting of a series of numbers and letters. The blockchain’s hash value uniquely and accurately identifies a block. When verifying the authenticity of a block, you only need to simply calculate the hash value of the block. If there is no change, it means that the information on the block has not been tampered with.

The Xueshuo Innovation Blockchain Technology Workstation under Lianqiao Education Online is the only "Smart Learning Factory 2020- Xueshuo Innovation Workstation" launched by the School Planning and Construction Development Center of the Ministry of Education of China. Approved "Blockchain Technology Professional" pilot workstation. The professional base is based on providing students with diversified growth paths, promoting the reform of the training model integrating professional degree research, production, and research, and building an applied and compound talent training system.

㈣ What is the difference between the hash values ​​of currency withdrawals from exchanges and wallet withdrawals

Hash functions play a vital role in the blockchain. Its approach is to encrypt and compress complex transaction information into a simple fixed-byte hash value, which becomes the identifier of the blockchain and ensures that the transaction information in the blockchain is not tampered with. This algorithm is also used in some important links, such as connecting adjacent blocks, building merkle trees, transaction verification, digital signatures, etc.





1. Concept


Hash: Hash, generally translated as "Hash", Or directly transliterated as "Hash", it converts an input of any length into an output of a fixed length through a hash algorithm, and the output is a hash value. Simply put, it compresses a message of any length into a message of a certain fixed length. Summary function. The hash algorithm and hash function we often say usually mean the same thing.


2. Principle


Based on a one-way hash function in cryptography, y=hash(x) is usually used in the industry express. This hash function can calculate a hash value Y by operating x. This function is easy to verify, but difficult to crack. It is easy to calculate Y from x, but it is difficult to derive x from Y. That is, only Encryption process, no decryption process.





3. Characteristics


(1) The encryption process is irreversible, that is Say we can't deduce what the original plaintext was from the hash value of the output.


(2) The input plaintext and the output hash value are in one-to-one correspondence. Any change in input information will inevitably lead to changes in the final output hash value.


(3) For any size input, the length of the final calculated hash value is small and fixed length.


(4) It is difficult to make the hash value of two plaintexts with different contents the same. That is, it is extremely unlikely that any two different blocks of data will have the same hash value.


4. SHA256 algorithm


Commonly used hash algorithms include MD5, SHA-1, SHA-256, SHA-384 and SHA- 512. In blockchain, the SHA-256 algorithm is commonly used for block encryption. For any message of any length, SHA-256 will generate a 256-bit hash value, which is called the message digest. This abstraction is equivalent to an array of length 32 bytes, usually with length 64 in hexadecimal The string representation is the 64 characters we see.


Blockchain uses this algorithm to encrypt transaction information in a transaction block and convert the compressed information into a hash consisting of a string of numbers and letters (haha Greek) string. The hash value of the blockchain can uniquely and accurately identify a block, and any node can obtain the hash value of this block through simple hash calculation. The calculated hash value is unchanged, which means the information in the block has not been tampered with.


The following is an example of encrypting plaintext into a hash value.





Then change the period to an exclamation point, and the hash value changes completely.





5. Hash Pointer (Hash Pointer)


Hash pointer means The value of this variable is calculated from the actual data and points to the location of the actual data. That is to say, the hash pointer can represent both the storage location of the actual data and the actual data content (the data hash value of a certain timestamp).


To sum up, looking at the structure of the blockchain from the perspective of hash pointers, it can be said that the blockchain is a linked list that connects data blocks in chronological order with hash pointers. The pointer is actually a hash value of a string of data. The hash value of a string of data is the "fingerprint" and abstraction of the string of data, so you can use this hash value to point to this string of data.


Each block in the blockchain has a hash pointer corresponding to its own block. Except for the creation block (i.e. the first block), each other block stores the information of the previous block. hash pointer, thus forming a chain as shown below, that is, a blockchain.





Such a data structure can ensure that the data is not tampered with, because once the data in any block is tampered with, the corresponding hash pointer will be An error will occur, so the followingThe hash pointer of the block cannot match the hash pointer generated by the block after the data is tampered with, so it can be detected once malicious tampering occurs.

㈤ What is the hash value in the blockchain?

The hash value in the blockchain is the process of converting an input string of any length into a password and making a fixed output . The hash value is not a "password" and the original data cannot be retrieved by decrypting the hash, it is a one-way cryptographic function.

In a blockchain, each block has the hash of the previous block. When any data in the current block is changed, the hash of the block will be changed, which will affect the previous block because it has the address of the previous block. For example, if there are only two blocks, one is the current block and the other is the parent block. The current block will have the address of the parent block, and if the data in the current block needs to be changed, the parent block will also need to be changed.

A cryptographic hash function needs to have the following key characteristics to be considered useful

1. Each hash The values ​​are all different.

2. For the same message, the same hash value is always generated.

3. It is impossible to determine the input based on the hash value.

4. Even a small change to the entire hash value of the input will be changed.

㈥ Hash algorithm in blockchain

Hash algorithm is the most important underlying technology in blockchain. It is a method used to identify transaction data and is unique. A cryptographic hash algorithm is a "fingerprint" of the data.

The cryptographic hash algorithm has 5 major characteristics:
1. It can quickly create hash values ​​for any type of data.
2. Certainty. Hash algorithms always produce the same hash value for the same input data.
3. Pseudo randomness. When the input data is changed, the hash value returned by the hash algorithm changes unpredictably. It is impossible to predict the hash value based on the input data.
4. One-way function. It is not possible to recover the original input data based on the hash value. It is impossible to learn anything about the input data based on the hash value alone.
5. Anti-collision. The chances of different blocks of data producing the same hash value are slim.

㈦ What is the role of the hash algorithm in the blockchain?

Jin Wowo explained: The blockchain is encrypted using a hash algorithm, and the hash algorithm is the key to the blockchain. A single password mechanism to ensure that transaction information is not tampered with.
After the hash algorithm receives a piece of plaintext, it converts it into a piece of hash data with a shorter length and a fixed number of digits in an irreversible way.

㈧ What is the hash algorithm in blockchain technology

1.1. Introduction

Practitioners in the computer industry should be very familiar with the word hash, ha Hash can map data from one dimension to another, usually using a hash function to achieve this mapping. Usually the industry uses y =Represented in the form of hash(x), this hash function implements operations on x to calculate a hash value y.
Characteristics of hash functions in blockchain:

Function parameters are string type;

Fixed size output;

Efficient calculation;

collision-free means that the probability of conflict is small: Verification of transactions only requires verifying the information entropy of the transaction, without comparing the original information. There is no need to transmit the original data of the transaction between nodes, only the hash of the transaction. Common algorithms include the SHA series and MD5 algorithms

1.2. Usage of hash

Hash is widely used in blockchain, one of which is called Hash Pointer
Ha The hash pointer means that the value of the variable is calculated based on the actual data and points to the location of the actual data, that is, it can represent both the actual data content and the storage location of the actual data. The picture below is a schematic diagram of the Hash Pointer


㈨ What is the role of the hash algorithm in the blockchain?

The blockchain uses the hash algorithm to The transaction information in a transaction block is encrypted and compressed into a hash string consisting of a series of numbers and letters.
Jinwowo Group analyzes the role of its hash algorithm as follows:
The hash value of the blockchain can uniquely and accurately identify a block. Any node in the blockchain can calculate it through a simple hash All have received the hash value of this block, and the calculated hash value has not changed, which means that the information in the blockchain has not been tampered with.

㈩ What is the use of hash function in blockchain?

Hash function, also called hash function and hash algorithm, is a method of creating small data from any kind of data. Digital "fingerprint" (also called digest) method. What does that mean? That is to say, you input data of any length and content, and the hash function outputs a fixed-length, fixed-format result. This result is similar to the fingerprint of the data you input. As long as the input changes, the fingerprint will definitely change. Different content has different fingerprints obtained through the hash function. This is the hash function.

In the distributed ledger, in order to ensure data integrity, hash values ​​are used for verification. For example, a transaction or a page of ledger (that is, the concept of a block) uses a hash to generate a summary, which means that the entire block transaction information cannot be tampered with (that is, the summary cannot be kept unchanged after tampering with the data).

The original definition or narrow understanding of blockchain is the form of block + chain. This chain is linked through hashing. Each block may have many transactions, and the entire block can pass Hash functionThe number generates summary information, and then stipulates that each block needs to record the summary information of the previous block, so that all blocks can be connected into a chain.

If the data of a certain block in history is changed, it means that the block digest value (i.e. hash value) will change, then the hash of the previous block recorded in the next block Corresponding modifications must be made, and so on, that is to say, if you want to modify historical records, all records from that point forward must be modified to ensure the legitimacy of the ledger. The hash function increases the risk of ledger tampering. Difficulty.

The Xueshuo Innovation Blockchain Technology Workstation under Lianqiao Education Online is the only "blockchain technology" approved by the "Smart Learning Workshop 2020- Xueshuo Innovation Workstation" carried out by the School Planning and Construction Development Center of the Ministry of Education of China. Professional” pilot workstation. The professional base is based on providing students with diversified growth paths, promoting the reform of the training model integrating professional degree research, production, and research, and building an applied and compound talent training system.

博客主人唯心底涂
男,单身,无聊上班族,闲着没事喜欢研究股票,无时无刻分享股票入门基础知识,资深技术宅。
  • 39500 文章总数
  • 3637499访问次数
  • 3092建站天数