BTC的挖矿算法究竟是如何运算的?

资讯 2024-06-23 阅读:136 评论:0
比特币挖矿是比特币系统安全的一个关键部分。其原理是,比特币矿工将一堆比特币交易归为一个区块,然后反复执行一种叫做Hash的加密操作几十亿次,直到有人找到一个特殊的目标Hash值。至此,该区块即被开采并成为比特币区块链的一部分。Hash 任...
美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

比特币挖矿是比特币系统安全的一个关键部分。其原理是,比特币矿工将一堆比特币交易归为一个区块,然后反复执行一种叫做Hash的加密操作几十亿次,直到有人找到一个特殊的目标Hash值。至此,该区块即被开采并成为比特币区块链的一部分。Hash 任务本身并不能完成任何有价值的任务,但由于通过它找到一个成功的目标值非常困难,所以它确保了没有人拥有接管比特币系统的能力和资源。

Bitcoin mining is a key part of the security of the Bitcoin system. The rationale is that the Bitcoin miners group a bunch of bitcoin transactions into a block, and then repeat an encryption operation called Hash billions of times until someone finds a special target Hash value. So, the block is mined and becomes part of the Bitcoin block chain. The Hash mission does not perform any valuable task per se, but because it is very difficult to find a successful target through it, it ensures that no one has the capacity and resources to take over the Bitcoin system.

Hash 函数是指输入一个数据区块并创建一个较小的、不可预测的输出。Hash 函数的设计使得没有 "捷径 "来获得所需的输出结果--你只能不断地对区块进行Hash操作,直到你通过蛮力找到有效的一个结果为止。对于比特币来说,Hash 函数是一个叫做SHA-256的函数。为了提供更高的安全性,比特币将连续重复SHA-256函数两次,这个过程被称为双SHA-256。

The Hash function refers to the input of a data block and the creation of a smaller, unpredictable output. The Hash function is designed so that there is no &quat; shortcuts & Quot; to obtain the desired output -- you can only continue to operate the Hash on the block until you find a valid result through force. For Bitcoin, the Hash function is a function called SHA-256. To provide greater security, Bitcoin repeats the SHA-256 function twice in a row, a process called Double SHA-256.

在比特币中,一个成功的Hash值是一个以足够多的零开头的数值。就像很少能找到一个以多个0结尾的电话号码或车牌一样,很少能找到一个以多个0开头的Hash。但比特币的难度是呈指数倍增加的。目前,一个成功的Hash必须从大约17个0开始。换句话说,找到一个成功的Hash比在地球上所有沙粒中找到某一粒沙子还要难。

In bitcoin, a successful Hash is a value that starts with enough zeros. As rarely can a phone number or license plate that ends with more than zeros be found, very rarely is a Hash that starts with more than zeros. But the difficulty of bitcoins is exponential. Now, a successful Hash has to start with about 17 zeros. In other words, finding a successful Hash is more difficult than finding a single grain of sand in all the sand particles on Earth.

下图显示了比特币区块链中的一个区块以及它的Hash值。黄色的字节经过Hash后生成区块Hash值。在这种情况下,生成的Hash值以足够多的0开始,因此此次挖矿成功。然而,Hash很难一次得到的,在这种情况下,矿工会改变nonce值或其他区块内容,然后进行反复尝试。

The figure below shows a block in the Bitcoin block chain and its Hash value. The yellow bytes generate the Hash value of the block after Hash. In this case, the Hash value was generated at a sufficient number of zeros, so the mining was successful. However, Hash was difficult to obtain once, in which case the mining union changed the nonce value or other block content and then tried repeatedly.

BTC的挖矿算法究竟是如何运算的?

比特币使用的SHA-256Hash算法

The SHA-256Hash algorithm used in Bitcoin

SHA-256的Hash算法采用512位(即64个字节)的输入块,对数据进行加密组合,并产生256位(32个字节)的输出。SHA-256算法由重复64次的相对简单的回合组成。下图显示了一个回合,它需要8个4字节的输入--A到H,然后执行一些操作,并生成A到H的新值。

The SHA-256 Hash algorithm uses 512 bits (i.e. 64 bytes) of input blocks to encrypt the data and produces 256 bits of output (32 bytes). The SHA-256 algorithm consists of a relatively simple round that repeats 64 times. The figure below shows a round that requires eight fourbytes of input -- A to H, and then performs some operations and produces a new value of A to H.

BTC的挖矿算法究竟是如何运算的?

蓝色方框以非线性的方式将数值混合在一起,因此很难用密码学分析这些值。由于算法使用了几个不同的函数,所以发现攻击就更难了。(如果你能找出一种数学捷径来生成成功的Hash值,你就可以接管比特币挖矿了)。

The blue box mixes values in a non-linear way, so it is difficult to analyse them by cryptography. Because arithmetic uses several different functions, it is harder to find an attack. (If you can find a mathematical shortcut to produce a successful Hash value, you can take over Bitcoin mining.)

Ma大多数框看A、B、C的位数,对于每个位置,如果多数位数为0,则输出0,否则输出1。也就是说,对于A、B、C的每个位置,看1位的数量。如果是0或1,输出0,如果是2或3,输出1。

The number of places A, B, C is seen in most of the boxes. For each location, if the number of digits is 0, then 0, or 1. That is, for each location of A, B, C, look at the number of places. If 0 or 1, 0, if 2 or 3, 1.

Σ0框将A的位数反转,形成三个反转版本,然后将它们相加模数为2。换句话说,如果1位的数量是奇数,则和为1,否则为0,和中的三个值分别是A向右反转2位、13位和22位。

& Sigma; box 0 inverts the number of A into three inverse versions, and then modifies them by two. In other words, if the number of one is an odd number, then the value is one, or the values of 0, and the values of three are A to the right, 2 to the right, 13 to the 22 to the right, respectively.

Ch "选择 "框根据输入E的值选择输出位,如果E的某位为1,则输出位为F的对应位,如果E的某位为0,则输出位为G的对应位,这样,F和G的位就根据E的值进行随机选择。

Ch & quot; Select & quot; Box selects the output position according to the value of the input E. If one of the Es is 1 the output is F and if one of the Es is 0, the output is Gs, so that the F and Gs are randomly selected according to the Es.

下一框Σ1对E的位进行反转和,除了移位是6位、11位和25位外,其他与Σ0类似。

Box & Sigma; 1 Reverses the position of E and is similar to & Sigma; 0 except for 6, 11 and 25 shifts.

红框执行32位加法,生成A和E的新值,输入Wt是基于输入数据,稍加处理。(这是输入块被输入到算法中的地方。)输入Kt是为每一轮定义的常数。

Red box performs 32-bit additions to generate new values for A and E, and input Wt is based on input data and slightly processed. (This is where the input block is entered into the algorithm.) The input Kt is the constant defined for each round.

从上图可以看出,一轮中只有A和E是变化的。其他值不变通过,旧的A值变成新的B值,旧的B值变成新的C值,以此类推。虽然SHA-256的每一轮都不会对数据有太大的改变,但64轮之后,输入的数据将完全被扰乱。

As can be seen from the figure above, only A and E are changing in the round. By remaining constant, the old value A becomes a new value B, the old value B becomes a new value C, and so on. While none of the SHA-256 rounds will change the data much, after 64 rounds, the data entered will be completely disrupted.

这对挖矿的硬件意味着什么?

What does this mean for mining hardware?

SHA-256的每一步在数字逻辑中都非常容易实现--简单的布尔运算和32位加法。(如果你学过电子学,你可能已经可以把电路可视化了)。出于这个原因,定制的ASIC芯片可以在硬件中非常高效地实现SHA-256算法,在一个芯片上并行地放上几百轮。

Each step of SHA-256 is very easy to achieve in digital logic -- simple booleans and 32-bit additions. (If you've studied electronics, you may already be able to visualize circuits.) For this reason, custom-made ASIC chips can achieve the SHA-256 algorithm very efficiently in hardware, putting hundreds of rounds on a chip in parallel.

相比之下,Litecoin、Dogecoin和类似的altcoins使用Crypt Hash算法,该算法被有意设计成难以在硬件中实现的形式。它将1024个不同的Hash值存储到内存中,然后以不可预测的方式将它们结合起来,以获得最终结果。因此,与SHA-256 Hash相比,Scrypt需要更多的电路和内存。你可以通过查看挖矿硬件来了解其影响,Scrypt(Litecoin等)的计算速度比SHA-256(比特币)慢数千倍。

In contrast, Litecoin, Dogecoin and similar altcoins use Crypt Hash algorithms, which are deliberately designed to take forms that are difficult to achieve in hardware. It stores 1,024 different Hash values in memory and then combines them in an unpredictable manner to achieve the final result. As a result, Scrypt needs more circuits and memory than SHA-256 Hash. You can understand the impact by looking at mining hardware, and Scrypt (Litecoin et al.) is calculated thousands of times slower than SHA-256 (bits).

SHA-256算法出乎意料的简单,很容易手动完成。(用于签署比特币交易的椭圆曲线算法用手计算会非常痛苦,因为它有很多32字节整数的乘法)。手工做一轮SHA-256花了我16分45秒。按照这个速度,Hash一个完整的比特币区块(128轮)需要1.49天,每天的Hash率为0.67次(虽然我可能会通过练习变得更快)。相比之下,目前的比特币挖矿硬件每秒可以做到几兆次的Hash,比我的手动Hash快了约五千万倍。不用说,手动比特币挖矿根本不实用。

The SHA-256 algorithm was unexpectedly simple, and it was easy to do it manually. (A manual calculation of the elliptical curve algorithm for signing bitcoin transactions would be very painful, because it had a 32-bit integer multiplier.) It took me 16 minutes and 45 seconds to make a round of SHA-256 by hand. At this rate, a full bitcoin block (128 rounds) in Hash would take 1.49 days, with a rate of 0.67 times a day (although I might be able to do it faster). By contrast, the current bitcoin digs hardware a few trillion times faster than my hand, about 50 million times faster.

有Reddit读者问到我的能量消耗。其实不需要太多能量消耗,所以假设静止代谢率为1500kcal/天,人工Hash的能耗差不多为10兆焦耳/Hash。一般挖矿硬件的能耗是1000兆焦耳/Hash。所以,我的能源效率低了10¹?。接下来的问题是能源成本。一个便宜的食物能量来源是甜甜圈,200千卡的热量是0.23元。这里的电是0.15美元/千瓦时,便宜了6.7倍--比我预期的要接近。因此,我每Hash的能源成本大约是挖矿硬件的67倍。很明显,我不会靠人工挖矿发家致富,我甚至还没有包括我需要的所有纸和铅笔的成本。

There's a Reddit reader asking about my energy consumption. There's no need for too much energy consumption, so assuming a static metabolic rate of 1,500 kcal/day, the artificial Hash energy consumption is almost 10 MJ/Hash. The energy consumption of mine hardware is about 1,000 MJ/Hash. So, my energy efficiency is 10 mJ/Hash. So, my energy efficiency is 10 ¹? The next question is energy cost. A cheap food energy source is a donut, 200 kcals of heat is 0.23.

美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址
文字格式和图片示例

注册有任何问题请添加 微信:MVIP619 拉你进入群

弹窗与图片大小一致 文章转载注明

分享:

扫一扫在手机阅读、分享本文

发表评论
平台列表
美化布局示例

欧易(OKX)

  全球官网 大陆官网

币安(Binance)

  官网

火币(HTX)

  官网

Gate.io

  官网

Bitget

  官网

deepcoin

  官网
热门文章
  • 支付領域投下震撼彈!美國數位銀行Chime疑與GuardPay 神盾支付合作!

    支付領域投下震撼彈!美國數位銀行Chime疑與GuardPay 神盾支付合作!
    2020年,新冠肺炎(COVID-19)疫情加速數位貨幣進展。例如:2019年4月,國際清算銀行(BIS)的調查顯示,在全球66家中央銀行中,沒有一家計畫發行跨境支付的數位貨幣。惟到了2020年10月,BIS支付委員會主席康利夫(Jon Cunliffe)指出,肺炎疫情拉高民眾對無現金支付的需求,迫使各國加快數位貨幣的研發進程日本與韓國於2021年進入數位貨幣試驗階段。直到2019年12月,美國聯邦準備理事會(Fed)都尚無數位貨幣規劃,惟到了2020年2月,Fed已開始研擬...
  • 区块链:交易系统开发指南

    区块链:交易系统开发指南
    播报编辑《区块链:交易系统开发指南》使用通俗易懂的语言,从技术的角度详细介绍了区块链交易系统应有的功能架构及工作原理,让人们能够张开双臂轻松地拥抱区块链技术,享受区块链交易系统带来的惊喜与成就感。《区块链:交易系统开发指南》共分 7 章,第 1~2 章主要介绍区块链及数字货币的基本概念,以及各种公有链的 API 接口;第3~5 章主要介绍区块链交易系统的分类架构及功能; 6 章主要介绍区块链交易系统面临的问题及演进方向;第 7 章对全书做了总结。《区块链:交易系统开发指南》是...
  • 5.14加密货币价格:BTC突破6.2万美元以太坊和山寨币反映市场情绪

    5.14加密货币价格:BTC突破6.2万美元以太坊和山寨币反映市场情绪
    今天,随着比特币(BTC)的价格突破62 000美元的门槛,顶级加密货币的价格反弹了。 此外,以铁大幅上涨,维持在2 900美元的水平。 此外,其他顶尖山硬币,如索拉纳(SOL )、XRP、卡达诺(ADA )也大幅上涨。    今天密钥加密货币价格 1. 比特币价格    在5月14日星期二撰写本文时,比特币价格上升了2.57%,达到62 487.50美元。 另一方面,在过去24小时内,交易量从65.26 % 急剧上升至277亿美元。 与此同时,加密货币的市场价值为...
  • OKEx回应用户质疑:合约交易非期货 平台无机器人

    OKEx回应用户质疑:合约交易非期货 平台无机器人
       热点点 自选股份 数据中心 数据中心 研究和资料中心 资金流动 模拟交易 客户客户 具体来说,OKEx回答用户的问题:合同交易不是期货,平台不是机器人。 金融同步化,3月22日。    昨天下午,OKEx公司就维护先前用户线下的权利问题对同步财务公司作出了回应,指出OKEx公司提供的合同交易不是期货交易,在旗下的业务中没有正式的机器人。 同时,OKEX称,它不会以非法为由对任何投资损失索赔作出答复。 答复全文如下: 同步你的财务! 近日来,...
  • 0.00006694个比特币等于多少人民币/美金

    0.00006694个比特币等于多少人民币/美金
    0.00006694比特币等于多少人民币?根据比特币对人民币的最新汇率,0.00006694比特币等于4.53424784美元/32.5436 16人民币。比特币(BTC)美元(USDT)人民币(CNY)0.000066944.53424784【比特币密码】32.82795436 16比特币对人民币的最新汇率为:490408.64 CNY(1比特币=490408.64人民币)(1美元=7.24人民币)(0.00006694USDT=0.0004846456 CNY)汇率更新时...
标签列表