区块链的加密算法 哈希函数,区块链的哈希
近年来,随着区块链技术的发展,哈希函数作为一种加密算法在区块链中发挥着重要作用。本文将介绍哈希函数、哈希拓展和比特币的关系,以帮助读者更好地理解哈希函数在区块链中的作用。
一、哈希函数哈希函数是一种加密算法,它的主要作用是将任意长度的输入数据映射成固定长度的输出数据,这种输出数据被称为哈希值。哈希函数最常用的是SHA-256,它是一种单向函数,可以将任意长度的输入数据映射成256位的输出结果,同时这个输出结果是不可逆的,也就是说无法根据输出结果推断出输入数据,这也是哈希函数最主要的作用。
二、哈希拓展哈希拓展是一种基于哈希函数的技术,它可以将一个哈希值映射成一个更大的哈希值,其原理是将输入的哈希值作为输入数据,再经过一系列的哈希函数运算,将其映射成一个更大的哈希值。哈希拓展的主要作用是可以将输入的哈希值映射成更大的哈希值,从而提高安全性,防止被破解。
三、比特币与哈希函数比特币是一种基于区块链技术的数字货币,其安全性非常高,这也得益于哈希函数的使用。比特币使用SHA-256作为其哈希函数,将每一个交易记录都通过哈希函数计算出一个哈希值,将这个哈希值作为交易记录的唯一标识,从而保证了比特币的安全性。此外,比特币还使用了哈希拓展技术,将每一个交易记录的哈希值映射成一个更大的哈希值,这样一来,就可以更好地保证比特币的安全性。
以上就是本文关于哈希函数、哈希拓展和比特币的关系的介绍,希望能够帮助读者更好地理解哈希函数在区块链中的作用。
请查看相关英文文档
(I) Encryption technology of blockchain
Digital encryption technology is the key to the application and development of blockchain technology. Once the encryption method is cracked, the data security of the blockchain will be challenged, and the tamperability of the blockchain will no longer exist. Encryption algorithms are divided into symmetric encryption algorithms and asymmetric encryption algorithms. Blockchain primarily uses asymmetric encryption algorithms. Public key cryptography systems in asymmetric encryption algorithms are generally divided into three categories according to the problems they are based on: large integer differentiation problems, discrete logarithm problems and elliptic curve problems. First, introduce blockchain encryption technology. Encryption algorithms are generally divided into symmetric encryption and asymmetric encryption. Asymmetric encryption refers to encryption technology integrated into the blockchain to meet security requirements and ownership verification requirements. Asymmetric encryption usually uses two asymmetric keys, called public and private keys, in the encryption and decryption process. Asymmetric key pairs have two characteristics: First, after one key (public key or private key) encrypts information, it can only decrypt the other corresponding key. Second, the public key can be disclosed to others, while the private key is kept confidential, and others cannot calculate the corresponding private key through the public key. Asymmetric encryption is generally divided into three main types: large integer differentiation problems, discrete logarithm problems and elliptic curve problems. The problem class of large integer differentiation refers to using the product of two large prime numbers as the encrypted number. Since the appearance of prime numbers is irregular, solutions can only be found through constant trial calculations. The discrete logarithm problem class refers to an asymmetric distributed encryption algorithm based on the difficulty of discrete logarithms and strong one-way hash functions. Elliptic curve refers to the use of flat elliptic curves to calculate a set of asymmetric special values. Bitcoin uses this encryption algorithm. The application scenarios of asymmetric encryption technology in blockchain mainly include information encryption, digital signature and login authentication. (1) In the information encryption scenario, the sender (denoted as A) encrypts the information with the public key of the receiver (denoted as B) and sends it to
B, who uses his own private key Decrypt the information. Encryption of Bitcoin transactions falls into this scenario. (2) In a digital signature scenario, sender A uses its own private key to encrypt the information and sends it to B. B uses A's public key to decrypt the information and then ensures that the information was sent by A. (3) In the login authentication scenario, the client uses the private key to encrypt the login information and sends it to the server. The server then uses the client's public key to decrypt the authenticated login information. Please note the differences between the above three encryption schemes: information encryption is public key encryption and private key decryption, ensuring the security of the information; digital signature is private key encryption and public key decryption, ensuring the ownership of the digital signature. Authenticated private key encryption and public key decryption. Taking the Bitcoin system as an example, its asymmetric encryption mechanism is shown in Figure 1: The Bitcoin system generally generates a 256-bit random number as a private key by calling the random number generator at the bottom of the operating system. The total number of Bitcoin's private keys is large, and it is extremely difficult to traverse all private key spaces to obtain Bitcoin's private keys, so cryptography is safe. For ease of identification, the 256-bit binary Bitcoin private key will be hashed using the SHA256 algorithm and Base58Convert to form a 50-character long private key, which is easy for users to identify and write. Bitcoin's public key is a 65-byte random number generated by the private key through the Secp256k1 elliptic curve algorithm. Public keys can be used to generate addresses used in Bitcoin transactions. The generation process is that the public key is first hashed through SHA256 and RIPEMD160 to generate a 20-byte summary result (that is, the result of Hash160), and then converted through the SHA256 hash algorithm and Base58 to form a 33-character Bitcoin address. The public key generation process is irreversible, that is, the private key cannot be derived from the public key. Bitcoin’s public and private keys are usually stored in Bitcoin wallet files, with the private key being the most important. Losing the private key means losing all the Bitcoin assets of the corresponding address. In the existing Bitcoin and blockchain systems, multi-private key encryption technology has been derived based on actual application requirements to meet more flexible and complex scenarios such as multi-signatures.
㈡Blockchain Technology
Background: After the birth of Bitcoin, it was discovered that the technology was very advanced, and blockchain technology was discovered. Bitcoin and blockchain technology were discovered at the same time.
1.1 The purpose of the birth of Bitcoin:
①Currency transactions have records, that is, ledgers;
②The disadvantages of centralized institution accounting - it can be tampered with; Yi Chaofa
Bitcoin solves the first problem: anti-tampering - hash function
1.2 hash function (encryption method)
① Function: convert any A string of length, converted to a fixed-length (sha256) output. The output is also called a hash value.
② Features: It is difficult to find two different x and y such that h(x)=h(y).
③Application: md5 file encryption
1.3 Blockchain
①Definition
Block: Split the general ledger into zones Block storage
Blockchain: On each block, add a block header. It records the hash value of the parent block. By storing the hash value of the parent block in each block, all blocks are connected in order to form a blockchain.
②How does the blockchain prevent transaction records from being tampered with?
After the blockchain is formed, tampering with any transaction will cause the hash value of the transaction block to be different from that of its sub-blocks. , tampering was discovered.
Even if you continue to tamper with the hash value in the sub-block header, the hash value in the sub-block will be different from that in the grandchild block, and the tampering will be discovered.
1.4 The essence of blockchain
①The essence of Bitcoin and blockchain: a big ledger visible to everyone, onlyRecord the transaction.
②Core technology: Through cryptographic hash function + data structure, it ensures that the ledger records cannot be tampered with.
③Core function: Create trust. Fiat currency relies on government credibility, and Bitcoin relies on technology.
1.5 How to trade
①To conduct transactions, you need an account number and password, corresponding to the public key and private key
Private key: a string of 256-bit binary numbers , no application is required to obtain it, and you don’t even need a computer. You can generate the private key by tossing a coin 256 times.
The address is converted from the private key. The address cannot reverse the private key.
The address is the identity, which represents the ID in the Bitcoin world.
After an address is generated, it can only be known by everyone if it enters the blockchain ledger.
②Digital signature technology
Signature function sign (Zhang San’s private key, transfer information: Zhang San transfers 10 yuan to Li Si) = signature of this transfer
< p> Verify Korean verify (Zhang San’s address, transfer information: Zhang San transfers 10 yuan to Li Si, signature of this transfer) = TrueZhang San uses his own signature function sign() The private key signs this transaction.
Anyone can verify whether the signature was issued by Zhang San himself who holds Zhang San's private key by verifying the Korean vertify(). It returns true, otherwise it returns false.
sign() and verify() are cryptographically guaranteed not to be cracked. ·
③Complete the transaction
Zhang San will provide the transfer information and signature to the entire network. Under the premise that the account has a balance, after verifying that the signature is true, it will be recorded in the blockchain ledger. Once recorded, Zhang San's account will be reduced by 10 yuan, and Li Si's account will be increased by 10 yuan.
Supports one-to-one, one-to-many, many-to-one, and many-to-many transactions.
In the Bitcoin world, private keys are everything! ! !
1.6 Centralized Accounting
① Advantages of Centralized Accounting:
a. No matter which center keeps accounts, don’t worry too much
< p> b. Centralized accounting, high efficiency②Disadvantages of centralized accounting:
a Denial of service attack
b Stop service after getting tired
p>c Central institutions are vulnerable to attacks. For example, destroying servers and networks, committing theft, legal termination, government intervention, etc.
HistoryAll attempts at confidential currencies with centralized institutions have failed.
Bitcoin solves the second problem: how to decentralize
1.7 Decentralized accounting
①Decentralization: Everyone can keep accounts. Everyone can keep a complete ledger.
Anyone can download open source programs, participate in the P2P network, monitor transactions sent around the world, become an accounting node, and participate in accounting.
② Decentralized accounting process
After someone initiates a transaction, it is broadcast to the entire network.
Each accounting node continues to monitor and continue transactions across the entire network. When a new transaction is received and the accuracy is verified, it is put into the transaction pool and continues to be propagated to other nodes.
Due to network propagation, the transactions of different accounting nodes at the same time are not necessarily the same.
Every 10 minutes, one person is selected from all accounting nodes in a certain way, and his transaction pool is used as the next block and broadcast to the entire network.
Other nodes delete the transactions that have been recorded in their own transaction pool based on the transactions in the latest block, continue accounting, and wait for the next selection.
③ Features of decentralized accounting
A block is generated every 10 minutes, but not all transactions within these 10 minutes can be recorded.
The accounting node that obtains the accounting rights will be rewarded with 50 Bitcoins. After every 210,000 blocks (approximately 4 years), the reward is halved. The total amount is about 21 million, and it is expected to be mined in 2040.
Recording the reward of a block is also the only way to issue Bitcoin.
④ How to allocate accounting rights: POW (proof of work) method
Compete for accounting rights by calculating mathematical problems on several accounting points.
Find a random number that makes the following inequality true:
There is no other solution except traversing the random numbers starting from 0 and trying your luck. The process of solving the problem is also called mining.
Whoever solves the problem correctly first will get the accounting rights.
If a certain accounting node finds the solution first, it will announce it to the entire network. After other nodes verify that it is correct, a new round of calculation will start again after the new block. This method is called POW.
⑤ Difficulty adjustment
The generation time of each block is not exactly 10 minutes
As Bitcoin develops, the computing power of the entire network does not increase.
In order to cope with changes in computing power, every 2016 blocks (About 2 weeks), the difficulty will be increased or decreased so that the average time for each block to be generated is 10 minutes.
#欧易OKEx# #BTC[超话]# #digital currency#
㈢ The entire system of the blockchain uses a large number of cryptographic algorithms, which is relatively representative. is the hashing algorithm used for PoW.
The entire system of the blockchain uses a large number of cryptographic algorithms, and the more representative one is the hash algorithm used for PoW. Zheng Zheng doesn’t know how to solve the problem. For this reason, the editor will collect and organize for everyone. The entire system of blockchain uses a large number of cryptographic algorithms, and the more representative one is the hash algorithm used for PoW. If you are interested, come and take a look at the solution.
The entire system of the blockchain uses a large number of cryptographic algorithms, and the more representative one is the hash algorithm used for PoW.
A. Correct
B. Wrong
Correct answer: A
The encryption algorithm in blockchain technology plays a crucial role. In addition to hashing algorithms for PoW, there are also symmetric and asymmetric encryption algorithms for encrypted data transmission, digital signature algorithms, etc. These algorithms ensure the security, immutability and anonymity of the blockchain.
㈣ What are the core blockchain technologies of blockchain technology?
What is the hottest Internet topic at the moment? You don’t need to tell me what the editor knows, then It is blockchain technology, but many friends have only heard of this technology and do not have much in-depth understanding of it. So what are the blockchain technologies? Below we will bring you an introduction to the core technology of blockchain for your reference.
What are the core elements of blockchain technology?
Blockchain technology, which can be a public ledger (visible by anyone) or a permissioned network (visible only by those authorized), solves supply chain challenges , because it is an immutable record that is shared among network participants and updated in real time.
Blockchain technology----data layer: designing the data structure of the ledger
Core technology 1. Block + chain:
Technically speaking, block is a data structure that records transactions. Reflects the flow of funds for a transaction. The blocks of transactions that have been reached in the system are connected together to form a main chain, and all nodes participating in the calculation record the main chain or part of the main chain.
Each block consists of a block header and a block body. The block body is only responsible for recording all transaction information in the previous period, mainly including the number of transactions and transaction details; the block header encapsulates the current version number, previous A block address, timestamp (recording the time when the block was generated, accurate to seconds), random number (recording the value of decrypting the answer to the math question related to the block), target hash value of the current block, and Merkle number Root value and other information. From a structural point of view, most functions of the blockchain are implemented by the block header.
Core technology 2. Hash function:
The hash function can convert anyData of arbitrary length is converted into a set of fixed-length codes through the Hash algorithm. The principle is based on a cryptographic one-way hash function. This function is easy to verify, but difficult to crack. Usually, the industry uses y=hash(x) to represent it. This hash function implements operations on x to calculate a hash value y.
Commonly used hash algorithms include MD5, SHA-1, SHA-256, SHA-384 and SHA-512, etc. Taking the SHA256 algorithm as an example, inputting any string of data into SHA256 will result in a 256-bit Hash value (hash value). Its characteristics: the same data input will get the same result. As long as the input data changes slightly (for example, a 1 becomes a 0), a completely different result will be obtained, and the result cannot be predicted in advance. Forward calculation (calculating the corresponding Hash value from the data) is very easy. Reverse calculation (cracking) is extremely difficult and is considered impossible under current technological conditions.
Core technology 3. Merkle tree:
Merkle tree is a hash binary tree, which can be used to quickly verify the integrity of large-scale data. In the blockchain network, the Merkle tree is used to summarize all transaction information in a block, and ultimately generates a unified hash value of all transaction information in the block. Any change in transaction information in the block will cause Merkle tree changes.
Core technology 4. Asymmetric encryption algorithm:
Asymmetric encryption algorithm is a key secret method that requires two keys: public key and private key. The public key and the private key are a pair. If the public key is used to encrypt data, only the corresponding private key can be used to decrypt it, thereby obtaining the corresponding data value; if the private key is used to sign the data, then only the corresponding public key can be used to sign the data. In order to verify the signature, the sender of the verification information is the holder of the private key.
Because encryption and decryption use two different keys, this algorithm is called an asymmetric encryption algorithm, while symmetric encryption uses the same key in the encryption and decryption processes.
Blockchain technology----network layer: realize the decentralization of accounting nodes
Core technology 5. P2P network:
P2P network (peer-to-peer network), also known as point-to-point technology, is no Central server, Internet system that relies on user groups to exchange information. Unlike a centralized network system with a central server, each client in a peer-to-peer network acts as both a node and a server. Domestic Xunlei software uses P2P technology. The P2P network has the characteristics of decentralization and robustness.
Blockchain technology----Consensus layer: allocate the task load of accounting nodes
Core technology 6. Consensus mechanism:
Consensus mechanism is how to reach consensus among all accounting nodes to identify The validity of a record is both a means of identification and a means of preventing tampering. There are currently four main types of consensus mechanisms: PoW, PoS, DPoS and distributed consensus algorithms.
PoW(ProofofWork, proof of work): PoW mechanism, which is like Bitcoin’s mining mechanism, miners package existing transactions that have not been recorded by the network into a block, and then continue to traverse and try to find a random number, so that the new block can be added The hash value of the above random number meets certain difficulty conditions. Finding a random number that meets the conditions is equivalent to determining the latest block of the blockchain, and is also equivalent to obtaining the current round of accounting rights of the blockchain. Miners broadcast blocks that meet the mining difficulty conditions in the Yuanfu network. After verifying that the block meets the mining difficulty conditions and that the transaction data in the block meets the protocol specifications, other nodes in the entire network will each Blocks are linked to their own version of the blockchain, thereby forming a network-wide consensus on the current network state.
PoS (ProofofStake, Proof of Stake): PoS mechanism requires nodes to provide proof of a certain number of tokens to obtain a distributed consensus mechanism for competing for blockchain accounting rights. If you rely solely on the token balance to determine the bookkeeper, you will inevitably make the rich win, which will lead to the centralization of bookkeeping rights and reduce the fairness of the consensus. Therefore, different PoS mechanisms use different methods to increase the amount of money based on the proof of equity. The randomness of accounting rights avoids centralization. For example, in the PeerCoin PoS mechanism, the Bitcoin with the longest chain age has a greater chance of obtaining accounting rights. NXT and Blackcoin use a formula to predict the next accounting node. The more tokens you own, the greater the probability of being selected as an accounting node. In the future, Ethereum will also switch from the current PoW mechanism to a PoS mechanism. Judging from the information currently available, Ethereum's PoS mechanism will use nodes to place bets on the next block. The winner of the bet will receive an additional Ethereum currency award. Those who do not win will be deducted Ether coins to reach consensus on the next block.
DPoS (DelegatedProof-Of-Stake, share authorization certificate): DPoS is easy to understand and is similar to the modern corporate board of directors system. The DPoS mechanism adopted by BitShares is that shareholders vote to select a certain number of witnesses. Each witness has two seconds of authority to generate blocks in order. If the witness cannot generate a block within the given time slice, The block generation authority is given to the witness corresponding to the next time slice. Shareholders can replace these witnesses at any time by voting. This design of DPoS makes the generation of blocks faster and more energy-saving.
Distributed Consistency Algorithm: Distributed Consistency Algorithm is based on traditional distributed consistency technology. Among them are Byzantine fault-tolerant algorithms that solve the Byzantine Generals problem, such as PBFT (Byzantine fault-tolerant algorithm). In addition, distributed consensus algorithms (Pasox, Raft) that solve non-Byzantine problems are not explained in this article. This type of algorithm is currently a commonly used consensus mechanism in alliance chain and private chain scenarios.
Taken together, POW is suitable for public chains. If you build a private chain, because there is no trust problem with verification nodes, POS can be more suitable; and the allianceSince the chain has untrusted local nodes, it is more appropriate to use DPOS.
Blockchain technology----Incentive layer: Develop a "salary system" for accounting nodes
Core technology 7. Issuance mechanism and incentive mechanism:
Take Bitcoin as an example. Bitcoins are initially rewarded by the system to miners who create new blocks, and this reward is halved approximately every four years. At the beginning, miners were rewarded with 50 Bitcoins for each new block recorded, and this reward is halved approximately every four years. By analogy, by around AD 2140, newly created blocks will no longer receive rewards from the system. By then, the total number of Bitcoins will be approximately 21 million. This is the total number of Bitcoins, so it will not increase indefinitely.
Another source of incentives is transaction fees. When there are no system rewards for newly created blocks, the miners' income will change from system rewards to transaction fees. For example, when you transfer, you can specify 1% of it as a handling fee to be paid to the miner who records the block. If the output value of a transaction is less than the input value, the difference is the transaction fee, which will be added to the incentive for that block. As long as a given amount of electronic currency has entered circulation, the incentive mechanism can gradually be converted to rely entirely on transaction fees, so there is no need to issue new currency.
Blockchain technology----contract layer: giving the ledger programmable features
Core technology 8. Smart contract:
Smart contract is a set of programmed rules and logic that respond to scenarios. Implemented by decentralized, trusted shared script code deployed on the blockchain. Normally, after the smart contract is signed by all parties, it is attached to the blockchain data in the form of program code, and is recorded in a specific block of the blockchain after being propagated through the P2P network and verified by nodes. Smart contracts encapsulate a number of predefined states and transition rules, scenarios that trigger contract execution, response actions under specific scenarios, etc. The blockchain can monitor the status of smart contracts in real time, and activate and execute the contract by checking external data sources and confirming that specific trigger conditions are met.
The above is what blockchain technologies the editor has brought to you? All content introduced to the core technology of blockchain.
㈤ 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. NoThe chance that the same data block will produce the same hash value is very small.
㈥ The cryptographic technology of blockchain includes
Cryptography technology is the core of blockchain technology. The cryptographic technology of blockchain includes digital signature algorithm and hash algorithm.
Digital Signature Algorithm
Digital signature algorithm is a subset of the digital signature standard, representing a specific public key algorithm used only for digital signatures. The key is run on the message hash generated by SHA-1: to verify a signature, the hash of the message is recalculated, the signature is decrypted using the public key and the results are compared. The abbreviation is DSA.
Digital signature is a special form of electronic signature. So far, at least more than 20 countries have passed laws recognizing electronic signatures, including the European Union and the United States. my country's electronic signature law was adopted at the 11th meeting of the Standing Committee of the 10th National People's Congress on August 28, 2004. . A digital signature is defined in the ISO 7498-2 standard as: “Some data appended to a data unit, or a cryptographic transformation made to the data unit, which allows the recipient of the data unit to confirm the source and origin of the data unit. The integrity of the data unit and protects the data from forgery by a person (e.g. the recipient)”. The digital signature mechanism provides an identification method to solve problems such as forgery, denial, impersonation and tampering. It uses data encryption technology and data transformation technology to enable both parties to send and receive data to meet two conditions: the receiver can identify what the sender claims. Identity; the sender cannot later deny that it sent the data.
Digital signature is an important branch of cryptography theory. It is proposed to sign electronic documents to replace handwritten signatures on traditional paper documents, so it must have 5 characteristics.
(1) The signature is credible.
(2) The signature cannot be forged.
(3) Signatures are not reusable.
(4) Signed documents are immutable.
(5) The signature is non-repudiation.
Hash algorithm
Hash is to convert an input of any length (also called pre-mapping, pre-image) into a fixed-length output through a hash algorithm. The output is a hash. value. This transformation is a compressed mapping in which the space of hash values is usually much smaller than the space of inputs. Different inputs may hash to the same output, but the input values cannot be deduced in reverse. Simply put, it is a function that compresses a message of any length into a message digest of a fixed length.
Hash algorithm is a one-way cryptographic system, that is, it is an irreversible mapping from plaintext to ciphertext, with only encryption process and no decryption process. At the same time, the hash function can change an input of any length to obtain a fixed-length output. The one-way characteristic of the hash function and the fixed length of the output data make it possibleto generate messages or data.
Represented by the Bitcoin blockchain, secondary hashing is used many times in the workload proof and key encoding process, such as SHA (SHA256(k)) or RIPEMD160 (SHA256(K)). This The advantage of this method is that it increases the workload or increases the difficulty of cracking if the protocol is not clear.
Represented by the Bitcoin blockchain, the two main hash functions used are:
1.SHA-256, mainly used to complete PoW (proof of work) calculations;
2.RIPEMD160, mainly used to generate Bitcoin addresses. As shown in Figure 1 below, the process of generating an address from a public key for Bitcoin.
㈦ Blockchain: Tamper-proof Hash Encryption Algorithm
Students A and B toss a coin in the classroom and bet on who will clean the house. If the head comes up, A will clean the house, and if it lands tail, A will clean the house. If it's facing up, then B sweeps. There's nothing wrong with this strategy.
However, if the scenario is transferred to an online chat room, and A and B also play a coin tossing game, B will probably not agree, because when A tosses the coin, B will not guess.
Heads or tails, A can say that B guessed wrong.
How to solve this problem? How about encrypting the result of the coin toss first, and then B guesses? You can try this method.
Assume that any odd number represents the front side of the coin, and any even number represents the tail side. A wants a number 375, then multiplies it by 258, tells B the result is 96750, and declares that the 375 A wants is the key, which he keeps for safekeeping.
When verifying the result next, A can lie and claim that 258 is the number he wants and 375 is the key, and A is still invincible. What if A tells B the key in advance? B can directly calculate the original number, losing the confidentiality function.
This method of knowing the encryption method and knowing the decryption method obviously does not work. Is there a way to know the encryption method and still not be able to recover the original text?
Obviously there is, it is OK to add irreversible operations to the encryption process. A designs a new encryption method:
Assume that the number A wants is 375 and encrypts it:
B gets the result 120943, but he can hardly calculate the key 375 based on 120943.
If B wants to verify whether A is lying:
Finally, he can flip a coin...
This encryption method that loses part of the information is called "one-way encryption". Also called hash algorithm.
There is a problem:
This is possible, but it can be solved by increasing the difficulty of the above algorithm so that A is difficult to find.
According to the above expression, a reliable hash algorithm should satisfy:
Hash in cryptographyFunctions have three important properties, namely collision resistance, original image irreversibility, and problem friendliness.
Collision means that student A can find out an odd and an even number in advance to make the hash results consistent, which is computationally infeasible.
First of all, if the news about the large space sauna is compressed into a small space, there will definitely be a collision. Assume that the length of the hash value is fixed to 256 bits. If the order is 1, 2,...2 256 + 1, these 2 256 + 1 input values, and the hash values are calculated one by one, you will definitely be able to find two input values that make the hash The values are the same.
Student A, when you see this, please don’t be too happy too soon. Because you have to have time to figure it out before it's yours. Why do you say that?
According to the birthday paradox, if 2 130 +1 inputs are randomly selected, there is a 99.8% probability of finding at least one pair of collision inputs. Then for a hash function with a hash value length of 256 bits, an average of 2128 hash calculations need to be completed to find the collision pair. If a computer performed 10,000 hash calculations per second, it would take approximately 10 27 years to complete 2 128 hash calculations.
Student A, don’t think about cheating, I guess you won’t live this long. Of course, it is possible if computer computing power is greatly improved.
So what other uses does integrity have?
Used to verify the integrity of the information, because if the information is not tampered with during transmission, the hash value obtained by running the hash calculation will be different from the original hash value.
Therefore, in the blockchain, the collision resistance of the hash function can be used to verify the integrity of blocks and transactions.
Because a hash value corresponds to countless plaintexts, theoretically you don't know which one it is. For example, the results of 4+5=9 and 2+7=9 are the same. I know that the result I entered is 9, but can I know what number I entered?
If, when performing hash calculation on message m, a random prefix r is introduced, and based on the hash value H(r||m), it is difficult to recover message m, which means that the hash function The value hides message m.
Therefore, student B, it is impossible to deduce the original data based on the results. It is like finding a needle in a haystack.
Problem friendliness means that there is no convenient way to generate a hash value that meets special requirements. What does it mean? In layman's terms, there is no shortcut, you need to figure it out step by step. If the required hash result starts with several 0s, then the number of hash calculations required to find a hash value with the first 3 digits all being 0 and a hash value with the first 6 digits all being 0 is a certain number. Quantitative relationship.
How can this be used? In the blockchain, it can be used as proof of work in the consensus algorithm.
Mainly describes three important properties of hash functions: Anti-collisionproperties, the original image is irreversible, and problem-friendly.
Because of these important properties, functions such as integrity verification of blocks and transactions in the blockchain and workload proof of the consensus algorithm are implemented using hash functions.
[1]. Zou Jun, Zhang Haining. Blockchain Technology Guide [M]. Beijing: Mechanical Press, 2016.11
[2]. Chang Chai, Han Feng. Blockchain From digital currency to credit society [M]. Beijing: CITIC Press, 2016.7
[3]. Zhang Jian. Blockchain defines the new future financial and economic landscape [M]. Beijing: Machinery Industry Press, 2016.6
- 上一篇: 区块链代币是什么意思,区块链代币白皮书
- 下一篇: 什么是区块链技术的前世