What is Bitcoin mining, and why is it necessary? – Coin Center
why does bitcoin have “miners?”
gold has miners because people want gold and unfortunately it happens that most of the gold is found deep in the earth. bitcoin has miners because people want bitcoins, but something here seems silly: how did a bunch of bitcoins, the tokens of a man-made invention, end up locked away in circumstances that demanded mining? what’s the point of that?
not the best name
The truth is that bitcoin “mining” is a misnomer. when gold is mined, nothing is accomplished beyond the discovery of new gold. however, when bitcoins are mined, a valuable service is provided to the bitcoin network: decentralized transaction registration and validation.
Reading: Bitcoin mining provide crucial demand for
Bitcoin relies on miners to record and validate transactions due to a particular problem inherent in any digital currency system: double spending. double spending is the high-tech embodiment of counterfeiting. Let’s say, for example, that a money user, Alice, has a $5 bill and gives it to Bob. Can Bob be sure that he received $5 instead of a counterfeit? in the physical world, probably. in the digital world, probably not.
In the physical world, Alice would have to find paper, ink, and machines capable of making a convincing duplicate of her $5. the cost of that activity, along with moral qualms and the threat of arrest, keeps counterfeiting at bay.
In the digital world, however, a computer file version of a $5 bill, such as an mp3 file or an ms word document, can be perfectly copied at no cost. there is no way of knowing which file is the original, and the ease of copying means that counterfeit currency could quickly invade the economy.
To get around this, the inventors of bitcoin designed a system of network interactions, a protocol, that compares each purported transfer of bitcoin to a public ledger called the blockchain. a thief can try to resend already spent bitcoins until they are blue in the face; however, if those transactions are not verified, the miners will not record them and the community will ignore the attempted fraud.
how does mining work?
Bitcoin miners connect to the bitcoin network like telephone operators. miners use their computers to listen for transaction requests across the network and build a list of valid transactions.
Bitcoins are not sent or received as an email attachment. there are no files at all, just bitcoin allocations made to various public addresses. each public address has a matching private key, and only the holder of that key can digitally sign a new transaction request. additionally, the request must have inputs. the entries are the previous transactions that the sender is using to fund the new transaction. if you previously received five bitcoins from alice and four from bob, you can list these entries to fund a new transaction to cynthia of up to nine bitcoins in value.
miners check two things when they listen to your request. they first check to make sure your digital signature proves that you were actually the recipient of those entries. Second, they check to make sure you haven’t spent those supplies. To perform this second verification, miners query a public database of all valid past transactions, called the blockchain, to see if those entries have already been used in a transaction or are still available. copies of this chain of blocks are stored on the computers of all bitcoin users who connect to the network.
So, miners play the role of bank tellers: they inspect checks, ensure all proper signatures and account numbers are present, verify customer identification, and look for evidence that the customer has enough cash on hand to finance the transaction.
complete a “block”
If all goes well, the miner will add the transaction to his personal list of all valid transactions in the last few minutes. every few minutes, a miner will be selected to add their personal list, a block, to the official blockchain, thus keeping the public record up to date.
See also: This Longtime Crypto Investor Lost 20K in the Celsius Collapse. Here&039s His Advice on Managing Risk | NextAdvisor with TIME
To prevent miners from fraudulently corrupting the blockchain, the bitcoin protocol makes miners compete. a different miner is empowered to write each block, approximately every 10 minutes, and the rest of the mining community will only accept valid blocks. this is how it works:
guess and check the nonce
a miner’s block will become part of the chain as long as a majority of the mining community agrees (a) that the transactions listed by the miner are valid, with no copycat signatures and no double spending, and (b ) that the miner correctly guessed a special number, the nonce, that solves a particular mathematical problem. miners perform this verification by looking at the particular digital signature of the proposed block. this signature is a computer-generated product of three inputs, (1) the signature of the predecessor block, (2) a list of valid transactions since that predecessor, and (3) a particular random number, called a nonce.
To understand it all, we need a little more information about digital signatures. signatures operate through the use of “hash” functions. In their simplest form, hash functions are mathematical equations that take any given input and create a seemingly random output that will always correspond to that particular input.
the hash function used by bitcoin is called sha256. using that function, the input text:
“this is hashish!”
will always output this string:
You can test it yourself by visiting an online hash calculator; if you write “this is a hash!” without the quotes you will get the same specific string of numbers and letters.
If a hash function is well written, any change to the inputs will drastically change the output string, and different inputs will never produce the same string. by that standard, sha256 is very well written. for example, by changing our input “this is a hash!” even slightly results in completely different results:
“this is hashish!” = “dcc67309a9c5c4a6d5434de87dbd4162f745f32b2a6aedf89c89d31d863b022b”
“Is this hashish?” = “d43edbde4b15a97e780c1a9e1392b2c4601750fe03db543b3c4c44624d277641”
See also: Bitcoin Evolution Review: Is This App Good for Using? Key Australia Facts Checked!
“this is a hash brown”. = “5692e888b50c526f7eb95342a6fd56760b2ff95a766414562daa4083bab8bcfc”
so if the inputs to a new block signature are the previous block signature and a list of recent transactions, the output will be a unique string that could only have been created from that exact data. because it is the unique product of those inputs, that signature can be used to prove that the transactions described therein occurred in a given order: within the current block or some previous block. try to change the order by inventing false past blocks and the signature will no longer match. this allows the particular beneficiary of a transfer to prove that he was the first to receive the coins; any subsequent double spending of those coins is fraud.
all miners, however, are able to write a signature composed of the old block signature and the new transaction list very quickly using their powerful computers. how do we choose a winner at regular intervals to compete? the solution is to request a string that will be difficult to generate quickly, a specific type of output string, one that starts with a certain number of zeros, like this:
that long line of zeros at the beginning of the hash is statistically improbable, like flipping a coin and getting heads thirteen times in a row. however, there is a particular combination of inputs that will result in a hash output that starts with all of those zeroes. the combination will involve a particular random number called a “nonce” that the miners will have to guess.
miners repeatedly parse their two known inputs (the previous block signature and the list of new transactions), along with guesses at the random nonce. eventually, a miner will find a nonce that will give it a signature with the requested number of leading zeros.
miners using more powerful computers can guess faster and, like buying more lottery tickets, these miners are more likely to win the race to find a particular hash. that is why miners can compete with each other by investing in more powerful computers. more hash attempts equals more blocks written to the blockchain over time. To prevent blocks from being written too fast or too slow as miners use more or less computing power, the protocol adjusts every two weeks to require a longer and harder-to-guess string of zeros, or a shorter and more difficult-to-guess string of zeros. easier to guess. against hashish. the goal of these settings is to generate a new block every ten minutes.
Whenever a miner solves a block by writing a signature with enough zeros, it broadcasts it and the other miners validate the solution and verify that all listed transactions are valid. if all goes well, the miners will start racing to solve a new block using the signature of the last block as input.
That brings us, finally, to the question of why miners mine. this answer is really simple, miners mine because the writer of a new block on the blockchain is allowed by the protocol to give themselves a reward of new bitcoins, called a coin base transaction. that reward started at 50 bitcoins per block. every four years the protocol is adjusted, reducing the reward by half. someday the reward will be very small, but miners can also be rewarded by collecting fees volunteered by users requesting transactions.
We have discussed why mining is necessary: to stop double spending by creating a ledger of all transactions, the blockchain. we have also learned, in simplified terms, how mining actually works. In the future, we will discuss what happens when miners collaborate to mine blocks, form mining pools, and discuss the cryptography involved more fully.
peter van valkenburgh is director of research at coin center.
See also: Units & Symbols | Bitcoin Design