比特币的共识协议

资讯 2024-07-14 阅读:47 评论:0
美化布局示例

欧易(OKX)最新版本

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

APP下载   全球官网 大陆官网

币安(Binance)最新版本

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

APP下载   官网地址

火币HTX最新版本

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

APP下载   官网地址

目录

前言

一、铸币交易

? ? ?1.铸币权

? ? ?2.铸币交易(coinbase tx)

3.输入和输出

二、小型的区块链

1.见下图所示

2.哈希指针

3.双花攻击

三、块头块身,全节点轻节点

1.块头(block head)

2.块身

3.全节点full node(fully validating node)

4.轻节点light(weight) node

四、共识协议

1.分布式的共识(distributed consensus)

2.hash rate

3.比特币中的共识协议Consensus in Bitcoin

4.两个等长的分叉

5.比特币铸币规则


? ? ?本文为整理记录学习比特币的共识协议的笔记。图片清晰度可能不够高,希望这不影响您的观看体验。如果有任何错误,请随时指出,感谢您的阅读

♪ ♪ ♪ This paper is a note for documenting a consensus agreement to learn bitcoin. The picture may not be clear enough xff0c; hopefully this will not affect your viewing experience. ♪ xff0c; indicate xff0c; thank you for your reading. ♪

? ? ? ?通过某种方法,用户A获得了发行货币的权利

♪ ♪ By some method ♪ #xff0c; User A gets the right to issue money

? ? ? ?A把钱转给B,需要有A的签名和B的地址?

♪ ♪ ♪ strong < strong > 1 A transfers money to Bxff0c; requires A's signature and B's address?

? ? ? ?在比特币系统中,收款的地址是通过公钥推算(用B的公钥取哈希,然后经过转换得到)

♪ ♪ in the bitcoin system ♪ #xff0c; the address of the receipt is calculated by the public key ♪ #xff08; the public key of B is used to fetch Hashi #xff0c; then converted to xff09;

? ? ? ?交易过程中,A的公钥要让B和所有节点知道

♪ ♪ strong ♪ ♪ strong < < / strong < / strong < / strong > ♪ #xff0c; A's public key to let B and all nodes know

? ? ? ?原因:验证A的签名,A用私钥签名,B用公钥验证 交易时,A要用B的公钥加密,收到后B用自己的私钥解密

♪ ♪ Reason ♪ xff1a; Authentication A xff0c; A private key signature xff0c; B public key authentication xff0c; A public key encryption xff0c; received B decrypting with its own private key

? ? ? ?在交易中可以避免有人故意伪造A的签名:coinbase tx(左边那个框框)的输出存有A的公钥的哈希它一定要=转账交易内的A的公钥,否则交易无法进行

♪ ♪ strong 3 avoids intentional forgery of A's signature xff1a; coinbase tx (the box on the left) output containing A's public key Hash must #61; A's public key xff0c in the transfer transaction; otherwise the transaction cannot take place

以下图片是一个铸币交易

Here's a picture of a sculptor trade.

简单解释如下图

A simple explanation is given below.

? ? ?把交易写在区块链里,然后A拿到钱后给B和C各5个比特币 该交易要有A的签名,证明是经过A同意的,同时这个交易还要说明从哪而来

♪ ♪ Write the deal in the block chain ♪ #xff0c; then A gets the money and gives B and C five bitcoins each with A's signature ♪ #xff0c; attests to A's consent ♪ #xff0c; and the transaction also shows where it comes from. ♪

? ? ?比特币系统中,每个交易都包含输入和输出两个部分

♪ ♪ #xff0c in the bitcoin system; each transaction contains

图中有两种哈希指针

There's two Haci's fingers in the picture.

? ? ?一种是连接各个区块,串起来变成一个 。一种是指向前面某个交易(图中后面的c指向前面的c)

♪ One that connects blocks ♪ #xff0c; stringed together into one. One that points to a previous transaction ♪ #xff08; the c at the back of the graph points to the cxff09;

? ? ?这二种指针说明币的来源是有记录的,同时可以防范双花攻击

♪ ♪ These two fingers show that the money comes from a record ♪ #xff0c; it also protects against double flower attacks

? ? ?double spend attack 简单来讲是,一笔钱被花了两次

♪ Doubly spend attention ♪ simply ♪ ♪ ♪ xff0c; a sum of money is spent twice

包含宏观信息

Include macro information

? ? ? ?①比特币的版本协议(version)

♪ ♪ 1 bitcoin version protocol ♪ #xff08; version)

? ? ? ?②区块链中指向前一个区块的指针(hash of previous block number)

♪ Hash of previous block number ♪

? ? ? ?③默克尔树的根哈希值(Merkle root hash)(保证块身里面的交易列表无法被篡改)

♪ ♪ 3 Merkel tree root value ♪ ♪ ♪ ♪ ♪ xff08; Merkle root Hash& #xff09; #xff08; guarantee that the list of transactions in the pieces cannot be tampered with ♪ xff09;

? ? ? ?④挖矿的难度目标域值(target)

♪ ♪ ♪ 4 difficulty area value ♪ #xff08; target)

? ? ? ?⑤随机数(nonce)

♪ ♪ ♪ 5 random numbers ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ a random number ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ a random number ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ a random number ♪ ♪ ♪ ♪ ♪ ♪ ♪ a random number ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ a random number ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ a ff ♪ ♪ ♪ ♪ ♪ ♪ a ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪

? ? ? ?⑥H(block header)≤target中这个目标域值的编码(nBits)

♪ 6H (block header) code for this target domain value ♪ ♪ ♪ ♪ 6H (block header) #xff08; nBits)

? ? ?交易列表(transaction list)

♪ ♪ list of transactions ♪ ♪ xff08; trading list ♪ xff09;

? ? ?数目少,保存区块链的所有信息,验证每一个交易

♪ ♪ small number of xff0c; all the information that keeps the block chain xff0c; authenticating every transaction ♪

? ? ?数目多,不能独立验证交易的合法性,比如是否是双花攻击

♪ ♪ The number is high ♪ #xff0c; the legitimacy of the transaction cannot be independently verified ♪ #xff0c; for example, is a double flower attack

? ? ?简单例子:分布式的哈希表(distributed hash table)

♪ ♪ Simple example ♪ #xff1a; distributed Hashi table ♪ #xff08; distributed hashtable)

? ? ?系统里有很多机器,共同维护一个全局的哈希表。此时需要取得的共识内容是key-value pair(键值对),比如有的人在a这台机器插入value pair('a'→12345),别人在另一台机器也能读出

♪ There's a lot of machines in the system ♪ ♪ xff0c; together maintaining a global Hashi watch. The consensus that needs to be reached at this point is that the key-value pair (key pair) #xff0c; for example, someone inserts a value pair (#39; a#39; ##12345) xff0c; someone else can read it in another machine.

? ? ?拓展:CAP Theorem ?

♪ ♪Span style="color: #be191c;" ♪expand ♪ ♪/span #xff1a; CAP Theorem ♪

? ? ?3个性质--C:Consistency ?A:Availability P:Partition tolerance ?

♪ ♪ three properties ♪ C: Consistency ♪ Availability P: Partition tolerance ♪

? ? ?任何一个分布式系统,比如说分布式哈希表,三个性质最多只能满足两个

♪ ♪ Any distribution system ♪ #xff0c; for example, distributional Hash table ♪ #xff0c; three properties can only satisfy two

? ? ?比特币中的共识是去中心化账本里的内容(内容由有记账权的节点决定)获得记账权方法:靠算力 (puzzle friendly),每秒钟可以试多少nonce,称为hash rate

♪ ♪ The consensus in bitcoin is to decentralize the contents of the books ♪ #xff08; content is determined by the nodes with rights ♪ ♪ xff1a ♪ ♪ how much money ♪ #xff0c; called ash rate ♪

? ? ?账户数量的多少不会影响hash rate,也不会受到女巫攻击的影响

♪ ♪ How many accounts do not affect hash ratte, nor will they be affected by witch attacks

? ? ?比特币争夺记账权的过程:挖矿mining

♪ ♪ The process of Bitcoin competing for bookkeeping ♪ ♪ ♪ xff1a; digging mine ♪

? ? ?争夺记账节点的人:矿工miner

♪ ♪ vying for account nodes ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ vying for account nodes ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ ♪ the miner ♪ ♪ ♪ ♪ the miner ♪

? ? ?女巫攻击(sybil attack):在投票中,故意弄出超过总数一半的账号,操纵投票结构

♪ ♪ witch attack (sybil attack): in the vote ♪ #xff0c; deliberately deposing more than half of the accounts ♪ ♪ xff0c; manipulation of voting structures

? ? ?存在的原因:在比特币系统中,某些节点可能是有恶意的

♪ ♪ The cause of existence ♪ ♪ xff1a; in the bitcoin system ♪ ♪ ♪ ♪ xff0c; some nodes may be malicious

? ? ?存在恶意节点如何设置共识协议:按照算力来决定,每个节点都可以在本地组装出一个候选区块把它认为合法的交易放进,然后开始尝试nonce值。成功的获得记账权

♪ ♪ How to set a consensus agreement ♪ #xff1a ♪ where there are malicious nodes ♪ #xff0c ♪ based on arithmetic; each node can assemble a candidate block locally and place it in #xff0c; then start trying noce. Successfully earned rights to account.

如下图

Here's the figure.

? ? ?如果两个节点同时获得记账权,会出现两个等长的分叉 。此时,该接收哪个呢?

♪ ♪ ♪ If two nodes are given rights to account at the same time ♪xff0c; there will be two long splits. ♪ #xff0c; which one to receive #xff1f;

? ? ?比特币缺省情况下,每个节点接收自己最早收到的那个节点,不同节点根据在网络中位置的不同

♪ ♪ Bitcoin default ♪ #xff0c; each node receives the first node ♪ #xff0c; different nodes depend on their location in the network

? ? ?接受/不接收区块 接收区块:沿着你的区块往下继续扩展。不接收则反之

♪ ♪ Accept/not receive blocks ♪ #xff1a; continue to expand down your blocks.

? ? ?出现两个节点同时获得记账权的情况,这种等长的临时性的分叉会维持一段时间,直到某个节点胜出 胜出的是最长合法链,输掉的是orphan block,会被丢弃掉

♪ ♪ There's a situation where two nodes are given the right to account at the same time ♪ #xff0c; this kind of long temporary split lasts for some time ♪ #xff0c; until a certain node is won, the longest legal chain ♪ #xff0c; lost is orphan Block #xff0c; abandoned

? ? ?获得记账权的节点可以决定哪些交易被写进下一个区块。但是比特币想要合法的交易都可以被写进。比特币协议中就规定获得记账权的节点在发布的区块里,可以有一个特殊的交易(铸币交易),在该交易里可以发布一定数量的比特币

♪ ♪ The node to get rights to account can determine which transactions are written into the next block. ♪ But any transaction that Bitcoin wants to be legal can be written. ♪ #xff0c in the bitcoin agreement provides for the right to account in the published block ♪ #xff08; #xff09; #xff0c; a certain amount of bitcoins can be issued in the transaction

? ? ?铸币交易是比特币系统中发行新的比特币的东西

♪ The sedentary deal is the new bitcoin issue in the bitcoin system

? ? ?唯一方法:最初每次能造50比特币(初次奖励),但在21万比特币后,奖励减半

♪ ♪ The only method ♪ #xff1a; initially 50 bits of xff08; first reward ♪ #xff09; xff0c; but halved after 210,000 bits of xff0c;

美化布局示例

欧易(OKX)最新版本

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

APP下载   全球官网 大陆官网

币安(Binance)最新版本

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

APP下载   官网地址

火币HTX最新版本

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

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

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

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

分享:

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

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

欧易(OKX)

  全球官网 大陆官网

币安(Binance)

  官网

火币(HTX)

  官网

Gate.io

  官网

Bitget

  官网

deepcoin

  官网
热门文章
  • 从 IPFS社区Meetup谈谈2020年的IPFS的发展历程

    从 IPFS社区Meetup谈谈2020年的IPFS的发展历程
    8月3日, IPFS社区Meetup 如期举办,这一次的社区Meetup由交流与演讲和闪电演示两部分组成,其实该会议主要带领我们回顾了IPFS在2020年的发展历程(包括项目进展、IPFS生态发展等),展示了IPFS及其生态。2020年对于IPFS而言是不平凡的一年,其唯一激励层Filecoin的主网即将上线,这让IPFS和Filecoin在全球范围内得到了前所未有的关注,也推动了IPFS的高速发展。接下来,我们一起走进IPFS在20...
  • 超10万人爆仓,比特币跳水,发生了什么

    超10万人爆仓,比特币跳水,发生了什么
    现货比特币ETF上市第二日,数字货币再迎来抛售。比特币一度跌破42000美元/枚,截止1月13日内跌幅超7%,报42562.1美元/枚。The current Bitcoin ETF is on the second day of the market and the digital currency is sold again. Bitcoin fell by over 7% to $4562.1 on 13 January.现货比特币ETF普遍跌6%左右。其中,DEFI跌...
  • 兴业基金调研远光软件、东芯股份

    兴业基金调研远光软件、东芯股份
    根据6月6日公布的公开市场信息和机构研究,世界安全基金会最近对下列两家上市公司进行了一项研究: 1) 光电软件(工程师基金参与公司专项研究) 其中一个亮点是该公司深入参与建造南方网中心和技术平台,导致南网市场在 " 九天 " 平台产品方面取得重大突破;该公司的Won-宇宙大厅已上线,而且,除了Won-宇宙之外,远洋宇宙的应用现已扩大到Won-宇宙发射、Won-宇宙-教师和政党建设-宇宙;该公司的Far-O-Cloud平台已经实现了完全成熟的国家生产,也可以在全国云中运作。...
  • 0.00003374个比特币等于多少人民币/美金

    0.00003374个比特币等于多少人民币/美金
    0.00003374比特币等于多少人民币?根据比特币对人民币的最新汇率,0.00003374比特币等于2.2826 1222美元/16.5261124728人民币。比特币(BTC)美元(USDT)人民币(CNY)0.00003374克洛克-0/22216.5261124728比特币对人民币的最新汇率为:489807.72 CNY(1比特币=489807.72人民币)(1美元=7.24人民币)(0.00003374USDT=0.0002442776 CNY)。汇率更新于2024...
  • $DOG暴涨400%,加密货币或许正在重新定义和计量“价值”

    $DOG暴涨400%,加密货币或许正在重新定义和计量“价值”
    近/克洛克-0/5,Meme币狗?走吗?去哪?那个?MOON($ DOG)连续上涨超过230%,突破前期高点,达到0.0062美元。在同一时期,比特币生态的许多主流L2协议代币下跌了50%以上。这些就是我们所说的“价值币”。虽然大起大落不能说明什么,但从过去的牛市来看,领头羊MemeCoin表现非凡。在上一轮牛市中,$DOGE的价格上涨了超过150倍,其市值接近900亿美元。还有其他MemeCoin,如$Shib、$People、$ELON、$AKITA等。2 vkwmkpm...
标签列表