0%

What is a Blockchain and How Does It Work? 

Nov 4, 2022 11 min read

Nakamoto developed the Bitcoin cryptocurrency and blockchain to overcome perceived limitations with centralized currencies and banking systems. To fulfill Nakamoto’s vision, Bitcoin required a data store that was:

  • Decentralized: No trusted authority oversees accounts and transactions.

  • Distributed: The entire ledger is shared with a peer-to-peer network of many independent nodes. There is no central bookkeeper.

  • Ordered: Transactions are stored in an immutable ordered series.

  • Capable of achieving consensus: Every network node must eventually agree on the content and order of transactions.

Blockchains are the solution. A blockchain is a ledger made up of blocks of data, each consisting of multiple records containing information about a transaction. The blocks are linked together using cryptographic technologies (as described below). New transactions are appended by adding blocks to the end of the chain. In normal use, blocks cannot be removed or altered, so blockchains are immutable.

In this article, we’ll explore how blockchains fulfill the needs of cryptocurrencies like Bitcoin and Ethereum , as well as many other applications. Read on to learn the role blockchains play in distributed peer-to-peer networks and how cryptography makes blockchains possible.

Blockchain Peer-to-Peer Networks

Traditional databases—including those that support banks and exchanges—depend on a single entity to manage the database and guarantee the validity of the information it contains. Another way of putting this is that traditional databases use a client-server model; many clients receive data from a single server.

Blockchains, in contrast, use a peer-to-peer model that requires no central authority. The blockchain is distributed across a network of peers, each of which will (eventually) have a complete copy. Each peer runs software built to manage a specific blockchain. That software has many responsibilities, but some of the most critical are:

  • Connecting and communicating with other peers in the network.

  • Downloading and storing a copy of the blockchain ledger.

  • Creating, listening for, validating, and storing transactions.

  • Sending transactions to other nodes.

  • Downloading, validating, and creating new blocks.

Peer-to-peer networks were not a new invention. BitTorrent uses peer-to-peer networks, as do many other earlier technologies. But cryptocurrencies have unique requirements: the ledger must be immutable and strictly ordered. It must be so secure only the owner of a digital asset can transact with that asset. Double-spending must be impossible, which is not straightforward on peer-to-peer networks with inherent latencies.

Two technologies enable blockchains to fulfill these requirements without a central authority: cryptography and a consensus mechanism.

Blockchain Security and Cryptography

As the name “cryptocurrency” suggests, cryptography is key to how blockchains work. It is how they can act as decentralized, distributed ledgers. At its most basic, cryptography is the process of taking a message—the plaintext—and transforming it with an algorithm known as the cipher into an unreadable form—the ciphertext. The process is reversible, so we can retrieve the plaintext if we have the ciphertext.

In the simplest cryptographic algorithms ( ROT 13, for example), the sender and receiver only need to know the cipher to encrypt and decrypt a message. Clearly, that’s insufficiently secure—once the algorithm is known, anyone can decrypt any encrypted message.

Symmetric cryptography adds another component: a secret key. The cryptographic algorithm uses the plaintext and the key to produce the ciphertext. To decrypt, the recipient needs to know the algorithm and the secret key, which can be changed with each message. The technique is called symmetric encryption because we use the same key to encrypt and decrypt the message.

But if you want a decentralized and distributed ledger, a symmetric key proves an unwelcome limitation. As a shared secret, the key must be known to all participants in a transaction. But how do we share it securely and privately so others can’t use it to make fraudulent transactions? Symmetric cryptography can’t be the foundational cryptographic technology used in blockchains.

For that, we turn to asymmetric cryptography. Asymmetric cryptography uses different keys to encrypt and decrypt the message—the key used to encrypt the message is not the same as the key used to decrypt it. The most widely used form of asymmetric cryptography is public key cryptography, which is the foundation of blockchain security and privacy.

Public Key Cryptography

Public key cryptography relies on a pair of keys that are mathematically linked. The first is the private key, which is kept secret. The second is the public key, which is shared openly. The important quality of key pairs is this: only the private key can decrypt messages encrypted with the public key. If you wanted to send a secret message to someone, you could encrypt it with their public key, and it could only be decrypted with the matching private key.  Their ability to decrypt the message also proves that they are in possession of the private key.

The main benefit of public key cryptography is the lack of shared secrets. Provided the private key stays private, anyone can send messages only the private key holder can read.

What does this have to do with blockchains? Blockchain addresses—which have the same function as an account in traditional banking—are derived from public keys. To send Bitcoin, for example, you use a Bitcoin address derived from the recipient’s public key. Once sent, the coins are associated with the recipient’s address, but any future transaction must be authorized by their private key to be valid. They “own” the coins, but can only use them if they know the associated private key. In this way, cryptocurrency users can securely transact despite no shared secret.

Cryptographic Hashes

A cryptographic hash function is an algorithm that consumes input data and outputs a hash, a very large number. The input data and the hash are related in interesting ways:

  • The same input data always produces the same hash.

  • A small change in the input data results in a large change in the hash.

  • The hash is, practically speaking, unique. The chances of two different inputs creating the same output—a hash collision—are extremely small.

  • Hashes are computationally straightforward to generate.

Hashes are widely used in blockchains. It is hashes that tie the blocks in a blockchain together. Every new block includes a hash of the previous block, known as the parent block. The parent block includes a hash of its parent, which becomes part of the input data for the hash in the subsequent block, and so on back to the first block.

Remember, a small change in the input data means a large change in the hash. An illegitimate change at any point along the chain would cause a mismatch. This system is one of the reasons it’s so hard to tamper with the blockchain. New blocks can be added, but old blocks cannot be edited without recomputing the hashes for all subsequent blocks—a prohibitively expensive operation. Hashes are also used in mining, as we’ll explain below.

Digital Signatures

On the blockchain, a digital signature performs a similar function to a pen-and-ink signature on a contract. It verifies the authenticity of a transaction or agreement. But what is a digital signature?

If you recall, public keys encrypt data only the private key can decrypt. It works the other way around with a digital signature. The private key and the data (or a hash of the data) are combined and passed through an encryption algorithm that generates a unique output. The signature can then be verified with the associated public key.

The signer uses the data and their private key to generate a signature. Interested parties use the data, the digital signature, and the signer’s public key to verify the signature is genuine.

One advantage of digital signatures is that they are harder to forge than the pen-and-ink variety. When you sign a message digitally, the message is part of the input. If the message changes, the signature is no longer valid. Consequently, digital signatures verify that the private key holder signed a message and its contents are the same as when it was signed.

Blockchain networks use digital signatures to authenticate transactions. As we described in the section on public key cryptography, cryptocurrency transactions send coins to an address derived from a public key. To use the coins, the owner must prove that they own them. She signs the transaction with her private key, and blockchain nodes use the associated public key to verify that the transaction is legitimate.

Blockchain Consensus

How do the nodes in a peer-to-peer network agree which blocks to add to the blockchain and their order? A large blockchain network may have tens of thousands of nodes distributed worldwide, any of which could create and distribute new blocks.

The blocks themselves are part of the answer. If individual transactions were immediately added to the ledger, keeping everything synchronized and in order would be difficult. Instead, blockchain nodes gather many transactions together into a block. Blocks are added to the blockchain only after a pre-determined time has elapsed since the last block was added, giving time for the blockchain data to propagate.

That explanation may inspire additional questions. How are nodes made to wait for a predetermined time, and how is a block selected as the block to be added?

How Are New Blocks Added to a Blockchain?

Each blockchain has its own method for building, propagating, and selecting blocks, but there are two main methods for choosing which blocks are added:

  • Proof of Work, which is used by Bitcoin, Pre-Merge Ethereum, and many other cryptocurrencies.

  • Proof of Stake, which is used by Post-Merge Ethereum and other cryptocurrencies created in more recent years.

Proof of Work Explained

In a proof of work blockchain, a block-building node must prove that it has carried out a certain amount of computational work before it is allowed to add a block that other nodes will recognize as valid. The difficulty of the work is typically calibrated to take a certain amount of time—about ten minutes on the Bitcoin blockchain.

In the case of Bitcoin, a node gathers new transactions into a block. It then generates a cryptographic hash of the block’s header—a long number. That number must be lower than a target number. If it is higher, the node regenerates the block with a small change to a data field called the nonce. It then generates another cryptographic hash and checks to see if it is smaller than the target. It does this many millions of times until it finds a nonce, resulting in a hash smaller than the target number. This repeated guessing is mining.

Mining requires considerable computational power, and there is no way to cheat. But once a viable nonce is found, it is easy to verify. When the miner finds a solution, it distributes the block to other nodes, which verify the solution, add the block to their version of the blockchain, and distribute it. As a rule, the longest valid blockchain—the one that represents the most computational work—is considered the authentic version, so other nodes will accept the new longest chain as canonical.

Proof of Stake Explained

Proof of work requires massive computational resources and consumes huge quantities of power. Proof-of-stake is a more energy-efficient alternative. In a proof of stake blockchain such as the post-Merge Ethereum blockchain, a node must “stake” a certain number of coins as collateral against harmful behavior to become a validator. Validators play the same role as miners in a proof of work system: they build and validate blocks.

The system chooses a validator at random to propose a block. It gathers transactions, creates a block, and passes it to other validators. They check it, add it to their blockchain database, and distribute it. In the Ethereum blockchain, validators are chosen every 12 seconds, so that is the smallest amount of time in which a new block might be added.

Uses of Blockchain Technology

In this article, we’ve explored how blockchains use cryptography and elegant consensus mechanisms to support decentralized, distributed, digital currencies. But we’ve barely scratched the surface regarding blockchain’s capabilities. Other blockchain applications include:

  • Smart contracts enforced by the blockchain

  • Decentralized application (dApp) platforms

  • Decentralized credential management

  • Digital asset tracking

  • Logistics and supply chain management

  • Secure records management

While innovators are leveraging blockchain technology to solve problems in many industries, cryptocurrencies remain by far the largest application. Bittrex makes buying and selling cryptocurrencies safe and easy. With the Bittrex cryptocurrency exchange, you can buy and sell Bitcoin (BTC), Ethereum (ETH), and many other cryptocurrencies. Sign up today to start trading Bitcoin in under ten minutes using Instant Buy & Sell.

The post appeared first on Bittrex.com - The Next Generation Crypto-Currency Exchange.

Popular news

How to Set Up and Use Trust Wallet for Binance Smart Chain
#Bitcoin#Bitcoins#Config+2 more tags

How to Set Up and Use Trust Wallet for Binance Smart Chain

Your Essential Guide To Binance Leveraged Tokens

Your Essential Guide To Binance Leveraged Tokens

How to Sell Your Bitcoin Into Cash on Binance (2021 Update)
#Subscriptions

How to Sell Your Bitcoin Into Cash on Binance (2021 Update)

What is Grid Trading? (A Crypto-Futures Guide)

What is Grid Trading? (A Crypto-Futures Guide)

Start trading with Cryptohopper for free!

Free to use - no credit card required

Let's get started
Cryptohopper appCryptohopper app

Disclaimer: Cryptohopper is not a regulated entity. Cryptocurrency bot trading involves substantial risks, and past performance is not indicative of future results. The profits shown in product screenshots are for illustrative purposes and may be exaggerated. Only engage in bot trading if you possess sufficient knowledge or seek guidance from a qualified financial advisor. Under no circumstances shall Cryptohopper accept any liability to any person or entity for (a) any loss or damage, in whole or in part, caused by, arising out of, or in connection with transactions involving our software or (b) any direct, indirect, special, consequential, or incidental damages. Please note that the content available on the Cryptohopper social trading platform is generated by members of the Cryptohopper community and does not constitute advice or recommendations from Cryptohopper or on its behalf. Profits shown on the Markteplace are not indicative of future results. By using Cryptohopper's services, you acknowledge and accept the inherent risks involved in cryptocurrency trading and agree to hold Cryptohopper harmless from any liabilities or losses incurred. It is essential to review and understand our Terms of Service and Risk Disclosure Policy before using our software or engaging in any trading activities. Please consult legal and financial professionals for personalized advice based on your specific circumstances.

©2017 - 2024 Copyright by Cryptohopper™ - All rights reserved.