Book Image

Learn Bitcoin and Blockchain

By : Kirankalyan Kulkarni
Book Image

Learn Bitcoin and Blockchain

By: Kirankalyan Kulkarni

Overview of this book

Blockchain is a distributed database that enables permanent, transparent, and secure storage of data. Blockchain technology uses cryptography to keep data secure. Learn Bitcoin and Blockchain is the perfect entry point to the world of decentralized databases. This book will take you on a journey through the blockchain database, followed by advanced implementations of the blockchain concept. You will learn about Bitcoin basics and their technical operations. As you make your way through the book, you will gain insight into this leading technology and its implementation in the real world. You will also cover the technical foundation of blockchain and understand the fundamentals of cryptography and how they keep data secure. In the concluding chapters, you’ll get to grips with the mechanisms behind cryptocurrencies. By the end of this book, you will have learned about decentralized digital money, advanced blockchain concepts, and Bitcoin and blockchain security.
Table of Contents (6 chapters)

An introduction to cryptography and cryptocurrency

The blockchain technology is the backbone of cryptocurrency and it uses cryptography to keep the data secure. In this section of the chapter, we will discuss cryptography, cryptocurrency, and how cryptography is used in cryptocurrency implementation. We will also look into the workings of fiat currency cryptography, energy use in cryptocurrency, and also the security features of cryptography that are used. We will learn everything we need to know about decentralized digital money and its underlying architecture.

As we browse through the various parts of this section, we will learn about the history of Bitcoin, its alternative currencies, Bitcoin basics, and the technical operation of Bitcoin; then, we will browse through the technical foundation of the blockchain, the fundamentals of cryptography, and how it keeps data secure. From there, we will move on to understanding blockchain, its features, the underlying architecture on top of each Bitcoin, and how cryptocurrencies are implemented.

Workings and security of fiat currencies

Before we understand cryptocurrency, let's first look at some basic currencies used around the world. These currencies are also known as fiat currencies.

They are shown in the following diagram:

Some of the characteristics of fiat currencies are as follows:

  • These are owned by the governments of countries
  • They are centrally controlled through banks or legal entities
  • They are inflationary, meaning the value of a currency decreases
  • They include various security properties to prevent counterfeiting and cheating, but it is not impossible to counterfeit them

Since it is not impossible to counterfeit currencies, law enforcement comes into the picture to stop and prosecute those involved in counterfeiting fiat currencies. We will now look at various security features that are implemented in fiat currencies, as shown in the following diagram:

You will find two watermarks. You'll also see micro lettering and identification marks being implemented. Most of the time, fluorescent ink is used on notes for detecting notes that are fake.

Understanding cryptocurrency and its uses

Cryptocurrency is a very interesting and intriguing topic that has become a global phenomenon. It is different from all the currencies that are found all over the world. Right from the working of cryptocurrency, to who owns or controls it, its benefits and limitations, its use and much more, are all based on new ideas and processes. Let's now see a brief overview of the various features of cryptocurrency.

The main features of cryptocurrency are as follows:

  • It is a digital asset used as a medium of exchange
  • It secures transactions and controls supply by using cryptography
  • It is a subset of alternative currencies
  • In 2008, the first decentralized cryptocurrency was conceptualized
  • Cryptocurrency is digital money, while the underlying technology that enables the moving of digital coins or assets between individuals is called blockchain

Hash function

The main cryptography techniques used in cryptocurrency are a hash function and a digital signature.

Let's look at each of these briefly. The hash function is a mathematical function with the following properties:

  • Any input that we provide, be it a string, number, floating number, or anything, can be of any size
  • It produces a fixed-size output such as a 128-bit hash outcome or even a 256-bit outcome
  • It is collision-resistant
  • It hides the data within it

Let's now look at an example of a hash function in the following diagram:

Let's look at the hash function being used here. In the preceding diagram, we gave Fox, one string, as an input to the encryption module and we applied a hash function to it. It gives a specific fixed hash outcome, which is also known as a digest hash sum. Let's say we pass another statement that says The red fox runs across the ice and we apply a hash function to it. It gives us a specific hash sum, also known as a digest. Then, we add another statement, The red fox walks across the ice, and we see that it changes the hash function as the input has been changed. This is the key feature that the hash function brings.

Digital signature

This is the second building block of cryptocurrency and is digitally analogous to the hand written signatures that we usually make.

The properties of the digital signature are as follows:

  • You can create your own signatures, but they can be verified by another person too
  • The signature is tied to a particular document or message so that it cannot be used again and again for different documents and messages

Let's now look at an example of a digital signature in the following diagram:

Let's take an example and say that there is a string in the document which states that "I agree to pay $5000 for the software". Since this is the document that is being signed, we first apply a hash function to it. It gives us a hash or digest of the document, which is again fixed in size. Then, we apply our private key, or a specific key, to encrypt it and we get the outcome as a digital signature. This digital signature is signed specifically for this input, which states that "I agreed to pay $5,000 for the software".

Here, we saw how cryptography and cryptocurrency are digital assets that are widely used. We also saw how cryptocurrency uses cryptography and its techniques, such as hash functions and digital signatures.