無知

갈 길이 먼 공부 일기

기술 공부/블록체인

비트코인의 작동 방식 | But how does bitcoin actually work?

moozii 2021. 12. 30. 19:35
But how does bitcoin actually work? (By 3Blue1Brown)

지난 글과 마찬가지로, 거래 장부의 작성 상황에 대입해서 비트코인의 작동 방식에 대해 살펴봅시다

We’ll start with you keeping track of payments with your friends using a communal ledger.

앞선 블록체인 작동 방식 중, <봉인 작업의 인센티브로서의 코인>에 대한 부분을

조금 더 상세하게 설명해준 유튜브 영상에 대한 해설본입니다.

 

 

3Blue1Brown

스스로 코인을 만들어가는 과정을 따라보며 비트코인의 원리를 확인해봅시다.

Walking the path of inventing your own can help set the foundation for understanding some of the more recent players in the game, and recognizing where there’s room for different design choices.

 

다른 사람과 돈을 주고받은 내역을 정산하는 장부가 있다고 합시다. 

 

첫 번째 문제는, 당사자의 동의 없이 내역을 조작할 위험입니다

One problem with a public ledger like this is that when anyone can add a line, what’s to prevent Bob from going in and writing “Alice pays Bob $100” without Alice approving? How are we supposed to trust that all these transactions are what the sender meant for them to be?

 

여기서 등장하는 첫 번째 개념이자 해결방안은, 디지털 서명입니다.

 

<디지털> 서명의 문제는, 복제되기 쉽다는 점인데요, 

이를 방지하는 개념으로 공개 키 / 비밀 키를 활용합니다.

 

3Blue1Brown

비밀 키를 통해 <본인>만이 서명이 가능한 구조를 만들 수 있습니다. 

Formally, producing a signature involves some function that depends both on the message itself, and on your private key. The private key ensures that only you can produce the signature, and the fact that it depends on the message means no one can just copy one of your signatures to forge it on another message.

 

3Blue1Brown

메시지와 비밀 키를 입력 값으로 활용하면 공개할 수 있는 서명을 만들 수 있고,

메시지와 서명, 그리고 공개 키를 입력 값으로 활용하면 그 서명이 본인이 작성한 것인지, 

옳은 비밀 키를 기반으로 작성한 것인지를 간단히 검증할 수 있기 때문입니다. 

 

즉, 비밀 키를 모르는 제 3자는 내역을 조작한 뒤에 올바른 서명을 작성할 수가 없습니다. 

(애초에 서명은 이진수 256자리에 해당하는 긴 수이기 때문에 랜덤으로 때려 맞힐 확률이 매우 낮습니다.)

To get around that, we make it so that when you sign a transaction, the message has to include some unique id associated with that transaction.

 

3Blue1Brown

 

하지만, 비밀 키를 기반으로 한 서명을 만들었다고 해도, 

<메시지와 서명> 전체 한 줄을 장부 내에서 복사하게 되면 복제가 가능한 위험이 있습니다. 

그래서 우리는 각 거래 내역에 고유 ID를 설정해두어 디지털 서명의 입력 메시지가 매번 달라지도록 합니다.

 

두 번째 문제는, 거래 당사자가 거래를 이행하지 않고 도망칠 위험입니다.

이럴 경우에 대비해서, 우리는 프로토콜에 한 가지 조건을 추가합니다.

3Blue1Brown

잔고를 확인하고, 잔고를 초과하는 금액의 거래가 발생할 경우 거래 내역 작성이 불가능한 구조를 설계합니다.

So maybe you have the clever idea that you never actually have to settle up in cash as long as you have some way to prevent people from spending too much more than they take in. What you might do is start by having everyone pay $100 into the pot, and have the first few lines of the ledger will read “Alice gets $100, Bob gets $100, etc. Now, just don’t accept transactions when someone is spending more than they have on the ledger.

즉, 블록체인은 이전의 거래 내역을 모두 알고 현황을 확인한 뒤에야 거래를 집행함을 의미합니다.

Notice, this means you need to know the full history of transactions to verify that a new one is valid. And this is, more or less, going to be true for cryptocurrencies as well, though there is a little room for optimization.

 

세 번째 문제는, 옳은 장부에 대한 증명입니다.

그렇게 정리해둔 공동체 일원들의 거래 장부는 한 사람이나 하나의 기관이 중앙집중적으로 관리를 하지 않도록 합니다.

 

모두가 소유하고 모두가 함께 관리하도록 모두에게 복제합니다
To remove that bit of trust, we’ll have everyone keep their own copy of the ledger.

 

함께 관리하기 위해서는, 무엇이 옳은 장부인지에 대한 합의가 필요합니다. 

How can you get everyone to agree on what the right ledger is?

Can you come up with a protocol for how to accept or reject transactions and in what order so that you can feel confident that anyone else in the world following the same protocol has a personal ledger that looks the same as yours?

 

그 합의를 도출할만한 장부 작성 및 확인 방식이 바로 비트코인 프로토콜입니다.

 

 

비트코인의 핵심은, 가장 컴퓨팅 작업이 많이 소요된 장부가 믿을 만하다는 것입니다.
At a high level, the solution Bitcoin offers to trust
whichever ledger has the most computational work put into it.

 

이를 설명하기 위해서는 암호화폐에 사용하는 해쉬 함수를 설명해야 합니다.

I’ll take a moment to explain what exactly that means, which involves this thing called a “Cryptographic hash function”.

 

일반적인 아이디어는, 컴퓨팅 작업량을 신뢰의 기반으로 삼기 위해서, 

<장부를 조작하려는 행위에는 천문학적인 컴퓨팅 작업량을 요구>하는 체계를 만들라는 것입니다.

The general idea we’ll build to is that if you use computational work as a basis for what to trust, you can make it so that fraudulent transactions and conflicting ledgers would require an infeasible amount of computation.

 

3Blue1Brown

In fact, for the hash function I’m showing here, called SHA256, the way that output changes as you slightly change the input is entirely unpredictable. You see, this is not just any hash function, it’s a cryptographic hash function. That means it’s infeasible to compute in the reverse direction.

SHA256이라는 해쉬 함수는,

입력 값을 조금이라도 변경하면, 출력 값인 2의 256자리 값 전체가 <예측할 수 없게> 변경된다는 특성을 지녔습니다.

<역산이 불가능하다>는 의미입니다. 

SHA256은 구현 방식이 널리 알려졌음에도 그 누구도 역산을 해내지 못한 해쉬 함수로서 인터넷에 범용적으로 활용되는 암호화 방식입니다.

 

앞서 말했다시피, 우리는 <컴퓨팅 작업량을 많이 요구하는> 신뢰 체계를 만들어내야 합니다. 

위에서 설명한 해쉬 함수를 활용해서 아래의 문제를 풀라고 하게 되면 <컴퓨팅 작업량을 많이 요구>할 수 있습니다.

 

<출력 값의 앞 30자리가 모두 0이 나오는 SHA256 함수의 입력값을 구하시오>

 

3Blue1Brown

For right now, our focus will just be on how such a function can prove that a particular list of transactions is associated with a large amount of computational effort. Imagine someone shows you a list of transactions, and they say “I found a special number so that when you put this number at the end of list of transactions, and apply SHA256 the entire thing, the first 30 bits of the output are zeros”. How hard do you think it was for them to find that number? For a random message, the probability that the hash happens to start with 30 successive zeros is 1 in 230, which is about 1 in a billion.

 

거래 장부의 내역에 <특정한 값>을 추가하여 SHA256에 입력할 때,
출력값의 앞자리 30자리가 모두 0이 되도록 하는 <특정한 값>을 구하시오
.

 

 

이 문제를 해결하고 <특정 값>을 구하는 것을 우리는, Proof of Work, 작업 증명이라 부릅니다.

 

다시 본론으로 돌아와, 우리는 모두가 동의하는 <옳은 장부>에 대해 합의해야 합니다.

핵심 아이디어는, 모두가 <컴퓨팅 작업량이 가장 많이 투여된> 장부를 신뢰하는 것입니다. 

그래서 우리는, <본인만이 가능한 디지털 서명을 보유한 거래 내역>이 옳다고 합의했고, 

<작업 증명이 부여된 거래 내역 장부 블록>이 옳다고 합의했습니다.

 

3Blue1Brown

 

그다음으로는, 작업 증명을 포함한 거래 내역 장부 블록들을 정리해야 합니다.

So now think back to our distributed ledger situation. Everyone is broadcasting transactions, and we want a way for everyone to agree on what the correct ledger really is. As I said, the core idea behind the original bitcoin paper is to have everybody trust whichever ledger has the most work put into it. This work is to first organize a given ledger into blocks, where each block consists of a list of transactions, together with a proof of work.

 

네 번째 문제는, 장부 간의 순서 정리입니다.

블록을 작성하고 작업 증명을 만드는 것은 지금까지의 설명대로라면 모두 격리된 프로세스입니다. 

그렇기 때문에 지금까지의 방식으로는 블록 간의 순서가 무엇이 옳은지를 증명할 수 없습니다. 

 

따라서 우리는 다음 블록의 작업 증명을 진행하는 과정에서, 

앞선 순서의 블록의 작업 증명 해쉬값을 포함하도록 합니다.

 

3Blue1Brown

Also, to make sure there is a standard way to order of these blocks, we’ll make it so that a block has to contain the hash of the previous block. That way, if you change any block, or try to swap the order of two blocks, it would change the block after it, which changes that block’s hash, which changes the next block, and so on. That would require redoing all the work, finding a new special number for each of these blocks that makes their hashes start with 60 zeros.

 

이렇게 되면, 특정 블록을 조작하기 위해서는 그 이전의 거래 내역을 담은 블록들까지 모두 컴퓨팅 작업을 통해 새로운 해쉬 값을 부여해야 하기 때문에 매우 어려워집니다.

 

 

거래 장부 블록들이 하나의 사슬처럼 이어지는 인증 체계를 갖춘 것을
우리는 블록체인이라 합니다.
Because blocks are chained together like this,
instead of calling it a ledger, this is commonly called a “Blockchain”.

 

다섯 번째 문제는, 작업 증명의 인센티브입니다.

What this means is that they’ll listen for the transactions being broadcast, collect them into a block, then do a whole bunch of work to find the special number that makes the hash of this block start with 60 zeros, and broadcast out the block they found. To reward a block creator for all this work, when she puts together a block, we’ll allow her to include a special transaction at the top in which she gets, say, 10 LedgerDollars out of thin air. This is called the block reward.

3Blue1Brown

이 일련의 작업 증명 과정을 공동체 일원들이 수행하도록 인센티브 차원에서 코인을 지급합니다. 

코인 지급 내역은 블록에 이미 함께 명시되어 있습니다.

It’s a special exception to our usual rules about whether or not to accept transactions; it doesn’t come from anyone, so it doesn’t have to be signed.

특정인과의 거래로 받는 코인이 아니라, 

인센티브 차원에서 새로이 생성되기 때문에, 별도의 서명이나 발신인이 필요 없고, 

코인의 발행 양을 늘리는 행위입니다.

그렇게 코인을 작업 증명을 수행한 대가로서 얻어내는 것을, <채굴>이라 합니다.

 

또한, 채굴 행위에 대한 인센티브 차원에서, 채굴이 종료된 후에도 해당 블록이 거래되기 위해서는,

채굴자에게 수수료를 지불하도록 합니다.

 

3Blue1Brown

 

More Fun Fact

비트코인은 느린편
매우 한정적이라는 비판

 

이 글도 좋아요

 

How the Bitcoin protocol actually works | DDI

Many thousands of articles have been written purporting to explain Bitcoin, the online, peer-to-peer currency. Most of those articles give a hand-wavy account of the underlying cryptographic protocol, omitting many details. Even those articles which delve

michaelnielsen.org

 

다음에 시간 되면 비트코인 원 보고서도 읽어보고 싶네요