Historically, cryptography was an ancient art for sending hidden messages. (The term comes from the Greek word krypto logos, which means secret writing.) The sender encrypted the message by using some sort of key. The receiver then had to decrypt it. For example, 19th-century scholars decrypted ancient Egyptian hieroglyphics when Napoleon’s soldiers found the Rosetta Stone in 1799 near Rosetta, Egypt. In the 21st-century era of information networks, the sender can digitally encrypt messages, and the receiver can use cryptographic services and algorithms to decrypt them.
What does Napoleon have to do with cryptocurrencies? Cryptocurrencies use cryptography to maintain security and anonymity. That’s how digital coins, even though they’re not monetized by any central authority or regulatory body, can help with security and protection from double-spending, which is the risk of your digital cash being used more than once.
Cryptography uses three main encryption methods.
Hashing: Hashing is something like a fingerprint or signature. A hash function first takes your input data (which can be of any size). The function then performs an operation on the original data and returns an output that represents the original data but has a fixed (and generally smaller) size. In cryptocurrencies such as Bitcoin, it’s used to guess the combination of the lock of a block. Hashing maintains the structure of blockchain data, encodes people’s account addresses, and makes block mining possible. You can find more on mining later in this chapter, and in much more detail in Book 6.
Symmetric encryption cryptography: Symmetric encryption is the simplest method used in cryptography. It involves only one secret key for both the sender and the receiver. The main disadvantage of symmetric encryption is that all parties involved have to exchange the key used to encrypt the data before they can decrypt it.
Asymmetric encryption cryptography: Asymmetric encryption uses two keys — a public key and a private key. You can encrypt a message by using the receiver’s public key, but the receiver can decrypt it only with their private key.
Nodes
A node is an electronic device that does the bookkeeping job in the blockchain network, making the whole decentralized thing possible. The device can be a computer, a cellphone, or even a printer, as long as it’s connected to the Internet and has access to the blockchain network.
Mining
As the owners of nodes (see the preceding section) willingly contribute their computing resources to store and validate transactions, they have the chance to collect the transaction fees and earn a reward in the underlying cryptocurrency for doing so. This process is known as mining, and the owners who do it are miners.
Let me make something clear: Not all cryptocurrencies can be mined. Bitcoin and some other famous ones can. Others, such as Ripple (XRP), avoid mining altogether because they want a platform that doesn’t consume a huge amount of electricity in the process of mining; power usage is one of the issues with blockchain that are discussed in Book 6, Chapters 7 and 8. Regardless, for the most part, mining remains a huge part of many cryptocurrencies to date.
Here’s how mining works: Cryptocurrency miners solve cryptographic puzzles (via software) to add transactions to the ledger (the blockchain) in the hope of getting coins as a reward. It’s called mining because of the fact that this process helps extract new cryptocurrencies from the system. Anyone, including you, can join this group. Your computer needs to “guess” a random number that solves an equation that the blockchain system generates. In fact, your computer has to calculate many 64-character strings or 256-bit hashes and check with the challenge equation to see whether the answer is right. That’s why it’s so important that you have a powerful computer. The more powerful your computer is, the more guesses it can make in a second, increasing your chances of winning this game. If you manage to guess right, you earn Bitcoins and you get to write the “next page” of Bitcoin transactions on the blockchain. Head to Book 6 if you’re interested to learn more.
Because mining is based on a form of guessing, for each block, a different miner guesses the number and is granted the right to update the blockchain. Whoever has the biggest computing power combined, controlling 51 percent of the votes, controls the chain and wins every time. Thanks to the law of statistical probability, the same miner is unlikely to succeed every time. On the other hand, this game can sometimes be unfair because the biggest computer power will be the first to solve the challenge equation and “win” more often.
Proof of work
If you’re a miner and want to actually enter your block and transactions into the blockchain, you have to provide an answer (proof) to a specific challenge. This proof is difficult to produce (hence all the gigantic computers, time, and money needed for it), but others can very easily verify it. This process is known as proof of work, or PoW.
For example, guessing a combination to a lock is a proof to a challenge. Going through all the different possible combinations to come up with the right answer may be pretty hard, but after you get it, it’s easy to validate — just enter the combination and see whether the lock opens! The first miner who solves the problem for each block on the blockchain gets a reward. The reward is basically the incentive to keep on mining, and it motivates the miners to compete to be the first one to find a solution for mathematical problems. Bitcoin and some other mineable cryptocurrencies mainly use the PoW concept to make sure that the network isn’t easily manipulated.
This whole proof-of-work concept has some downsides for blockchain technology. One of the main challenges is that it wastes a lot of computing power and electricity just for the sake of producing random guesses. That’s why new cryptocurrencies have jumped on an alternative wagon called proof of stake (PoS), covered in the next section.
Proof of stake
Unlike PoW, a proof-of-stake (PoS) system requires you to show ownership of a certain amount of money (or stake). That means the more crypto you own, the more mining power you have. This approach eliminates the need for the expensive mining extravaganza. And because the calculations are pretty simple to prove, you own a certain percentage of the total amount of the cryptos available.
Another difference is that the PoS system offers no block rewards, so the miners get transaction fees. That’s how PoS cryptos can be several thousand times more cost-effective than PoW ones. (Don’t let the PoS abbreviation give you the wrong idea.)
But of course, PoS also has its own problems. For starters, you can argue that PoS rewards coin hoarders. Under the proof-of-stake model, nodes can mine only a percentage of transactions that corresponds to their stake in a cryptocurrency. For example, a proof-of-stake miner who owns 10 percent of a cryptocurrency would be able to mine 10 percent of blocks on the network. The limitation with this consensus model is that it gives nodes on the network a reason to save their coins instead of spending them. It also produces a scenario in which the rich get richer because large coin holders are able to mine a larger percentage of blocks on the network.Proof of importance
Proof