Sitemap
haRies Efrika

haRies Efrika

Blockchain/ Bitcoin Explained

13 min readJun 26, 2026

--

I have been wanting to write this for a while, but only got free time recently. I understand this is not state of art technology and people have moved the focus to AI for sure, but I am writing this because my son has been interested in it and I was trying to explain to him the process behind. My target is that, whoever reads this will understand the end-to-end process in bitcoin and hopefully, able to easily re-tell the story to other people.

Press enter or click to view image in full size

What is Blockchain?

Someone said to me that Blockchain is linked-list with steroid. I would agree on that. So you can imagine series of blocks, chained each other with clear order which block comes first and after.

[block 0]--> [block 1] --> [block 2] ...... --> [block 5000]

One block contains transaction data. In case of bitcoin, the block will contain transaction log/history (transfer amount from one address to another). In case of other type of Blockchain like NFT, it will contain history of item ownership and item ID/ short description. Please note that data inside the block, once committed, is non-mutable, non-changeable.

Block data are open and replicated to all nodes in Blockchain network. Miner node must have all historical data/ block from the beginning until recent.

There are rules on how a block will be written and committed, and every time new block data get added and broadcasted to the network, all nodes will do re-verification of new block authenticity and integrity. Because it is open, and all nodes are verifying, it is what makes Blockchain data non temper-able.

Though open, there is personal data written on block or other database related with blockchain. Public key is used to identify authority of certain data inside blockchain. Person who owns the pair of public and private key, is the only one able to do data mutation.

Private and Public Key

Key pair has been part of international cryptographic security standard for so many years. You basically have a random big number as private key and then there is certain algorithm where you can generate the public key based on that private number. We are talking about really huge number of 256 bits, this means maximum is 2 ²⁵⁶ − 1


115792089237316195423570985008687907853269984665640564039457584007913129639935

== 1.15 x 10^77

So my private key is some of random number from 0 to that maximum number, while your private key will be another random number.

When generating new random key, can it clash someone else’s already owned key?

Possible but not feasible. If all of humans on earth (say 8 billion) are generating new key for every second, continuously for 1000 years, we will have total of 2.52×10²⁰.

Number of humans: 8 x 10^9
seconds in 1000 years: 1000 x 365 days x 24 hours x 3600s ==> 3.15 x 10^10

total key generated = 8 x 10^9 x 3.15 x 10^10 ==> 2.52 x 10^20

If we compare generated keys with the total possible keys (power 20 compared with power 77), we can simply see that the free space is very large, like 10⁵⁷ times larger. There is Birthday Paradox theory in cryptography (you can google it) which can explain probability of key collision (two persons generated same key) is only 0.00000000000000000000000000000000000027%.

Key administration

Having to keep and store private/public key pairs is not practical. They are very long number, hard to remember and if you just store them randomly, like on notes, high chances someone can copy paste them. Therefore in bitcoin (or other blockchain), we use what is called Seeds.

Deterministic Seeds

Seeds are series of words that will act as your password. You can’t remember all of your private keys, but you can remember series of words. So as part of bitcoin standard (now has become Blockchain standard), there are already prepared 2048 dictionary words that we can pick from. And we have to pick 12 or 24 words as our main password. Example picked series of words:

abandon ability able about above absent absorb abstract absurd abuse
access accident account accuse achieve acid acoustic acquire across act

When I said “pick” I did not actually mean pick one word by word manually. We have to do it automatically via wallet software in our android phone, for instance. There is way called cryptographically secure random number generator (CSPRNG), that will be used to randomly pick word from dictionary and it will prevent possibility of clashing with other people’s seeds.

OK so now what happens after I have the seeds? The seeds will be used to create master key (that usually is transparent to us, we don’t care nor remember). And master key will be used to generate deterministic child private keys. So for same seeds words, in example, the child keys generated will ALWAYS Be the same i.e.

1st child key generated:  lsdfkjs803423809u4lksdfjsdkl09838
2nd child key generated: kxzkiengios83kjms82804kljsdf08934
... and so on

Therefore, in case you lost your phone or PC, but you still remember the seeds words (or kept them in somewhere safe), the keys for your bitcoin wallet is safe can be always generated at any other time.

We were talking about private key, but why now child keys?

The actual one to be used in bitcoin trading will be the child keys. To increase security and anonymity, every time you receive new fund (someone transferred money to you), the standard is to use/ generate new wallet. One wallet represents one private key. When you are sending out money, the application is smart enough to collect all wallets you have and use them as source fund. You only see the total unified balance in bitcoin application, no matter how many sub wallets you actually owned.

How private and public key is actually used?

In other topic, private and public key can be used to encrypt/ decrypt message. A message encrypted by public key can only be decrypted by private key. Public key is meant to be public and broadcasted. When you are opening https website from your web browser. You are actually exchanging public key, between your browser in your laptop, with public key of that website. It is used first time to exchange a shared random key. Afterwards the data transmission inbound/outbound is done on shared key.

In other topic though, including blockchain, the private/public keys are used to sign and verify. I can sign data using private key, and other people can use my public key to verify if that signed data actually was signed by me.

Say,
public_key = "my public key"
private_key = "secret dough"

sign("this is text so sign", private_key) = "i8dkwerkoiserlkjsdf8i3802"

verify("i8dkwerkoiserlkjsdf8i3802", public_key) = true
verify("i8dkwerkoiserlkjsdf8i3802", "other public key") = false

With this signing/ verification process, bitcoin network will know that request for transaction is actually coming from legitimate owner for that wallet.

Bitcoin Money Transfer Process

Alright, now is time to look at how the process behind the scene. First of all, wallet address is represented by public key. But not plain public key, instead a “hashed” public key. Hashing is a way to create unique text data based on input. If you have never heard about hashing before, this is example:

haries@thinkpad-x1:~$ echo "abc12345" | md5sum
a90acb735b18a3314f2db44104bea194 -
haries@thinkpad-x1:~$ echo "abc12346" | md5sum
8a1fc9990d204b3e40f1f5c88414b6a0 -

In general, hashing is used to get uniqueness of certain data. As you see from above example, even when I changed only one digit, from 5 to 6, the hash output is totally different. There is standard algorithm used for hashing, but I will not go into detail for hash method in bitcoin, for simplicity purpose in this article. Hashing can be done by CPU, but later on we will touch a bit other hardware that is more effective.

About UTXO (Unspent Transaction Output)

In bitcoin network, imagine UTXO as summary table of balance. It is derived table, means the main source of truth is still the blockchain data with transaction log. UTXO serves like cache, or easier way to lookup balance data. Example:

Transaction id, vout index,  amount,    wallet address
--------------------------------------------------------
abc123, 0, 0.5 BTC, john address 1
abc123, 1, 1.0 BTC, alice address 1
def456, 0, 0.2 BTC, bob address 1
hij789, 0, 0.1 BTC, bob address 2

Notice that for transaction id abc123, there are two vout indexes. Means in previous single transaction logged, was somehow making changes to john’s and alice’s wallet balance, resulting to their final balance 0.5 and 1.0 BTC respectively.

Please notice as well, Bob final balance is actually 0.3 BTC, covering two sub addresses.

Whenever there is new block added to block chain (remember, one block contains a lot of transactions), the UTXO table is updated. If balance amount is already spent out, it will be removed from the table. So say if in the future alice spends all her 1.0 BTC, her record will no longer be in UTXO table.

Say, Alice owns 1 BTC and wants to transfer 0.3 BTC to Bob.

If you see the previous UTXO table, in the future, we will have the following UTXO:


Transaction id, vout index, amount, wallet address
— — — — — — — — — — — — — — — — — — — — — — — — — — — —
abc123, 0, 0.5 BTC, john address 1
def456, 0, 0.2 BTC, bob address 1
hij789, 0, 0.1 BTC, bob address 2
xxx555, 0, 0.6 BTC, alice address 2
xxx555, 1, 0.3 BTC, bob address 3

You are noticing couple of changes:

  1. Bob’s existing addresses row do not change. Alice can only make balance mutation to her own wallet.
  2. Bob got new address as new placeholder to the transfer.
  3. Alice’ old UTXO is fully spent and the change, is kept on new address. This is according to the bitcoin protocol so that it makes it extremely difficult to trace back whose address belongs to which identity.
  4. Alice’s original balance was 1BTC, transferring 0.3BTC, but her final wallet becomes 0.6BTC. This is because of the fee. The delta (0.1), if there is any — is automatically considered as transaction fee. Alice has freedom to choose how much/ big as fee from the application.

If she wants, she could also set 0 fee. However later on probably no miner would be processing her transaction request. Completing the transaction is expensive, nobody would want to spent resources and electricity for free.

OK, let’s go back to the original topic about transfer process, so the first step is to create a transaction info, consisting of:

  • input: this is current UTXO representing Alice’s address (abc123, vout=1)
  • output: you already have seen on UTXO example above, two new rows with same xxx555 transaction id.

This transaction info will be hashed, and then the hash value will be used to generate signature, informing public that this is genuinely coming from Alice as the owner of that UTXO.

Then data is broadcasted, consisting of:

  1. Transaction info
  2. Signature
  3. Public key

The Mining Process

To easily understand the concept, in this example we will eliminate any mining race. Say, there is only one miner in the world that will process Alice’s (and other’s) transactions.

The previous transaction broadcast will be received by miner node. The signature and transaction hash will be verified. If valid, it will be queued under Mempool.

Get haRies Efrika’s stories in your inbox

Join Medium for free to get updates from this writer.

So, Mempool is place where all of transactions requests are waiting to be processed and completed. Say alice’s transaction is tx1, we will have other transactions waiting i.e.

Inside mempool:
tx1
tx2
tx3
tx4
...
tx1000

The miner node is picky, it will select some transactions that fit its criteria, most likely the one offering highest fee. How many will be picked, it will be as many as possible that fits maximum bitcoin single block size. So it could be that one block candidate will be created, assuming one block only fits five transactions, only for the example purpose:

[tx1, tx10, tx25, tx26, tx99]

Say currently in the bitcoin network the maximum block right now is 5000 i.e.

[block1]--[block2]--[block3] ... --[block4999]--[block5000]

Then the previous example is candidate for block5001.

From the block content, miner can generate block header. The algorithm to create the header can be googled ;)

Now it is not easy to make that block candidate be committed to blockchain. There is so called challenge. For every new block candidate and current time, there is mechanism in bitcoin protocol to automatically determine the challenge target for the miner(s).

The challenge:

Find the nonce (imagine this as serial number/ index) value that will result in hash value (in big number) to be smaller than the challenge target.

Real target example:

000000000000000000003a4e5f6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4

The difficulty of challenge is determined by how many leading zeroes it has.

The following is example of VERY EASY target ever:

f00000000000000000003a4e5f6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4

Notice that I changed the left most number to F. This will make the number value to be very big, hence with few tries, most likely we can have hash value that is lower than that target.

The following is example of almost impossible (very difficult) target ever:

0000000000000000000000000000000000000000000000000000000000003a4

What is the chance you will get hash result that is numerically, lower than that? probably impossible. To give you more figure, please have a look at this example:

haries@thinkpad-x1:~$ echo "haries 0" |sha256sum
1c95fbf0f20377c7333ae217de92b84164f770ea5b3b94b32030a04f963d23a2 -
haries@thinkpad-x1:~$ echo "haries 1" |sha256sum
21b8149e31f2b333345cbabb74f4c5b6fe1ee2ab0eca0ca3a4c8f70814b086cd -
haries@thinkpad-x1:~$ echo "haries 2" |sha256sum
5dbbde3f7a5253b99fc985a786aa1994e946db57999ae374f625ef180eedfc7a -
haries@thinkpad-x1:~$ echo "haries 3" |sha256sum
cf29a6f38930c220148dd5612842f0898cd086263858fe3a9e5eb6dd2eb9c31f -

In that example, I was increasing the nonce from 0 to 3, and as you see, I didn’t even get any hash result with leading one zero 0abce9090... moreover if I have to find the value that has a lot of leading zeroes 000000000000.....

Back to topic, the concept of bitcoin mining challenge is very similar. Find the nonce until the hash result is lesser than the target:

result = hash(
block header,
nonce
)

But the nonce is just integer 32 bit. Means there is high possibility you hit nonce max number without finding solution. In this case the block header is modified a bit. You modify part of block called scriptsig, where it can contain 96bytes of space. That is huge combination of 2⁷⁶⁸. People call this as ExtraNonce. Then after updating ExtraNonce, the nonce is reset back to 0.

This a lot of hashings, is the reason why miner back then initially use GPU. Though hashing calculation is possible via CPU, but the GPU hardware capability is much faster. As comparison, The RTX 4060 is roughly 100 times faster than the i7–14700K at SHA-256 hashing. But nowadays there is ASICs (Application-Specific Integrated Circuits). An ASIC is a chip designed to do nothing but SHA-256 math. An ASIC is roughly 15,000 times faster than an RTX 4060.

OK, so our single miner works hard, and finally after repeating the entire nonce from 0 to 4,294,967,295 for many times while changing ExtraNonce, we found hash result that is smaller than target. The mining node will publish the proof of work (block, the challenge target and the solution nonce) to bitcoin network, will be received by other (all) nodes, and will be verified if the solution is indeed correct.

Please remember that in real case, everybody is racing to the first one committing block candidate of 5001. If you publish the solution but someone else already broadcasted the solution and be part of accepted block by majority of nodes, you just lost time and resource.

Just for information, bitcoin protocol has mechanism to automatically detect if target difficulty is too easy or too difficult and will be adjusted accordingly.

Mining Competition

Because mining is so difficult, people are making what so-called mining pool. Mining pool consists of so many miners working together to find solution, led by pool master/ owner. The pool master is the one setting up block candidate. Let’s go with this example:

pool1: consisting of miner m1 (master), m2 m3 is proposing block 5001 [tx1, tx2, tx3]

while

pool2: consisting of miner m4 (master), m5 m6 is proposing block 5001 [tx1, tx8, tx9]

In pool1, the task is split, for example:

  • m1 is working on block variant 1
  • m2 is working on block variant 2
  • m3 is working on block variant 3

The variant is actually change on ExtraNonce. The first 3 bytes are set by master to indicate miner ID. Then the rest of 93 bytes are free to change by each pool member.

Finally one of them will find the solution, and report to pool master i.e.

  • m1 has been hashing 100,000,555 times, did not find solution
  • m2 has been hashing 50,000,123 times, did not find solution
  • m3 has been hashing 1,000,456 and found the solution.

The pay split is not based on who found the solution, since it is just “luck”. Instead, based on how many hashes have been done. Therefore the fee split later on will be 100:50:1 approximately.

How much the pool will earn commission?

Aside from the transaction fee (i.e. 0.1 BTC if you refer our previous example), there is what is called block subsidy. Block subsidy is a BTC that comes out of nowhere, as a reward the completing a block and the network majority agrees to use that block as proceeding of block 5000. The current value is 3.125 BTC.

When bitcoin firstly launch, the block subsidy was 50 BTC. Then every 4 years, it halves.

2009 50 BTC
2012 25 BTC
2016 12.5 BTC
2020 6.25 BTC
2024 3.125 BTC
~2028 1.5625 BTC

So the total reward for our example will be 3.225 BTC. The split of reward will be handled internally by the pool community, and not part of official bitcoin network protocol.

The reward will first come to pool master wallet address out of thin air, so the very first data in the block actually contains this compensation. It has no input and simply just assign BTC to master’s address.

Block Races

Now we come to situation where both mining pool1 pool2 submitted their block candidate/solution at same time.

[block4999]--[block5000]

--[block5001a] candidate from pool 1
--[block5001b] candidate from pool 2

Now it just matters on which block candidate “arrives” and be committed first. It could be that on Node1 somewhere, block5001a came first and got verified.

                    ┌→ Block 5001a (first)
Block 4999→ 5000 →→→
└→ Block 5001b

But on other hand, it could be that Node2 somewhere saw block5001b that came first:

                    ┌→ Block 5001a 
Block 4999→ 5000 →→→
└→ Block 5001b (first)

This is perfectly normal, called Temporary Fork or Chain Split.

Because Node1 sees 5001a first, believing it is the correct one, it will try to work a new block candidate 5002 based on it:

                    ┌→ Block 5001a → 5002 
Block 4999→ 5000 →→→
└→ Block 5001b

However, Node2 and few other nodes have been working on top of 5001b and already submitted more blocks:

                    ┌→ Block 5001a
Block 4999→ 5000 →→→
└→ Block 5001b → 5002x → 5003

Because Node1 also gets published proof of work on top 5001b, it sees that 5001b branch now has LONGER blocks than 5001a.

                    ┌→ Block 5001a → 5002
Block 4999→ 5000 →→→
└→ Block 5001b → 5002x → 5003

Therefore it will stop what it is doing, and will consider the 5001b as the real winner. It will discard the 5001a branch, will rollback its UTXO snapshot, back to 5000, and re-update the UTXO based on 5001b, then 5002, then 5003, before finally trying to race for 5004. The branch 5001 will be left stalled, and all of its effort to submit 5002 was in vain. So sad, but this is harsh truth in bitcoin protocol.

Now if you have hard about bitcoin confirmation, it actually represents how many miner have verified the block and put it inside their server. Chain split is one of the core reasons why Bitcoin requires multiple confirmations — to ensure the transaction is deep enough in the chain and won consensus.

Thanks for reading, and have a good day everyone 🍻!

--