之前,我总以为挖矿就是把Nonce值都试一遍,然后用SHA256算法算一遍。后面发现自己把东西看得太简单,我尝试尝试讲讲比特币的挖矿算法的流程。
首先挖矿算法的目标对象只是区块中的区块头,共80个字节,我们来看看区块头有哪些字段:
注意:
The SHA256 hashing algorithm, like all hashes constructed using the Merkle-Damgård paradigm, is vulnerable to this attack. The length extension attack allows an attacker who knows SHA256(x) to calculate SHA256(x||y) without the knowledge of x. Although it is unclear how length extension attacks may make the Bitcoin protocol susceptible to harm, it is believed that Satoshi Nakamoto decided to play it safe and include the double hashing in his design.
Another explanation [6] for this double hashing is that 128 rounds of SHA256 may remain safe longer if in the far future, a practical pre-image or a partial pre-image attack was found against SHA256.