bitcoin and blockchain: what math puzzle do miners actually solve? example with real transactions — Steemit (2024)

In this post we will try to break down, in simpler terms, the mechanism of blockchain and bitcoin. Readers are assumed to be familiar with a few basic cryptography and blockchain related terms. Today, I'll specifically focus on transaction validation and mining rewards. Transactions are validated by miners by solving complicated math puzzle and the first miner to solve this puzzle is rewarded with brand new coins aka virgin coins. This creation of new coins is somewhat equivalent to printing paper money by a government, or as economists put it, quantitative easing. A government can print money at will resulting in inflation and currency's devaluation. But creation of money in bitcoin economy is pre-defined in such a way that the total supply approaches to 21 million (20.99999998 million to be exact) by 2140. After that no coins will be created. It's not possible to manipulate supply and hence price. In the below figure, the green line indicates BTC supply over time.

Figure: bitcoin supply

bitcoin and blockchain: what math puzzle do miners actually solve? example with real transactions — Steemit (1)
Image credit: https://bashco.github.io/

Divisibility, portability, fungibility, scarcity, resistance to manipulation of supply and distributed authority, among others, make bitcoin a superior form of currency to government issued paper (or digital) money.

Now, how is money created in bitcoin economy? The most common answer I get is that miners are rewarded with coins they add a new block to the bitcoin blockchain by solving a math puzzle. What do we exactly mean by that math puzzle? We'll see by the end of this post. To find the answer in less technical terms, I particularly consulted these resources:

I would recommend Antonopoulos' book to anyone aspiring to learn about technical nitty gritty of bitcoin. And the following is a great video lecture series taught by Princeton professor and PhDs. It consists of 12 sessions (combined duration: 15-16 hours).

An individual will ask these two basic questions to justify a currency' value:

  1. Can I trust the money is authentic and not counterfeit?
  2. Can I be sure that no one else can claim that this money belongs to them and not
    me? (Aka the “double-spend” problem.)

In order to maintain integrity and prevent double spending, bitcoin implements consisting of:

  • A decentralized peer-to-peer network (the bitcoin protocol)
  • A public transaction ledger (the blockchain)
  • A decentralized mathematical and deterministic currency issuance (distributed
    mining)
  • A decentralized transaction verification system (transaction script)

We'll briefly discuss point 2 (blockchain) and 3 (mining) to answer our question regarding bitcoin creation.

Bitcoin overview

The below image illustrates the bitcoin peer-to-peer network and connected participants, a transaction issued and relayed by a bitcoin user with his private key and validation of that transaction by miners.

Figure: bitcoin overview

bitcoin and blockchain: what math puzzle do miners actually solve? example with real transactions — Steemit (2)
Image credit: Mastering Bitcoin

Below is an extended illustration of connected participants in bitcoin network:

Figure: The extended bitcoin network showing various node types, gateways, and
protocols

bitcoin and blockchain: what math puzzle do miners actually solve? example with real transactions — Steemit (3)

Image credit: Mastering Bitcoin

Suppose that Alice transfers 1 BTC to Bob in exchange for a high-end gaming laptop, Pete transfers 0.001 BTC for a pizza and there are many more such transactions. Currently a block consists of around 1000-2500 transaction. Now let's see how miners validate the transactions. In other words, miners check if the issuer is the rightful owner (holder of private key) of coins to associated bitcoin address. A miner verifies all such transactions and includes in a block. If the miner can add this block to existing blocks, known as the blockchain, it is rewarded for the computation it did. Miners basically:

  • collect all pending transactions
  • verifies them
  • bundles into a block
  • guess a random number (aka nonce) such that sha256(sha256(data+nonce)) less than difficulty where
    • SHA256 is the cryptographic hash function. The SHA-256 algorithm is intended to take an arbitrary amount of input data and produce 256 bits of output, whilst also maintaining certain properties that make for an effective cryptographic hash.
    • nonce is a random integer. Miners try to "guess" the nonce; only way a miner can find the number is by brute-forcing, i.e. trying millions of random numbers.
    • data is a hash over the contents of the block (transactions) and the previous block's hash
    • difficulty is a measure of how difficult it is to find a hash below a given target

The transaction created by Alice’s (or anyone else's) wallet application is 258 bytes long and contains everything necessary to confirm ownership of the funds and assign new owners. Now, the transaction must be transmitted to the bitcoin network where it will become part of the distributed ledger (the blockchain).

We now elaborate hashing in sketchy terms. As of now, the hash of latest block in the blockchain, Block #472391 is:
0000000000000000014228823553852a90563fe84da5f0a5aa4832e85f68b1b5
Note the bunch of zero's at the beginning. Simply put, miners need to choose a random number (nonce) such that the hash generated by sha256(sha256(data+nonce)) begins with a number (thirteen) of 0's. This difficulty level changes based on how much time, on average, is required to find a block. As the network combined mining capacity increases, difficulty too increases and vice versa. The below figure illustrates block formation:

bitcoin and blockchain: what math puzzle do miners actually solve? example with real transactions — Steemit (4)

Image credit: Mastering Bitcoin

We now take a look at hashes of pending transactions:

2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 -transaction 191e9240f415223982edc345532630710e94a7f52cd5f48f5ee1afc555078f0ab -transaction 287298cc2f31fba73181ea2a9e6ef10dce21ed95e98bdac9c4e1504ea16f486e4 -transaction 3... ...... ...

Now miner creates a transaction root (aka Merkle root) which essentially is hash of all transaction combined. The process is illustrated below:

bitcoin and blockchain: what math puzzle do miners actually solve? example with real transactions — Steemit (5)

Image credit: Wikipedia

Block 472391's Merkle root is:

d29b40ec75fe295493398f4675b60633a9d5a6a20e2914df9a0b353e2a742a2a

Suppose that we'd like to find the next block (Block 472392). So we take hash of Block 472391, transaction root (of all the transactions waiting to be included in Block 472392, timestamp (we'll ignore in illustration). We have (scroll right to see entire line):

0000000000000000014228823553852a90563fe84da5f0a5aa4832e85f68b1b5--e361a57a7406adee653f1dcff660d84f0ca302907747af2a387f67821acfce33

Now concatenate 1 to the above string (shortened it for the sake of readability):

00000000000000000142288--e361a57a7406adee653f1-1

Run it through SA256, and see if it meets difficulty requirement, i.e., begin with a bunch of 0's. Try 2, 3, 4, and so on until you find a number that satisfies the difficulty condition. I'm not how computers (miners) approach this random number guessing. This random number in Block 472391 is 1900492548 and was found by F2Pool.

Guessing the number 1900492548 is solving the complicated math problem

This nonce is not unique,i.e, it is possible to find more than 1 number (nonce) that satisfies difficulty condition. The block is added to the blockchain and miner is awarded with 12.5 BTC.

bitcoin and blockchain: what math puzzle do miners actually solve? example with real transactions — Steemit (2024)

FAQs

What math puzzle do miners actually solve in Bitcoin? ›

Bitcoin miners solve “math problems” using the Proof of Work consensus mechanism. The whole process involves finding a nonce, which when hashed with the SHA-256 algorithm, produces a value that meets a difficulty level set by the Bitcoin network.

What are the puzzles in Bitcoin mining? ›

As mentioned, the miners are looking for the correct nonce that would solve the puzzle. The hash puzzle described in the previous question was a specific list of characters that the machine has produced as an output, in order to solve it one needs to find an input that produces this specific output.

What equation is used to mine bitcoin? ›

A miner (this is a node engaging in validating trans- actions) packs together a block of floating, not yet validated transactions, and builds a header of this block that contains a hash of the previous block header. The hash algorithm used is SHA-256 (iterated twice), that outputs 256 bits.

What is the puzzle for blockchain? ›

This puzzle involves finding a specific number, called a nonce, that, when combined with the block's data, produces a hash value that meets certain criteria, usually a target value set by the network's difficulty level.

What kind of math does Bitcoin use? ›

The Bitcoin network utilizes integer math to prevent potential disagreements that could arise if decimal or fractional numbers were used. The use of whole numbers and their negative counterparts ensures that all computational devices can synchronize more effectively and agree on specific network changes.

What algorithm does Bitcoin solve? ›

Bitcoin miners solve a complex mathematical puzzle, called proof-of-work, to generate new bitcoins and secure the network. This puzzle is based on a cryptographic hash function called SHA-256, and the goal is to find a specific input (called a nonce) that results in a hash value that meets certain requirements.

Is Bitcoin mining just guessing? ›

It's called mining because this process also releases new coins into circulation. Put simply, crypto mining is really just guesswork with a monetary incentive—aka proof of work.

Is Bitcoin mining guessing? ›

Target Hash and Nonce

Miners are guessing a number that is lower than the target hash. The target hash is a hexadecimal number set to require an average number of attempts. Miners make these guesses by adding nonces to the information being hashed.

How do miners solve a block? ›

The miner constructs a candidate block filled with transactions. Next, the miner calculates the hash of this block's header and sees if it is smaller than the current target. If the hash is not less than the target, the miner will modify the nonce (usually just incrementing it by one) and try again.

How to earn 1 Bitcoin per day without investment? ›

Obtaining 1 BTC per day without any cost or risk is not possible. While there are various ways to obtain Bitcoin, such as through mining or trading, all of these methods come with some level of cost or risk.

Why does it take 10 minutes to mine a Bitcoin? ›

The Bitcoin network has a mechanism for ensuring that no matter how much hash rate is produced by all miners, one new block is only created on average every ten minutes.

How much power is needed to mine 1 Bitcoin a day? ›

The fact is that even the most efficient Bitcoin mining operation takes roughly 155,000 kWh to mine one Bitcoin. By way of comparison, the average US household consumes about 900 kWh per month.

What is the math behind blockchain? ›

Cryptographic hash functions are also used to secure transactions on the blockchain. These mathematical functions take an input and produce a fixed-length output unique to that input. The hash function used in Bitcoin is SHA-256, which produces a 256-bit output.

What is the mathematics of the blockchain? ›

Thus, the set of points of an elliptic curve with the sum operation also has abelian group structure. The cryptographic algorithm used in the bitcoin and the blockchain is based on the discrete logarithm for elliptic curves on finite fields, which is similar to the discrete logarithm in a finite field.

What does blockchain actually solve? ›

Beyond Cryptocurrency

Remember that this digital ledger fixes and maintains data entries using a peer-to-peer network. As a result, blockchain can address privacy concerns, eliminate discrepancies in databases, and fix other notable recordkeeping issues.

What do miners try to solve? ›

To earn this reward, the miners compete to solve a difficult mathematical problem based on a cryptographic hash algorithm. The solution to the problem, called the proof of work, is included in the new block and acts as proof that the miner expended significant computing effort.

What is a cryptographically mathematical puzzle in terms of Bitcoin? ›

A mathematical puzzle that miners must solve on proof-of-work (PoW) blockchains in order to add their block to the chain. After Ethereum switched to proof-of-stake (PoS) in 2022, Bitcoin remained the major PoW chain.

Can I mine crypto by solving puzzles? ›

Cryptocurrency mining is the process by which new units of a cryptocurrency are created and transactions are added to the blockchain. It involves solving complex mathematical problems or cryptographic puzzles that validate and secure transactions on a blockchain.

What is 32 BTC puzzle? ›

Shortly, the "32 BTC Puzzle" is not a puzzle at all but rather a bruteforce BenchMark or specific BruteForcing contest that aimed to compose fast and reliable instrument for BTC Private Keys bruteforce from one hand and to check how the BTC cryptography is secure at the moment.

Top Articles
Latest Posts
Article information

Author: Kieth Sipes

Last Updated:

Views: 5996

Rating: 4.7 / 5 (47 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Kieth Sipes

Birthday: 2001-04-14

Address: Suite 492 62479 Champlin Loop, South Catrice, MS 57271

Phone: +9663362133320

Job: District Sales Analyst

Hobby: Digital arts, Dance, Ghost hunting, Worldbuilding, Kayaking, Table tennis, 3D printing

Introduction: My name is Kieth Sipes, I am a zany, rich, courageous, powerful, faithful, jolly, excited person who loves writing and wants to share my knowledge and understanding with you.