Bitcoin is at once a technology and a currency. It is a decentralized ledger - otherwise known as a blockchain - which details every transaction ever made in its native token, bitcoin. What is truly remarkable about the blockchain is that it is not stored or maintained by any central entity, but rather is amended and distributed autonomously, and the transactions within are irreversibly recorded, universally recognized as being legitimate. In an internet increasingly vulnerable to hacking attacks and theft, how can such a system be so confident in its security and accuracy?
Bitcoin technology is based on cryptography, or the art of hiding secrets in plain view. How bitcoin utilizes cryptography is most evident in two different processes: bitcoin transactions, and the settling of these transactions within the ledger. Both processes depend on a cryptographic mechanism known as the hash function.
OK, here comes the trickiest paragraph, so pay close attention. A cryptographic hash function is a process by which a large amount of information is converted through a mathematical algorithm into a small, fixed output. While fixed initial information, when hashed, will always result in the same output, it is mathematically impossible to travel the other way - the input information cannot be determined from the output. Moreover, any change to the input, no matter how small, will result in an output bearing no resemblance to the previous output. At the same time the output is connected to its input through this algorithmic link.
As it pertains to bitcoin, this output is known as a public key, a.k.a. bitcoin address, and the input provides the permission to make a transaction. The input, otherwise known as a private key, is provides a digital signature, which tells its algorithmically-connected public key to broadcast the desired transaction to the network. This network consists of thousands of relay points known as nodes - who can be anyone with broadband internet and about 20 gb of memory to spare - who snatch up newly broadcast transactions and stick them into a block filled with all other unfiled transactions.
These transactions are settled onto the blockchain through a special process known as bitcoin mining. Mining, in this context, refers to the application of a cryptographic hash function to the unfiled block, converting all the information within into that small, fixed output, which is then recorded on the blockchain. While a hash function can usually be done in a millisecond, the bitcoin protocol introduces a level of difficulty into the processvwhich is known as proof of work. Proof of work requires that a successful output of the hash function - i.e. one that is amended to the end of the blockchain - start with a certain number of zeros. And, as mentioned above, it is impossible to determine the output of a variable input ahead of time. This means that miners must run the hash function, over and over again, each time changing slightly a variable input known as a “nonce”, until by happy accident the output starts with this predefined number of zeros. When a miner finally is successful, they broadcast the solution to the network, together with the nonce and all the transactions, it is verified as accurate and appended to the blockchain. The miner is then rewarded with bitcoin into his wallet, and the process starts all over again.
Proof of work
Proof of work is necessary for two reasons. First, newly-minted Bitcoin are meant to be introduced slowly into the network over the course of the next 125 years, until production stops at 21 million bitcoin. This requires that mining rewards are distributed every 10 minutes. To maintain this schedule in the face of increasing mining power, the bitcoin network must increase proof of work difficulty.
It is this mechanism that also serves to secure the network. The greatest threat to the bitcoin network is a so-called 51% attack, in which a single miner or evil group gains a majority of mining power and uses it either to disrupt the network or to process their own double spending of the same coin. However, the mining network, as foreseen, has grown massively and in distributed fashion. It would be extremely difficult - more so each day - for an evil group or government to compromise the blockchain.