如果你百度/谷歌搜索 比特币挖矿的原理的话,都会给你说是计算一个复杂的数学问题而已,但是这么说的话太笼统而且也太简单。
If you search for the principles of bitcoin mining, it's a complex mathematical question, but it's too general and too simple.
采矿引擎如何工作这是一个重要的知识点,所以我们需要了解一些密码学知识和哈希算法相关的知识,才能知道挖矿的基本原理。
How mining engines work is an important knowledge point, so we need to know some cryptography and Hashi algorithm-related knowledge in order to understand the underlying principles of mining.
单向加密人类能够理解的输入,例如 Hello World ,并将其扔到某个加密函数(即所谓的复杂的数学问题),加密函数的算法越复杂,逆向工程就越困难。
The more complex the algorithm of the encryption function is, the more difficult it is to reverse the project.
例如一个 SHA - 256 的例子,网站(http://tool.oschina.net/encrypt?type=2)可以很快的计算散列值,让我们来散列 “Hello World” 看看会得到什么结果:
An example of a SHA - 256 site (
不管你试验几次都会得到一样的散列值,在编程中这种被称之为幂等性。
No matter how many times you test it, you get the same hash value, which in programming is called stride.
加密算法的一个基本特性就是,它们很难通过逆向工程来得到明文结果,但是十分容易验证他们的加密结果,例如这里的 “Hello World” 很难通过逆向工程得到他的原明文结果,比特币采用的是 Double SHA-256 也就是将明文通过 SHA-256 计算过一次之后,再拿 SHA-256 针对散列值再次进行计算,在这里我们只使用 SHA-256 来进行加密。
One of the basic features of encryption algorithms is that it is difficult for them to obtain an explicit result through reverse engineering, but it is very easy to verify their cryptographic results, such as the “Hello World” here, where it is very difficult for the reverse engineering to obtain his original result. Bitcoin uses Double SHA-256, which means that the SHA-256 is to be calculated again against hash values once it has been calculated through SHA-256, where only SHA-256 is used to encrypt.
比特币通过让参与者散列随机的字母与数字的组合,直到计算出来的散列包含前导 0。
Bitcoin consists of random combinations of letters and numbers in the participants'hash until the calculated hash contains the lead 0.
例如我们计算 886 的散列值可以得到如下结果:
For example, we can calculate a hash value of 886 as follows:
000f21ac06aceb9cdd0575e82d0d85fc39bed0a7a1d71970ba1641666a44f530
它返回了 3 个 0 作为前缀的散列值,但是我们怎么知道 886 计算出来的散列结果产生了 3 个 0 呢?
It returns three zeros as prefixed hash values, but how do we know that 886 calculated hash results produce three zeros?
答案是我并不需要知道。。。我需要知道矿工给我的散列值前导有几个零就好了,并不需要复杂的算法来验证整个散列值的有效性。
The answer is that I don't need to know. I need to know how many zeros the miners gave me in the hash lead, and there's no need for sophisticated algorithms to verify the validity of the whole hash value.
比特币则稍微复杂一点,它每隔 10 分钟生成一个新的区块,新区块的散列值的难度它可以动态调整,就类似于 CLR 的 GC 一样,它可以根据目前挖矿的人数来进行难度动态调整,如果挖矿的人多的话,则调高难度,少则调低。
Bitcoin, on the other hand, is a bit more complex; it generates a new block every 10 minutes, and the difficulty of the hash values of the new block can be dynamically adjusted, as in the case of the CLR GC, which can be dynamically adjusted by the current number of diggers, if there are more diggers.
注册有任何问题请添加 微信:MVIP619 拉你进入群
打开微信扫一扫
添加客服
进入交流群
发表评论