Blockchain Technology Tutorial

Blockchain technology is revolutionizing a wide range of industries. Forbes’ Bernard Marr highlights several Blockchain applications, including entertainment, such as music-streaming service Spotify; the food industry, such as for supply-chain logistics; and healthcare, such as for storage and use of medical records. While the possibilities for blockchain’s applications may be constantly growing, however, the best known may still be bitcoin.

Interested to learn about Blockchain, Bitcoin, and cryptocurrencies? Check out the Blockchain Certification Training and learn them today!

Blockchain Technology Tutorial

The topics covered in this article on Blockchain Technology are:

  • Issues with today’s banking systems
  • How bitcoin has solved these issues
  • What is blockchain technology
  • The features of the blockchain, such as public distributed ledger, how encryption works, the proof-of-work algorithm and mining
  • Blockchain use case

Let us begin by understanding the issues with banking systems.

Issues With Banking Systems

Suppose you want to transfer money from your account to someone else’s account through a banking channel. For a $200 transaction, the bank might charge a fee of to $5, meaning the receiver would end up getting only $195. In percentage terms, that’s a very high transaction fee.

Issues with Banking Systems

Today there are also many scenarios in which people end up double spending. For example, a user has $800 in an account but ends up sending $1,000 total—$500 each to two users. Double spending is a unique problem in which digital money is spent twice, meaning the user is able to make two purchases with an amount that is less than the total purchase value.

Also, banking systems are prone to hacking. Hackers gain unauthorized access to data and do transactions on behalf of an unsuspecting person, or transfer money to illegitimate accounts. In 2017, there were 1,785 fraud instances in India through ATM cards and net banking, each amounting to more than 1 lakh rupee (about $1,385—for a total of about $2.5 million). With the current banking system prone to so many hacks, it can cost a huge amount of money.

Let us understand how Bitcoin, the first application of Blockchain technology, solves the issues with banking systems.

How Bitcoin Solves These Issues

Bitcoin is a decentralized system, so you can do a transaction for a fee as low as $1, compared with the $5 the bank was charging in our example. And at the other end, the receiver gets the true value of the amount that was sent.

Bitcoin is a decentralized system in which no third party—such as a government, bank or any other financial intermediary—is involved in the transaction between the sender and receiver, thereby reducing the transaction cost drastically. That is the primary objective of cryptocurrencies and all technologies like blockchain in which intermediaries are removed.

Now let’s see how bitcoin and blockchain technology has solved the problem of double spending. The basic structure of blockchain involves verification of transactions. In our example above, if the user transferred $500 to the first person, then she would not be able to transfer another $500, due to the basic validation of the blockchain.

Suppose you are trying to spend the same bitcoins in a second transaction after the first transaction has been confirmed. The second transaction would not get verified and would thus become invalid because after the first transaction has been confirmed, the balance would be verified in the second transaction and the address identity would be validated. If someone tries to spend more than the balance in the account, the miners (the validators of the blockchain network) would discard that particular transaction and not add it to the main blockchain network. So double spending is pretty much impossible.

How Bitcoin Solved these problems

In a blockchain, each block is linked to its previous block. The transactions become invalid for bitcoins that have already been spent; you can't spend any bitcoins that have already been spent. And a public ledger records all bitcoin transactions, accessible by everyone who is associated with the system. It is a 100% transparent system: all transactions are visible on the public ledger. Once a user joins the blockchain network, he or she gets a copy of all the blockchain transactions since its inception.

The first block in a blockchain is called the genesis block. Though everyone in the network can access the public ledger, only the user’s address and the transaction details are visible. By looking at the address, you can’t figure out to whom this address belongs. Thus, the identity of the address owner is secure. Also, the blockchain is safe from data tampering. Each block in the blockchain is aware of its previous block. Even if a hacker tries to hack one block, he or she would have to change the entire subsequent chain ahead of that block, which would require such a huge amount of computational power as to make it next to impossible.

Let us now learn more about Blockchain technology.

What Is Blockchain Technology?

Imagine two friends living far away from each other, and one would like to transfer money to the other using blockchain technology. As mentioned, blockchain is a decentralized system of secure and trusted distributed databases. It’s a distributed ledger that records and shares the transaction details across many nodes (computers) that are part of the network. Every participant has the same copy of the ledger, and it’s immutable—once a record or a transaction is registered, it cannot be modified.

Blockchain was originally introduced to timestamp digital documents and prevent tampering of records. In simple terms, a chain of blocks that contain information is called a blockchain. When a transaction occurs, its related information is recorded into a block. A transaction initiated in one corner of the globe can get registered on the block, and then that block is verified (validated) by the miners and then added to the main blockchain. A block contains aggregated transactions that a miner has to validate, and for doing that, the miner gets rewarded.

After understanding Blockchain technology, you should know what are the components of a block.

Components of a Block

Components of a Block

Previous Hash

The previous hash is the attribute that connects a block to its previous block. It consists of the hash value of the previous block.

Data

This consists of the sender’s address, the receiver’s address and the transaction amount. There could be multiple transactions among multiple senders and receivers, so each block consists of any number of transactions, and each transaction will have a sender’s address, a receiver’s address, and a transactional nonce.

Nonce

Bitcoin uses a proof-of-work algorithm, and to execute the algorithm, a random value is used to vary the output of the hash value; this is called the nonce. Proof of work is the process of transaction verification.

Hash

The hash is like a digital fingerprint. To get the hash for the current block, the process takes an input value (the previous hash, the data, and the nonce) and produces an output value of a fixed length. Bitcoin uses the SHA-256 hashing algorithm to generate a 256-bit-length hash. It looks something like a hexadecimal value.

Moving on, let us take a look at the features of blockchain technology.

Features of Blockchain

1. Public Distributed Ledger

To recap, a blockchain is a decentralized public distributed ledger that is used to record transactions across many computers. For example, user A transfers money to user B, user B transfers to C, and C transfers to B. A distributed ledger is a database that is shared among all the users who are part of the blockchain network. The transactions are accessed and verified by users of the bitcoin network, thereby making it less prone to cyber attack.

Let’s take an example in which bitcoin users are transferring money: Bella is trying to transfer money to John, John is trying to transfer money to Elsa, and Elsa is trying to transfer money to Jack. So these are the three transactions to be initiated.

If these transactions were happening on a central ledger, it could get corrupted, and there is the chance of data tampering. To solve this problem, a public distributed ledger plays a vital role: It ensures that each user who is part of the cycle has a copy of the transaction details. In our example, Bella, John, Elsa, and Jack all have the same ledger—the distributed ledger.

Now let’s say Elsa misplaces her transaction details. She can easily get them from the other participants because they all have a copy. And if anyone attempts to alter the record, the alternate transaction copies with the other users will negate the alteration, because they will see that among all the participants, only one has a different copy.

Public Distributed Ledger

2. Encryption

Blockchain eliminates unauthorized access by using the cryptographic algorithm SHA-256 to ensure that the blocks are kept secure. Each user in the blockchain has his or her own keys: a private one and a public one. The private key is known only to the sender; it is also used to confirm if the origin of the transaction is legitimate. The public key is also used to uniquely identify the user, but it is shared by the sender with every transaction. It floats on the blockchain network.

Let’s take a look at a typical transaction verification process. Suppose a sender wants to send a message. The sender will pass the message through the hash function and generate a hash value of the message. After the hash value has been created, it is passed through a signature algorithm, and with the private key, a digitally signed document is created.

The original message, the digitally signed document, and the public key are then transmitted to the receiver. At the receiver’s end, the transaction message is passed through a hash function to get a hash value, and that hash value is compared with the hash value obtained by passing the digital signature and public key through a verification function.

The hash function creates a unique digital fingerprint of data. The message is passed through the hashing function, and it generates a hash value. This hash value is called a digital print, and it has a unique property: Any hashing function is a one-way function; it cannot be reversed. You cannot decode the original value from the hashed value. The image below shows some examples.

Features of Blockchain - Encryption

As you can see, no matter what the size of the input data is, the hash value always has a 256-bit length. Now let’s consider the example of Gmail using a hashing algorithm. Whenever you enter your username and password, that password is never directly saved in any part of the Gmail database. It is saved using the hashing function. So once you log on, your password is passed through the hashing function and compared with the hash value in the database. If both of these hash values match, then you’re logged on to Gmail and the inbox is displayed on your screen.

3. Proof of Work

Proof of work is a method to validate transactions in a blockchain network by solving a complex mathematical puzzle, and this process is called mining. Finding the nonce value is the mathematical puzzle that miners need to solve in the bitcoin network, and it takes a huge amount of computational power and resources to find the nonce value. Users trying to solve the puzzle are called miners.

The puzzle is solved by finding a nonce that generates a hash value and results in an output that is less than a predefined target. Miners verify transactions within a block and add the block to the blockchain when they have confirmed and verified the transaction. With proof of work, miners compete against one another to solve the mathematical puzzle; the first miner who solves the puzzle is rewarded. And when a block is solved, the transactions contained in it are also considered valid, and the bitcoins associated with the transactions then get deducted from the sender’s account and move to the receiver’s account.

Let’s take a closer look at how proof of work functions. Remember the components of the block described previously: the previous block’s hash, the data for all the transactions aggregated in the block, the nonce (the random value used to generate a hash value less than the target) and the hash, which is the digital signature of the block itself. As mentioned, the hash is generated using a hashing function called SHA-256.

Enroll for the Blockchain Training Course and get a deep dive on Bitcoins, Hyperledger and learn to build your own blockchain network!

When the hash is generated, if its output is less than the target, then the puzzle is deemed to be solved and the block is considered to be validated. If the output is not less than the target, then the miner increases the nonce by 1 and then a new hash is generated. This process continues until the puzzle is solved.

Things to note:

  • In blockchain, the target is adjusted every 2,016 blocks, which is approximately every 14 days.
  • The average time it takes to form a block is 10 minutes.
  • The difficulty target of the puzzle increases or decreases depending on the time it takes to mine the blocks. So the network generates the target for the puzzle to be solved, and it changes the difficulty based on the time it takes to mine a block.
  • Proof of work is hard to produce but very easy for miners to verify. Once the block is hashed, the remaining miners validate the work of that one miner, but they don’t need to find the nonce again, so it takes less work.

4. Mining

When miners use their resources—time, money, electricity and so on—to validate a new transaction and record it on the public ledger, they are given a reward in bitcoins. As of today, the reward is 12.5 bitcoins, and there is no other way that bitcoins can be generated in the bitcoin network. The reward is halved after every 210,000 blocks or about every four years. When this happens next, the mining reward will be reduced to 6.25 bitcoins.

Blockchain Use Case

Here is the video in which you can see a demo on how to generate an SHA-256 hash using an input value, as well as see a typical blockchain structure, the mining of a block and an actual transaction involving sending money.

This article is only the beginning of all there is to learn about blockchain technology and bitcoin. If you’d like to learn the full range of blockchain basics, check out Simplilearn’s Blockchain Basics course. Want to take your career to the next level with a blockchain certification? Take the Blockchain Certification training course.

About the Author

SimplilearnSimplilearn

Simplilearn is one of the world’s leading providers of online training for Digital Marketing, Cloud Computing, Project Management, Data Science, IT, Software Development, and many other emerging technologies. Based in San Francisco, California, and Bangalore, India, Simplilearn has helped more than 500,000 students, professionals and companies across 200 countries get trained, upskilled, and acquire certifications.

View More
  • Disclaimer
  • PMP, PMI, PMBOK, CAPM, PgMP, PfMP, ACP, PBA, RMP, SP, and OPM3 are registered marks of the Project Management Institute, Inc.