Micky C, on 28 January 2018 - 05:01 PM, said:
I could be wrong, but I'm vaguely of the impression that the ledger is protected by some kind of encryption, and that the mining process is calculating new encryptions to make the ledger larger so more people can use it. As a result of making it larger, you're rewarded by you owning the coins taking the new space.
No. The ledger is public information, and is hence entirely unencrypted. It is actually a common misconception that Bitcoin provides strong privacy in this sense, as in reality, performing a transaction using Bitcoin is no more privacy conserving than posting a message using a nickname on an internet forum. In fact, it actually guarantees authentication, verifying that a certain participant behind a pseudonym actually committed himself to a given transaction.
The reason it is however still used on shady blackmarket websites is because it is the only viable alternative to centralised bank payments, where you can be tracked immediately without effort, as it is associated with your real name and identity. In Bitcoin, you are at least behind an address acting as a pseudonym, but against sophisticated network traffic analysis, that doesn't stand a chance, which is how sites like Silk Road eventually got busted.
But I'm getting ahead of myself here. I'm going to try and explain how the blockchain network in Bitcoin works, by starting with a prominent problem in decentralised algorithms. If nothing else, it's at least good practice for my exam on the subject next week, heh.
Anyways, as MusicallyInspired already mentioned, Bitcoin, and its many, many alternatives, such as Ethereum, is a decentralised distributed algorithm intended to allow transactions between different participants without the requirement of a central authority overseeing the transaction.
Now first of all, the core problem of a decentralised distributed algorithm like Bitcoin, which aims to establish state replication, is that different parties in the network may see messages in a different order than their neighbors do. State replication in relation to a currency means that every participant in the network needs to be able to agree with every other correct (i.e. not malicious) participant that a certain set of transactions X happened in a specific order Y, where every participant has a specific account balance Z. If this cannot be guaranteed, then it becomes possible for an actor in the network to, for example, spend the same money twice on different parties in the network (double spending attack), and have different, non-malicious parties disagree about what your account balance actually is.
There are algorithms that solve this problem deterministically or probabilistically, by using multiple rounds of communication, which do not rely on the methods used by blockchain technologies. However the big issue with these protocols is that they're either too slow, not scalable or not resilient enough to attacks. They work in theory, but not are not good enough in practice. And this is one of the reasons why Bitcoin even took off as much as it did -- it's a solution that actually works in practice. (but paradoxically shouldn't work in theory, but that goes too much into detail)
The idea of Cryptocurrencies is that, in order for the network to be able to agree on a specific order of transactions, the intervals in which the transactions are confirmed needs to be big enough so that the messages containing the transactions can actually propagate through the network and reach a majority of the participants before a second one can be confirmed. Whenever a participant in the network wants to start a transaction, he/she will broadcast a message containing all necessary information (such as sender, recipient and amount of money to be transferred, as well as other details) in the form of a transaction, which will then be accepted and stored by the miners.
The miners themselves are attempting to generate new "blocks", which are the essential components that the ledger is actually made out of. The ledger itself namely is simply a massive, enormous chain of blocks, where all transactions since the beginning of the protocol are recorded, spanning from the very first genesis transaction all the way to today. Hence the term:
blockchain. This ledger is stored by each node independently, and on this ledger, they now attempt to achieve state replication.
A block itself contains the following components:
- A pointer to the previous block.
- A number of transactions.
- The answer to the Proof-of-Work challenge.
In order for a transaction to be confirmed, it needs to be valid (have correct signatures, etc.), needs to be included in a block and said block needs to be part of the longest chain in the ledger. The miner only gets paid if he manages to append the block to the longest chain, and while it is possible for a miner to append a block he found to any point in the chain, he will only profit from it if it's part of the longest chain. Forks may occur by chance if two miners find a block for the same predecessor; however, eventually, one of the forks of the chain will emerge dominant.
We now come to the proof of work challenge. In order for a block to be accepted and considered valid, it needs to have a correct answer for the challenge. The process of finding this answer is computationally expensive, which is the reason people are buying GPUs and FPGAs in droves, as they want to find the answers as quickly as possible. And if the miner does find the answer, and manages to append his block to the longest chain, he will be rewarded for his efforts by being able to "mint" new coins. This is the process of mining.
The challenge itself is a mathematical formula. It differs from cryptocurrency to cryptocurrency, and others do not even make use of the same system, as I mentioned in my previous post. However, in the case of Bitcoin, it is set up so that each miner has his own unique challenge, which is also unique for the block he's mining it for, and there is no better strategy for solving it other than trying out random numbers. This gives each miner equal chances of finding an answer, depending on their computing power of course. The challenge in detail is a string of numbers, consisting of preset values + the random, guessed string of the miner, which is then hashed twice using SHA256, whose result is required to be smaller than a given number, set by the protocol, in order to be a valid answer.
Why all this effort, just to compute meaningless numbers? Well the reason is simple: The challenge is fine-tuned so that globally, throughout the entire network, it takes on average about 10 minutes for a new block to be found. This gives us enough time to allow transactions to be collected by the miners, which are then included in the blocks, to then be further propagated and accepted in the network. This way, every participant receives a consistent view of the network, and state replication is achieved. And that's it.
Mark., on 28 January 2018 - 07:46 AM, said:
Then what is the point of mining if everyone is synced. Does it really pay well for every transaction you find and share with the rest? And how do you get paid. Does your payment come out of every single member's account? I assume there is a safeguard against people mining and verifying their own purchases.
There are safeguards in place. One of these safeguards are digital signatures.
Essentially, each participant has a private and a public key, the former is used for signing a message, while the latter is used for verifying it. Signing is in this sense essentially a special form of encryption -- the private key encrypts, the public key decrypts, however, the name implies, the private key is secret, while the public key is... well, public.
Hence whatever you encrypt with your private key isn't actually confidential -- anyone can decrypt it! But, what it does guarantee is that nobody can forge your message. Nobody knows your private key, hence they cannot encrypt a message with it, which proves to anyone that, if a message is encrypted with your private key, then you really did send that message. And hereby, the public key acts as your address.
In terms of transactions, this means that nobody can spend anyone else's money as long as their private key remains secret, as each transaction needs to be signed by the party that is spending the money.
Further safeguards are syntactic correctness checks, compliance with the specification, timelocks (essentially time until a transaction can be included in a block) and the proof of work challenge, of course.
How does a miner get paid when he finds a block and appends it to the longest chain? There are two ways:
- The first way is the primary method used. The protocol dictates that the miner is allowed to include an extra transaction in every valid block he mined, which transfers a certain number of coins from an "empty" dummy source to his own account. The amount of coins is hereby dictated by the protocol specification, lowers over time, and should be at around 10 bitcoins at the moment. These coins are newly generated, and do not stem from any pre-existing address.
- The second way is through using transaction fees. A miner may require a participant sending a transaction to leave a certain percentage of the spendable money they have to the miner as a transaction fee. Transactions that do not meet the necessary fee percentage are ignored by certain miners. Then, once the block is in the longest chain, these fees go directly into the miner's address as a separate transaction and become spendable to them. These coins stem from actual participants in the network.
Considering this, it is simple to see why a miner has an incentive to continue searching for new answers to the challenge. They are what keeps the network going, and in exchange they get to profit from it. The downside, as we all notice, is that greed can go too far, and now the driving force of Bitcoin has become a menace on those who intend to buy GPUs for casual use. It is also extremely costly in terms of power, which can have big consequences for the environment, and of course , the immense greed also leads to actively malicious practises like bitcoin miner programs in javascript advertisements.
I got this information from a number of courses at the university I'm studying at, as well as reading some of the associated papers of the currencies. Parts are probably slightly inaccurate and simplified, but I hope this cleared things up a bit.