Sharing technical posts, make money online, ...

Friday, July 27, 2018

How Does the Blockchain Work? - Part 1

In simplest terms, blockchain uses a combination of cryptography and a public ledger to create trust between parties while maintaining privacy             

Understanding the mechanics of how this works is a little bit more difficult, but in order to fully appreciate the genius behind blockchain technology we’ll need to dive into the technical details.

While blockchains can include many more features, the fundamentals of a blockchain are in the technology’s name:

●    The block - A block is a list of transactions from a certain time period. It contains all the information processed on the network within the past few minutes.
●    The chain - Each block is timestamped, placed in chronological order, and linked to the block before it using cryptographic algorithms. These algorithms are difficult for computers to calculate and often take several minutes for the fastest computers in the world to solve. Once solved, the cryptographic chain locks the block into place, making it difficult to change. (We’ll look at this in greater depth in just a minute).

The chain grows longer over time. Once a new block is created, the computers on the network work together to verify the transactions in the block and secure that block’s place in the chain.

In this chapter, we’ll take a look at what’s inside of a block and how one gets created. We’ll then turn to the chain and examine the different ways today’s blockchains are secured. We’ll try to avoid computer code and complicated explanations. The important thing here is getting a basic understanding of how the parts of a blockchain work together.

Distributed Ledgers

The most fundamental part of the blockchain is the ledger. It’s where information about the accounts on the network is stored. The ledger inside the blockchain is what replaces the ledger at a bank or other institution. For a cryptocurrency, this ledger usually consists of account numbers, transactions, and balances. When you submit a transaction to the blockchain, you’re adding information to the ledger about where currency is coming from and going to.

As we’ve already seen, a blockchain ledger is distributed across the network. Every node on the network keeps its own copy of the ledger and updates it when someone submits a new transaction. This “distributed ledger” is how blockchain intends to replace banks and other institutions. Instead of having the bank keep one official copy of the ledger, we’ll have everyone keep their own copy of the ledger and then we’ll verify transactions by consensus.

Each blockchain technology has its own ledger, and the various ledgers work very differently (as we’ll see). However the Bitcoin ledger, the first blockchain ledger, requires three pieces of information to list a transaction:

●    An input - If Amy wants to send Ben a Bitcoin, she needs to tell the network where she got that Bitcoin in the first place. Maybe Amy received the Bitcoin yesterday from Sarah, so the first part of the ledger entry says so
●    An amount - This is how much Amy wants to send to Ben;
●    An output - This is Ben’s Bitcoin address where the Bitcoin should be deposited

Now comes a difficult-to-grasp concept: there is no such thing as a Bitcoin. Of course, there are no physical Bitcoins. You probably already knew that. However, there are also no Bitcoins on a hard drive somewhere.

You can’t point to a physical object, digital file, or piece of code and say, “this is a Bitcoin.” Instead, the entire Bitcoin network is only a series of transaction records. Every transaction in the history of Bitcoin lives in the Bitcoin blockchain’s distributed ledger. If you want to prove that you have 20 Bitcoins, the only way you can do it is by pointing to the transactions where you received those 20 Bitcoins.

Almost all blockchains have this characteristic in common. The transaction history is the currency, there’s no difference between the two. Some new cryptocurrencies are altering the way the ledger is written in order to provide greater anonymity and privacy in transactions. They use certain identity masking techniques to hide the sender and receiver of the transaction while still maintaining a functional distributed ledger. (We’ll look at this in greater depth in the chapters on Dash, Zcash, and Monero.)

The “Double Spend” Problem

Of course, since there is no such thing as a physical cryptocurrency or even a digital file you can point to, we run into a few technical challenges implementing a digital currency. The biggest of these challenges is the double spend problem, where an attacker could send you a token and then send someone else the same token a moment later. Double spend means that tokens could be spent multiple times, increasing inflation and devaluing the cryptocurrency.

When you send a transaction on the Bitcoin blockchain, for instance, you’re merely forwarding a transaction you received from someone else. The double spend problem comes when an attacker tries to send a transaction twice, so it works like this:

✓ The attacker receives Bitcoin from Alice
✓ The attacker’s wallet looks like this: [Alice -> 1BTC -> Attacker] & [Bob -> 1 BTC -> Attacker]
✓ The attacker then spends the money by forwarding a past transaction. For instance, [Alice > Attacker > You]
✓ The double spend problem comes when the attacker simultaneously spends the coin twice. For example: [Alice > Attacker > You, 1 BTC] AND [Alice > Attacker > Someone Else, 1 BTC] right after each other.

When you use a bank, the bank would catch this error and invalidate one of the transactions. However, Bitcoin doesn’t have a central authority. Instead, Bitcoin uses cryptography to make it statistically very difficult to create false transactions.

​First, the attacker could not double spend at the same instant. If he sent two conflicting transactions at the same time, everyone on the network would be able to see both those transactions in the same block. The network would invalidate one.

​The attacker could try double spending one right after the other. However, the network would also reject a transaction that references an already-spent coin.

​The attacker’s only chance is to convince part of the network to accept one of his transactions and convince the other part of the network to accept the other transaction. This splits the network into two streams, called “forks.” Multiple forks of the blockchain can exist on Bitcoin.

The creators of Bitcoin solved this forking challenge, and double spend problem, by making the link between blocks difficult to compute. Since it takes so long to cryptographically create and validate a new block, it’s unlikely two blocks will be created at the same time. Even if two blocks are created simultaneously, the Bitcoin protocol directs participants in the network to follow the longest chain. As soon as a new block is created the network will revert back to a single version of the ledger.

Since multiple forks are theoretically possible, it’s wise to wait for multiple blocks to go by before considering a transaction “confirmed.” Once confirmed, however, that transaction is immutable. It’s nearly impossible to create a fraudulent blockchain fast enough to replace the honest blockchain. Let’s dive into how it works.

The Ultimate Beginner’s Guide about Blockchain Wallet, Mining, Bitcoin, Ethereum, Litecoin, Zcash, Monero, Ripple, Dash, IOTA and Smart Contracts

By Alan T. Norman

No comments:

Post a Comment