How does mining bitcoin work ? – Flow Process

in #blockchain8 years ago

In the previous article, I wrote about the 2 concepts on how the blockchain technology work on hash cryptography and link.So today, this article is about on how this concept been implemented in Bitcoin and how does bitcoin mining work with easy examples.

Yes! Bitcoin! the first cryptocurrencies have been implemented with blockchain technology.

By the way,

Did you know? Bitcoin was created by Satoshi Nakamoto, but Satoshi Nakamoto is just a man without faces. In 2014, The world’s media though Dorian Satoshi Nakamoto is the real identity, he denied it.

For better understanding I will start by brief the flow of bitcoin process then I will explain in more deeper for each process.

Transaction request – You would like to send 10BTC to Alice.
P2P network or Blockchain network with ‘Miners – The transaction request will be sent to the bitcoin blockchain network for validation and process the transaction.
Linked and Verified – Your transaction will include in the block and send to the bitcoin blockchain network.
Confirmation- Alice will get the confirmation from the blockchain network, indicate the transaction have been processed.

#1 Transaction request

As soon you register in Bitcoin network, you will be provided will various choice of Bitcoin wallet. Example like ArcBit , Bitcoin core, Bitcoin Knots and others. You will have to install Bitcoin wallet on your computer or mobile phone depending on your usage.Check out here!

Bitcoin wallet can be equivalent to the physical wallet, except it is digital and stores your Bitcoin (technically location/address) and private key.In physical wallet people usually keep a certain amount of money, identification card, license card, debit/credit card, business card and relevant thing in the wallet.Analogously:

  • Money is your bitcoin .
  • An identification card is your private key.

As everybody knows it, the identification card is the proof of citizenship, so do for the private key, it recognizes you as an authentic owner of the bitcoin you own in the wallet and it should be kept in secret.

Let’s dive deeper,

You will be assigned to the private key and public key ( ‘cryptographic key pair’). The public key is created from the private key which it will be used to validate by the node to ensure the transaction request is actually coming from legitimate owner, where in this case is YOU. By default, your private key is 256-bit with the combination of 36 alphanumerics.

Example:
5CF2A070917629477FF1E7DE1DA320D35700831734F08B3C37584351A29D7676

Example :
Let’s say you are a secret agent from CIA, you were requested to send a secret message/document to your partner to another country. As an agent, you must ensure the information originality is retain. So, what you do is to create two message :

  1. Original message.

  2. Encrypted message (encrypt/signed with private key).

From this private key, you are generating a public key.The private key is used to make the encrypted message.

  • Private key: “No No here” .
  • Public key: “K no ck k no ck who’s t here ?”.

When your friend received that message, before he/she going to read the message, he/she will check the original message and compare with the encrypted message by decrypting the encrypted message using the public key “Knock knock who’s there?”.

If both of the messages are in the same shape and handwritten , that means the message is coming from the true owner.

You must understand why your friend decrypt back using the public key, right? it is because only through the public key he/she can open the encrypted message which has been generated from the private key.

This concept is called digital signature which involves the mathematical computational algorithm(hash method)and also automatic processes in the background of the bitcoin network.

In bitcoin environment, instead of sending a message, you are sending :

  • Your transaction details like amount bitcoin to send
  • Private key
  • Sender address(receipt who going to receive the Bitcoin)

The transaction request by you will be signed/encrypted by your private key and this transaction will be verified by the node in the bitcoin blockchain network using your public key.

The main purpose is to compare the hash values between the original message and hash value of the encrypted message. If both of it same then it should consider the valid transaction.

source from revasolutions.com

#2 P2P Network or Blockchain network with Miners

Do you remember the last article I wrote about what it means by the P2P network in blockchain? here. Just a brief explanation of it, blockchain network is the concept of Peer-to-Peer (P2P) where multiple nodes like your pc hardware could be used to validate transaction or mining bitcoin. Nodes basically can be anybody who installs bitcoin software and equipped with sophisticated hardware.

According to Bitcoin.org mining is a process of using sophisticated hardware(eg. Mining Rig ) to process transactions, secure the network, and keep everyone in the Blockchain network organize.

I know some of you might be interesting to hear more about the hardware but don’t worry I will discuss that in the next article.

As for now, let’s focus on the basic first.

How is this ‘miners’ process your transaction? Here i grouped the process in 3 stage .

  • Validation
  • Collection & block process
  • Mining

Validation process

The transaction is propagated and validated by the nodes in the network based on the concept of digital signature I explained above. The network will check whether the amount the bitcoin is actually available and you are the owners of it based on your public bitcoin key address history. As I explained before bitcoin is public ledger where every node has the record of your bitcoin history.This process is important to prevent all transaction from conflicting with one another.


source from ybrikman.com

Example:

If Alex wants to buy a carpet and decided to pay 10 BTC to Diana, there is also imposter would like to perform the same transaction, pretending he/she did it while actually didn’t, in hope that he/she can get the carpet using your BTC.This should not happen! any transactions conflict should be avoided before wrapping the transactions in the block for mining.

Collection and block process

Then miners will collect all of the transactions including your transaction and wrap in a block.

Mining

The miners will perform calculation cryptographic hash function or ‘Hashing’ to the block by adding ‘nonce’. ‘Nonce‘ is just like random number the ‘miners‘ use to try with.This process is to ensure that the block cannot be produced easily. So, through this process, the ‘miners’ continuously adding nonce until they meet certain criteria(mining) and will be rewarded for doing it.Currently, the reward is 12.5 BTC, this reward will decrease halve when bitcoin block reaching 210,000 blocks, make it to 6.25 BTC.

What the criteria? whoever produces the small-enough hash value and ensure the ‘leading zero‘ is according to the current difficulty level will win! Difficulty rise as more miners and bitcoin network keep expands.

Example formula :

block(Transactions + nonce) = Hash ( small enough)

Let’s hashing word ‘helooo’ and adding with a nonce (random number). In blockchain environment, this ‘helooo’ word will be in hash value, but just for this scenario, I will cover in a word to make it more easy to see and understand.

Example:


Figure 1


Figure 2

Yes! I got 3 ‘ leading zero‘ , which might be the current mining difficulty and smallest hash value. This successful mining data will be wrapped in another block and this block then will be added to the chain. If you notice I need to perform multiple ‘hashing’ from ‘helooo111’ until I found the leading zero at ‘heloo226′(figure 2) , this is refer to mining. Whoever faster they get to add the block to the chains and be rewarded. Try this simulation! it will help you get the picture.


source from bloomberg.com

#3 Link and verified

Now, if you remember from the previous post here. I wrote about the link where each block connected to the previous block.This is the part where the link is created. As soon, the ‘miners’ able to create the required block, this block will be added to the blockchain network.At this stage, your transaction is considered verified.

#4 Confirmation

The recipient will receive first confirmation as soon their transaction successfully added to blockchain network.

However, the recipient is free to choose their threshold on how many confirmations they will receive, but it is safer to wait until 6 confirmation (6 blocks added after your batch block) in order to prevent double spending scenario.

Summary :

  1. All transactions will be collected from the blockchain network.
  2. Nodes will validate and ensure no transaction conflicting.
  3. The transactions will be wrap in a block to be mining.
  4. The nodes will start to mine by performing the calculation cryptographic hash function over and over until finding the small- enough hash with leading zero. A will block will generate.
  5. This block will be submitted to the blockchain network.
  6. 'Miners’ are rewarded.
  7. The recipient will receive the confirmation of the transaction.

The flow of Bitcoin process

If you can found this article on “How does bitcoin mining work ?” is good, feel free to share it. Thank You.

Sort:  

For future viewers: price of bitcoin at the moment of posting is 7965.91USD

Congratulations @explorerwriter! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 1 year!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Do not miss the last post from @steemitboard:

Are you a DrugWars early adopter? Benvenuto in famiglia!
Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Congratulations @explorerwriter! You received a personal award!

Happy Steem Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Do not miss the last post from @steemitboard:

Downvote challenge - Add up to 3 funny badges to your board
Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Coin Marketplace

STEEM 0.04
TRX 0.32
JST 0.082
BTC 62333.05
ETH 1669.91
USDT 1.00
SBD 0.41