티스토리 뷰

https://godd.tistory.com/94?category=825121 

 

[블록체인] Bitcoin 백서 정리 #2 - 메커니즘

https://godd.tistory.com/92 [블록체인] Bitcoin 백서 정리 #1 - 도입부 Bitcoin 백서는 사토시 나가모토라는 가명으로 발표한 신뢰할 수 있는 제 3자 없이 온라인으로 지불이 가능한 P2P 전자 화폐인 Bitcoin을..

godd.tistory.com

지난번은 비트코인이 동작할 수 있는 메커니즘을 정의한 포스팅이다.

이어서 지속적인 화폐 유통과 운영상의 필요한 정책들을 정리하는 방법을 정리한다.

 

Incentive

By convention, the first transaction in a block is a special transaction that starts a new coin owned by the creator of the block. This adds an incentive for nodes to support the network, and provides a way to initially distribute coins into circulation, since there is no central authority to issue them. The steady addition of a constant of amount of new coins is analogous to gold miners expending resources to add gold to circulation. In our case, it is CPU time and electricity that is expended.

관례적으로, Block의 첫번째 거래는 Block의 생성자에 의해 소유되는 신규 코인을 생성하는 특별한 거래이다. 이것은 노드들이 네트워크를 유지하도록 인센티브를 주는 것이다. 그리고 코인을 발행할 중앙 기관이 없기 때문에 최초로 코인을 유통할 수 있는 방법을 제공해준다. 일정량의 신규 코인 증가는 금을 유통하기 위해 자원을 소비하는 Miner들과 유사하다. 우리의 경우에는 컴퓨팅 시간과 전기를 소비하는 것이다.

 

Block 생성이 유일한 신규 코인 발행이라는 인센티브를 줌으로써 유통을 유지할 수 있게 해준다.

사실 비트코인은 Nick Szabo 가 고안한 Bit Gold 시스템과 매우 유사한데 실제로 Nick Szabo 는 금과 같은 역할을 할 수 있는 전자 화폐를 만드려고 했으며 금 유통 환경과 실제 Miner들이 시간과 힘을 써가며 금을 채굴 하는 것과 유사한 환경을 만들었다. 

 

The incentive can also be funded with transaction fees. If the output value of a transaction is less than its input value, the difference is a transaction fee that is added to the incentive value of the block containing the transaction. Once a predetermined number of coins have entered circulation, the incentive can transition entirely to transaction fees and be completely inflation free.

인센티브는 또한 거래 수수료로 제공 받을 수 있다. 거래의 Output 값은 Input 값들보다 더 적다면, 그 차이는 거래가 포함되는 Block의 인센티브 값으로 수수료인 것이다. 일단 미리 정해진 수량의 코인이 모두 발행된다면, 인센티브는 완전히 거래 수수료 체제로 전환되고 인플레이션으로부터 자유로워진다.

 

실제 세상의 금의 한정 수량이 정해져 있듯이, 코인도 일정 수량 이상 채굴할 수 없다. 금이 무한정으로 채굴할 수 있다면 금의 가치가 없듯이 코인도 마찬가지로 보고 있다. 대신 코인이 모두 채굴되고 나면 Block을 계속해서 만들 이유가 없어지므로 거래 수수료를 인센티브로 지급함으로써 노드들은 지속적인 유통을 위해 일 할 것이다.

 

The incentive may help encourage nodes to stay honest. If a greedy attacker is able to assemble more CPU power than all the honest nodes, he would have to choose between using it to defraud people by stealing back his payments, or using it to generate new coins. He ought to find it more profitable to play by the rules, such rules that favour him with more new coins than everyone else combined, than to undermine the system and the validity of his own wealth.

인센티브는 정직함을 유지할 수 있게 해준다. 만약 욕심많은 Attacker들이 정직한 노드들보다 더 큰 CPU 파워를 가진다면, 그는 지불한 것들을 훔쳐 속이는 것과 새로운 코인을 생성할 지 선택해야 한다. Attacker들은 시스템과 자신의 부의 유효성을 약화시키기 보다 규칙대로 하는것이 더 많은 이득을 얻는것임을 알아야 한다. 

과반수 이상의 CPU 파워를 가진 악의적인 노드가 있다 해도 결국 위변조를 위한 컴퓨팅 파워를 사용하는 것보다 인센티브를 획득하는 것이 자신에게 이득을 얻게 해줄 것이라고 얘기한다.

가치 유지를 위한 인센티브 정책으로 인해 악의적인 노드들이 없는 환경을 만들었지만, 전자 화폐 신뢰성 유지를 위해 전체 거래를 저장 할 공간이 너무 많지 않나 의문이 아직 남아있다.

 

 

Reclaiming Disk Space

Once the latest transaction in a coin is buried under enough blocks, the spent transactions before it can be discarded to save disk space. To facilitate this without breaking the block's hash, transactions are hashed in a *Merkle Tree [7][2][5], with only the root included in the block's hash. Old blocks can then be compacted by stubbing off branches of the tree. The interior hashes do not need to be stored.

코인의 최종 거래가 충분한 Block들에 묻힌다면, 이 전에 소비된 거래들은 저장 공간을 절약하기 위해 버려질 수 있다. Block의 해시 값을 깨지 않고 해결하기 위해 거래들은 Merkle Tree로 해시되어 오직 루트만 Block 해시에 포함된다. 오래된 Block들은 트리의 가지치기로 압축할 수 있다. 중간 해시들은 저장될 필요가 없다.

 

 Merkle Tree는 이진트리 기반이지만 기존 이진트리는 검색을 위한 자료구조이면, 이건 검증을 위한 자료구조라고 설명된다.

 

오랫동안 코인이 사용되지 않아 Block 들이 쌓이면서 저장 공간을 위해 그 당시 거래들에 대한 내용을 버려야 할텐데, 모든 거래를 Merkle Tree로 만들어 가지고 있음으로써 거래들을 저장하지 않고 있어도 된다고 한다. 

Merkle Tree는 이진트리인데 위 왼쪽 그림을 보면 거래들을 해시화 해서 두개씩 묶어 다시 해시로 바꿈으로써 결국 루트 해시가 나올거고 Block Header에 이 Merkle Tree만 가지고 있으면 된다는 말이다. 노드들은 Block의 모든 거래들을 가지고 있을 필요가 없다.

 

A block header with no transactions would be about 80 bytes. If we suppose blocks are generated every 10 minutes, 80 bytes * 6 * 24 * 365 = 4.2MB per year. With computer systems typically selling with 2GB of RAM as of 2008, and Moore's Law predicting current growth of 1.2GB per year, storage should not be a problem even if the block headers must be kept in memory.

거래들이 없는 Block 헤더는 약 80byte일 것이다. 만약 Block을 10분마다 생성한다고 가정하면, 1년에 80 bytes * 6 * 24 * 365 = 4.2MB 이다. 2008년 보통 2GB 램을 가진 컴퓨터가 팔리고 있고 *무어의 법칙에 따른다면 해마다 1.2GB 씩 성장할거라 예측해보면 메모리에 Block 헤더들을 저장한다 해도 저장공간은 문제가 되지 않을 것이다.

 

 무어의 법칙 :  메모리 용량이나 CPU 속도가 18~24개월마다 2배씩 향상된다는 법칙

 

그럼 다시 처음으로 돌아가서 전자 화폐를 전자 서명의 체인으로 정의 했는데, 루트만 가지고 지불 검증을 할 수 있느냐에 대한 의문점이 생긴다.

 

Simplified Payment Verification

It is possible to verify payments without running a full network node. A user only needs to keep a copy of the block headers of the longest proof-of-work chain, which he can get by querying network nodes until he's convinced he has the longest chain, and obtain the Merkle branch linking the transaction to the block it's timestamped in. He can't check the transaction for himself, but by linking it to a place in the chain, he can see that a network node has accepted it, and blocks added after it further confirm the network has accepted it.

전체 네트워크 노드의 실행 없이 지불 검증이 가능하다. 사용자는 오직 가장 긴 작업증명체인 (가장 긴 체인임을 확신할 때까지 네트워크 노드들에게 질의함으로써 얻을 수 있는) 의 Block 헤더의 카피본만 유지할 필요가 있다. 그리고 그 거래가 Timestamp 되어 있는 Block으로 연결된 Merkle Branch를 얻기만 하면 된다. 해당 노드는 스스로 거래를 체크하진 못하지만, 체인의 한 부분을 연결함으로써 네트워크 노드가 거래를 받아들이는지 추가로 확인해주게 된다.

모든 거래 내역을 가진 노드를 Full 노드라 하고 위처럼 Block 헤더만 유지하는 노드들을 SPV (Simplified Payment Verification) 노드라고 한다. SPV 노드는 거래에 대한 검증을 하기 위해 Full 노드로부터 Merkle Branch 를 얻는다. 위 그림의 빨간 부분의 Branch 만 얻어오게 되면 특정 Tx3의 검증이 가능하다.

Tx3를 해시 한 Hash3을 만듦 -> Hash2와 합쳐서 Hash23을 만듦 -> Hash01과 합친 해시 값과 Merkle Root를 비교하면 검증이 완료된다.

 

As such, the verification is reliable as long as honest nodes control the network, but is more vulnerable if the network is overpowered by an attacker. While network nodes can verify transactions for themselves, the simplified method can be fooled by an attacker's fabricated transactions for as long as the attacker can continue to overpower the network. One strategy to protect against this would be to accept alerts from network nodes when they detect an invalid block, prompting the user's software to download the full block and alerted transactions to confirm the inconsistency. Businesses that receive frequent payments will probably still want to run their own nodes for more independent security and quicker verification.

이 검증 방식은 정직한 노드들이 네트워크를 통제하는 한 신뢰할 수 있지만, 만약 Attacker들이 장악하게 된 네트워크라면 취약해지게 된다. 네트워크 노드들은 스스로 검증할 수 있지만, 이 단순한 방법은 Attacker들의 계속해서 네트워크를 장악하는 한 Attacker들의 날조된 거래들로 속을 수 있다. 이를 막기 위한 한 전략은 네트워크 노드들로부터 유효하지 않은 블럭을 발견했을 때 경고를 받아, 사용자의 소프트웨어가 불일치를 확인하기 위해 전체 블록과 경고를 받은 거래들을 다운받도록 하는 것이다. 빈번한 지불을 받는 사업자들은 독립적인 보안과 빠른 검증을 위해 자체 노드를 운영하려고 할 것이다.

 

SPV 노드는 악의적인 Attacker들이 많을 경우 Merkle Branch를 받을 때 날조해서 보낼 수 있다는 얘기다. 이를 방지하는 방법은 결국 alert를 받았을 때 전체 거래를 받아서 불일치를 확인하는 방법이라고 얘기한다.. 어쨌든 내 노드의 안전을 위해서는 자체 Full 노드를 운영하는 것이 나을 것이라고 얘기하는 듯 하다.

 

Combining and Splitting Value

Although it would be possible to handle coins individually, it would be unwieldy to make a separate transaction for every cent in a transfer. To allow value to be split and combined, transactions contain multiple inputs and outputs. Normally there will be either a single input from a larger previous transaction or multiple inputs combining smaller amounts, and at most two outputs: one for the payment, and one returning the change, if any, back to the sender.

비록 코인들을 개별적으로 다룰 수 있지만, 한 송금의 잔돈을 개별적인 거래로 만드는 것은 다루기 불편하다. 금액을 나누고 합치는 것을 허용하기 위해 거래들은 여러개 입력과 출력을 포함한다. 보통 이전 거래로부터 오는 단일 입력이나 작은 금액들로 이루어진 여러 개의 입력, 그리고 최대 두개의 출력이 있다. 하나는 지불을 위한 출력이고, 다른 하나가 있다면 거스름돈이다. 

 

어딘가에서 나온 Output은 다른 거래의 Input이 된다. 내가 받은 코인들을 하나하나씩 거래로 만드는 것은 귀찮으니까 그림과 같이 여러개의 Input으로 모아서 한번에 Output으로 보낼 수 있다는 얘기다. Output이 두개가 있다면 지불에 대한 Output과 보낸 사람에게 거스름돈을 보내기 위한 거래의 Input 값으로 들어갈 거스름돈 Output이 있다.

 

It should be noted that fan-out, where a transaction depends on several transactions, and those transactions depend on many more, is not a problem here. There is never the need to extract a complete standalone copy of a transaction's history.

한 거래가 여러 거래들을 의존하고 또 이 여러 거래들은 더 많은 거래들에 의존되고 있는 팬아웃은 여기서 문제가 되지 않는다. 한 거래내역의 완전한 독립 사본을 추출해야 할 필요는 절대 없다.

 

금액이 분할되고 병합되면서 발생하는 거래들의 의존성은 어차피 In - Out에 대한 내역들을 알 필요가 없으므로 중요하지 않다는 뜻이다.

 

Privacy

The traditional banking model achieves a level of privacy by limiting access to information to the parties involved and the trusted third party. The necessity to announce all transactions publicly precludes this method, but privacy can still be maintained by breaking the flow of information in another place: by keeping public keys anonymous. The public can see that someone is sending an amount to someone else, but without information linking the transaction to anyone. This is similar to the level of information released by stock exchanges, where the time and size of individual trades, the "tape", is made public, but without telling who the parties were.

전통적인 은행 모델은 거래 당사자들과 신뢰할 수 있는 제 3자에게만 접근 권한을 제한함으로써 일정 수준의 Privacy를 제공한다. 모든 거래들을 알려야할 필요성은 이 방식을 불가능하게 하지만, 정보의 흐름을 다른 면에서 차단함으로써 보호가 가능하다. 그것은 공개키를 익명으로 유지하는 것이다. 대중은 누군가가 다른 누군가에게 얼마를 보냈는지 볼 수 있지만 그 거래를 특정인으로 연결할 정보가 없다. 이것은 기존 증권 거래소에서 시간, 거래 내용을 공개하지만 거래자들이 누군지는 말하지 않는 "tape" 수준의 정보공개 레벨과 비슷하다.

 

As an additional firewall, a new key pair should be used for each transaction to keep them from being linked to a common owner. Some linking is still unavoidable with multi-input transactions, which necessarily reveal that their inputs were owned by the same owner. The risk is that if the owner of a key is revealed, linking could reveal other transactions that belonged to the same owner.

추가적인 보호책으로 신규 키 페어를 사용하여 공통된 소유자를 연결시킬 수 있는 여지를 막아야 한다. 여러개의 입력을 가지는 거래의 경우 해당 입력들이 동일한 소유자의 것임이 드러날 수 밖에 없어서 일부의 연결고리는 피할 수 없다. 만약 한 키의 소유자가 드러나게 된다면 해당 연결고리는 동일한 소유자의 다른 거래들까지 드러나게 된다.

 

기존 전통적인 모델은 개인정보가 사용된 거래들을 신뢰할 수 있는 제 3자를 통해 Counterparty로 제공됨으로써 대중들에게 개인정보를 차단할 수 있다.

하지만 신규 키 페어의 생성 , 기존 거래의 정의를 보면 공개키, 거래내용, 전자서명만 노출 되는데 공개키는 노출이 되더라도 익명으로 유지함으로써 개인정보를 지킬 수 있다는 것이다. Private Key 는 온라인 상 나의 Identitiy를 나타내는 것이므로 노출되지 않도록 주의해야한다.

 

Calculations

계산식만 따로 가져와서 해석해보자.

 

 

p = probability an honest node finds the next block
q = probability the attacker finds the next block
qz = probability the attacker will ever catch up from z blocks behind

Attacker가 정직한 체인을 언젠가는 따라잡을 확률이다.

p = 정직한 노드들이 다음 Block을 찾을 확률

q = Attacker들이 다음 Block을 찾을 확률

qz = z 개만큼 뒤처진 Attacker가 언젠가 따라잡을 확률

 

Attacker가 따라잡을 수 있는 확률을 구하기 위해 가능한 진척도에 대한 푸아송 확률에 그 시점부터 따라잡을 수 있는 확률을 곱해준다.

분포 끝부분에 무한급수를 피하기 위해 식을 정리하고 계산해보면..

 

Attacker가 Block을 생성할 확률이 0.1

뒤처진 Block 개수가 클수록 따라잡을 수 있는 확률이 급격하게 감소한다.

 

 

Attacker가 Block을 생성할 확률이 0.3

일때도 마찬가지..

 

 

 

 

 

 

 

 

따라잡을 확률이 0.1 % 이하를 유지하려 할 때

Attacker가 Block을 생성할 확률에 따라 따라잡을 Block의 수를 보여준다.

 

 

 

Attacker가 과반수를 넘는다 해도 정직한 노드의 역할을 하는게 경제적으로 이득이라는 것을 잊으면 안된다..

 

 

 

 

 

 

Reference

https://www.bitcoin.com/get-started/bitcoin-white-paper-beginner-guide/

http://wiki.hash.kr/index.php/%EB%B9%84%ED%8A%B8%EA%B3%A8%EB%93%9C

https://en.wikipedia.org/wiki/Merkle_tree

https://en.wikipedia.org/wiki/Moore%27s_law

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함