[go: up one dir, main page]

0% found this document useful (0 votes)
1K views20 pages

Block Chain Technology Unit-I

Blockchain is a decentralized distributed database that records transactions in a way that makes it difficult or impossible to change, hack, or cheat the system. It allows digital information to be recorded and distributed, but not edited. The document discusses the history of blockchain technology and how it improves on previous systems by solving issues like double spending and the need for centralized trusted authorities. It then defines key aspects of blockchain like how blocks are linked together chronologically in an immutable ledger, and how consensus across the network validates new transactions. Different types of blockchain networks like public, private and consortium are also outlined. Finally, several real-world applications of blockchain technology are presented like land registry, insurance, voting, and food tracking.

Uploaded by

sriniefs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views20 pages

Block Chain Technology Unit-I

Blockchain is a decentralized distributed database that records transactions in a way that makes it difficult or impossible to change, hack, or cheat the system. It allows digital information to be recorded and distributed, but not edited. The document discusses the history of blockchain technology and how it improves on previous systems by solving issues like double spending and the need for centralized trusted authorities. It then defines key aspects of blockchain like how blocks are linked together chronologically in an immutable ledger, and how consensus across the network validates new transactions. Different types of blockchain networks like public, private and consortium are also outlined. Finally, several real-world applications of blockchain technology are presented like land registry, insurance, voting, and food tracking.

Uploaded by

sriniefs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

BLOCK CHAIN TECHNOLOGY

UNIT-I

Issues with Current Banking System:


 Centralized Power
 Private Ledgers
 High Transaction Fees
 Double Spending
 Financial Crisis and Crashes
 Prone to Hacks

History of Blockchain:
The first work on a cryptographically secured chain of blocks was described in 1991 by
Stuart Haber and W. Scott Stornetta. They wanted to implement a system where document
timestamps could not be tampered with. In 1992, Bayer, Haber and Stornetta incorporated
Merkle trees to the design, which improved its efficiency by allowing several document
certificates to be collected into one block. In 2004, computer scientist and cryptographic
activist, Hal Finney introduced a system called Reusable Proof of Work (RPoW). RPow
solved the double spending problem.

The first blockchain was conceptualized by a person (or group of people) known as Satoshi
Nakamoto in 2008. Nakamoto improved the design in an important way using a Hashcash-
like method to timestamp blocks without requiring them to be signed by a trusted party and to
reduce speed with which blocks are added to the chain. The design was implemented the
following year by Nakamoto as a core component of the cryptocurrency bitcoin, where it
serves as the public ledger for all transactions on the network. On 3rd January 2009 Bitcoin
came into existence, on 12th January 2009, Hal Finney received 10 Bitcoins from Satoshi
Nakamoto as First Bitcoin Transaction.

In August 2014, the bitcoin’s, Blockchain file size, containing records of all transactions that
have occurred on the network, reached 20 GB (gigabytes). In January 2015, the size had
grown to almost 30 GB, and from January 2016 to January 2017, the bitcoin blockchain grew
from 50 GB to 100 GB in size.

The words block and chain were used separately in Satoshi Nakamoto's original paper, but
were eventually popularized as a single word, blockchain, by 2016.

Many smart contracts are running on a Blockchain. Blockchains are being adopted in
financial services.

Blockchain:

Blockchain Technology – Compiled by G Sreenivasulu, Associate Professor of CSE, JBIET Page 1


Blockchain is a decentralized distributed database of immutable records, where transactions
are protected by strong cryptographic algorithms and the network status is maintained by the
Consensus algorithm.

 Blockchain is simply a data structure where each block is linked to another block in a
time-stamped chronological order
 It is a distributed digital ledger of an immutable public record of digital transactions
 Every new record is validated across the distributed network before it is stored in a block
 All information once stored in the ledger is verifiable and auditable but not editable
 Each block is identified by its cryptographic signature
 The first block of the Blockchain is known as the Genesis block

Block Chain is Use of Mathematics to create secure distributed ledger which enables
transactions without need for third parties.

What is the difference between blockchain and cryptocurrency?


Many people are confused on the differences between blockchain and cryptocurrency. A
relatable way of framing this relationship is to compare it to an application on your phone
(e.g. Uber or Whatsapp), and the platform on which that application is running (IOS or
Android). Blockchain is the platform and cryptocurrency is an application that runs on the
blockchain platform. The confusion stems in part from the fact that the platform (blockchain)
and cryptocurrency (Bitcoin) launched at the same time.

Blockchain is a distributed database. How does it differ from traditional databases?


Properties Blockchain Traditional Database
Operations Only Insert Operations Can perform C.R.U.D. (create,
read, update and delete)
operations
Replication Full Replication of block on every peer Master Slave
Multi-Master
Consensus Majority of peers agree on the outcome of Distributed Transactions
transactions (2 phase commit)
Invariants Anybody can validate transactions across the Integrity Constraint
network

Blockchain Transaction Life Cycle:


1. Someone Requests a Transaction via something called a wallet.
2. The transaction is send (broadcast) to all participation computers in the specific
blockchain network.
3. Every computer in the network checks (validate) the transaction against some validation
rules that are set by the creators of the specific blockchain network.
4. Validated transactions are stored into a block and are sealt with a lock (hash).
5. This block becomes part of the blockchain when other computers in the network validate
if the lock on the block is correct.

Blockchain Technology – Compiled by G Sreenivasulu, Associate Professor of CSE, JBIET Page 2


6. Now the transaction is part of the blockchain and cannot be altered in any way.

Basic Features of Blockchain Technology


1. Cannot be corrupted
2. Decentralized Technology
3. Enhanced Security
4. Distributed Ledgers
5. Consensus
6. Faster Settlement

Type of Blockchain:
Public Blockchain: They are fully decentralized and allow anyone to participate as users,
miners, developers, or community members. All transactions that take place on public
blockchains are fully transparent, meaning that anyone can examine the transaction details.
Blocks are validated one after another cannot be modified. Network is open to any new
participants. All participants can be involved in validating data. All participants can read data
contained in blocks. Some of the largest, most known public blockchains are the Bitcoin
blockchain and the Ethereum blockchain, Dash, Factom.

Private Blockchain: Transactions are private and are only available to ecosystem
participants that have been given permission to join the network. Private blockchains are
more centralized than public blockchains. Blocks are validated by an authority and can be
subsequently modified. Nodes chosen by the authority. New nodes are accepted by the
central authority. Blocks are validated by the central authority. Read rights may be limited by
the central authority.
Examples- Multichain, Blockstack
Federated or Consortium Blockchain: Consortium blockchains are sometimes considered
a separate designation from private blockchains. The main difference between them is that
consortium blockchains are governed by a group rather than a single entity. This approach
has all the same benefits of a private blockchain and could be considered a sub-category of
private blockchains. Blocks are validated one after another and cannot be modified. Network
nodes. Network nodes allowed to participate in the consensus. New nodes are accepted based

Blockchain Technology – Compiled by G Sreenivasulu, Associate Professor of CSE, JBIET Page 3


on a consensus. Read rights can be public or limited to certain nodes. Blocks are validated
according to predefined rules (approval from a specific number of nodes). New nodes are
accepted based on a consensus.
Examples- Ripple ,R3 & Hyperledger1.0

Blockchain Applications
Blockchain has the potential to revolutionize the way things are authenticated in any system.
1. Land Registry
Blockchain real estate market is building up new business models of connecting potential
buyers and sellers. In Blockchain solution, there is no need of third-party, lawyers and
brokers. Ubiquity joined with the real estate register office in Brazil and developed the
project which aims to reduce cost while improving, security and transparency. Ubiquity
seeks to great immutability to property ownership data handled by the land records office.
It is an effort to move away from paper-based records towards 100% computer-based
solution. Records stored on Blockchain are immutable. Also, Sweden government
partners with ChromaWay to test the possibility of a Blockchain based land registry.
2. Insurance
The first thing which comes to my mind when I think about insurance claim is increasing
fraudulent claims. Existing claims processes potentially have high complexity, extended
timeframes, and inconvenience, which can create customer friction and a gap of trust
between different parties. Everledger has come up with a delivering breakthrough
Blockchain solution to industries where transparency, trust, and provenance valued most.
3. Voting
There are always doubts about the voting system ability to secure data and defend against
potential attacks. Every single vote has a big impact on a country. Agora provided a
Blockchain voting platform to ensure transparent and verifiable elections around the
world. Agora’s partnership with the Sierra Leone election was a proof-of-concept
experiment. And the interesting part is, both results from government officials and
experiment had the same results.
4. Ride Sharing
Nowadays, sharing a ride is common. Passengers pay driver with either cash or credit.
How about digital currency? LaZooz is a real-time ridesharing service, powered by
Blockchain. It synchronizes vacant seats with passengers in real time, based on their
location. By using cryptocurrency technology La`Zooz works with a “Fair Share”
rewarding mechanism for driver and passengers.

5. Food
Ever wondered about the integrity of the food you are eating, where it comes from and
how it’s made? With Provenance, you can track the journey of fresh produce from source
to the shop in real time. As such, you can know if the chicken chop is infected since you
know the origin. Provenance equips physical products with a unique ID that enables the
tracking of each item. With that ID, you can check the secure digital history, along with
verified claims made by a company, enriched with content from along the supply chain.

Blockchain Technology – Compiled by G Sreenivasulu, Associate Professor of CSE, JBIET Page 4


Blockchain System means greater levels of confidentiality and security which reduces the
overhead of achieving regulatory compliance.

6. Patient Data Management


In the healthcare sector, critical patient data and information remains scattered across
different departments and systems. Due to this, crucial data is not accessible and easily
available at the time of need. Patientory is empowering people to take charge of their own
health. Patientory is a Blockchain solution that provides personal healthcare solution to
store and manage health information. They connect doctors, care providers, and
consumers all within a single, secure Blockchain platform, creating a team that works
together to provide the best care.

7. Drug Traceability
You wouldn’t tell if the medicine is genuine until you put it inside your stomach.
Blockverify provides a Blockchain solution to track pharmaceuticals throughout the
supply chain to ensure, consumers receive an authentic product. Blockverify offers a
transparent environment where it is not possible to duplicate products and it can track
fraudulent transactions of any type throughout the system. The system creates immutable
records to ensure data integrity, also, by using smart contracts it automates processes
leading to significant cost savings for its customers.

8. Commercial Financing
The current lending industry is inefficient, especially with lots of documents to fill up.
Now, both borrowers and lenders are connected all over the world through Blockchain.
Lendoit is disrupting the traditional lending industry, all without giving the bank their cut.
As lenders, you can remain completely anonymous without being required to register
anywhere. Select your preferred loan from the marketplace. Next is to initiate from your
wallets. Borrowers connected to the platform will pay the loan in a low- interest
environment.

9. Trade Financing
As of now, trade finance is a complex process. Various parties from exporters, importers,
banks, transporters, shippers, customs agents, and regulators all require checks and
verifications at various points of the process. Each interlocking part of the process
depends on the successful completion of the previous phase and on reliable information.
Creating a blockchain trade finance ecosystem means combining all the different stages
of a trade, from production to end-delivery including on-boarding other banks, regulators,
customs and all parts of the trade cycle.

Batavia has used a Blockchain based solution and designed to support more efficient,
transparent, secure and cost-effective transactions with the idea to simplify the trade
finance process by moving away from the trade finance sector’s reliance on paper-based
records. It eliminates the necessity to handle and compare documents, allowing buyers,
sellers, and the banks to execute transactions with efficiency and transparency. Recently,

Blockchain Technology – Compiled by G Sreenivasulu, Associate Professor of CSE, JBIET Page 5


Indian ICICI bank announced it has successfully on-boarded over 250 corporates on the
bank’s blockchain application. The idea behind it is to experience a more time and cost
efficient and secure way of undertaking domestic & international trade transactions
through Blockchain platform.

10. Cross-border transactions


Blockchain as a solution to financial institutions and banks is to offer near-instant cross-
border payments at lower costs, higher security and more reliability. With Blockchain,
payments are immutable and accurate, costs associated with the investigation of cases and
litigation are also getting trim. Axoni’s blockchain platform provides fully synchronized
integration with third-party market data providers. It serves as the underlying framework
to share and synchronize data between systems and financial institutions while
maintaining the privacy, scalability, and the audit required for capital markets.

Limitations And Challenges Of Blockchain Technology


Blockchain was invented by Satoshi Nakamoto in 2008 to serve as the public transaction
ledger of the Cryptocurrency Bitcoin. Blockchain has advantages but at the same time has
some limitations that need to be considered while using that technology. Though Blockchain
came a long way and it has already started for mass adoption.

The Limitations of the blockchain technology are:


1. Lack of Technical knowledge : Despite Blockchain's increasing popularity, still many
investors aren't aware of all the technical terms and also there is no proper
documentation which helps users to get detailed knowledge.
2. Fewer people available with proper certification: As compared to the demand for
Blockchain nowadays, the experts in this technology are quite a few.
3. Scalability: This is the one of the major limitation in the blockchain network as all the
transactions performed on the network needs to be verified by each of the nodes. Due
to which, the speed of processing transaction gets limited.
4. Less Privacy: As it is distributed ledger, though identities are anonymous but still with
the transaction patterns it is possible to link the user identity with that address and can
get information about the user.
5. Security Concerns: Blockchain is the network of people. If more than half of the
people become dishonest and get in favor of manipulation of data, then that lie
becomes the truth which could be one of the major reasons for the complete network
failure. So, they need to closely observe to avoid misusing the data and to ensure
security.
6. Complexity: Blockchain technology is not easy to understand by beginners as it
involves a lot of mathematical calculations. It can’t be understood overnight as it’s a
bit complicated industry.
7. Increased Transaction cost: In the beginning, transaction cost is almost free but as the
network grows, transaction cost keeps increasing.
8. Manual errors: Manual errors can lead to outdated log information or even create a
mismatching data while entering the data into the database.

Blockchain Technology – Compiled by G Sreenivasulu, Associate Professor of CSE, JBIET Page 6


The Challenges Faced by the Blockchain Technology are:
1. Initial Costs for Setup: Setting up blockchain for the very first time is very expensive
as it is developed for the specific firm and therefore it is expensive to purchase or
developing in-house. Also, after setting up, experts are required to fulfill the
requirements and as we know demand is high but very few resources are available.
So, organizations are paying high to hire the resources which are qualified.
2. Consumption of Energy: Miners spend a huge amount of computing power to solve
the computations via proof-of-work algorithm to verify and process the transactions
making it highly Energy-consuming.
3. Integration with the legacy system: Blockchain is running on the latest technology due
to which it’s too difficult to get it synced with older systems as those systems or
software's need to be modified to incorporate the changes due to which overhead cost
is increased to meet the blockchain requirements. Thus, it might take a lot of funds or
human expertise and also it is a time-consuming process.
4. Security and Privacy: As mentioned before, Blockchain is a secure platform as
transactions are visible only to the people on the network but still if the majority of
people are in support of false practices, it can be an issue for the system. Thus, it is
one of the issues which need to be reviewed by the blockchain community to avoid
manipulating or misusing data.
5. Public Awareness: Though many investors are started investing in blockchain still
there's a long way to go for the Blockchain to be fully adopted by masses. Still, there
are people in the world unaware about the usage, features and many more benefits of
Blockchain, which they can get if they use this technology.

Blockchain Technology – Compiled by G Sreenivasulu, Associate Professor of CSE, JBIET Page 7


Unit-II
Cryptocurrency
A cryptocurrency is a digital or virtual currency designed to work as a medium of exchange.
It uses cryptography to secure and verify transactions as well as to control the creation of new
units of a particular cryptocurrency. Essentially, cryptocurrencies are limited entries in a
database that no one can change unless specific conditions are fulfilled.
History
There have been many attempts at creating a digital currency during the 90s tech boom, with
systems like Flooz, Beenz and DigiCash emerging on the market but inevitably failing. There
were many different reasons for their failures, such as fraud, financial problems and even
frictions between companies’ employees and their bosses.

Notably, all of those systems utilized a Trusted Third Party approach, meaning that the
companies behind them verified and facilitated the transactions. Due to the failures of these
companies, the creation of a digital cash system was seen as a lost cause for a long while.

Then, in early 2009, an anonymous programmer or a group of programmers under an alias


Satoshi Nakamoto introduced Bitcoin. Satoshi described it as a ‘peer-to-peer electronic cash
system.’ It is completely decentralized, meaning there are no servers involved and no central
controlling authority. The concept closely resembles peer-to-peer networks for file sharing.

Cryptocurrency uses cryptography to make their transactions extremely secure. One of the
most important cryptographical tools that are used in cryptocurrency is the concept of Digital
signatures

What is Cryptocurrencies Cryptography?


Cryptography is a method of using advanced mathematical principles in storing and
transmitting data in a particular form so that only those, for whom it is intended for, can read
and process it. Cryptography has been used for thousands and thousands of years by people
to relay messages without detection. In fact, the earliest use of cryptography was seen in the
tomb taken from the Old Kingdom in Egypt circa 1900 BCE. Cryptography has existed in
modern society through one way or another.

Encryption is one of the most critical tools used in cryptography. It is a means by which a
message can be made unreadable for an unintended reader and can be read only by the sender
and the recipient. In modern technology, there are three forms of encryption that are widely
used, symmetric cryptography, asymmetric cryptography, and hashing.

Symmetric Cryptography:
Symmetric cryptography is the earliest known cryptographic method known to man. The
concept is very simple and if we were to break it down to steps, this is what it will look like:

 You have a message M that you want to send over to your friend.
 You encrypt the message with a Key and get a cipher text C.

Blockchain Technology – Compiled by G Sreenivasulu, Associate Professor of CSE, JBIET Page 8


 Your friend gets your cipher text C.
 She then decrypts the cipher text using the same Key to retrieve message M.

The are two types of symmetric cryptography:


 Stream Ciphers.
 Block Ciphers.

There are 3 kinds of stream ciphers:


 One-time pad with alphabets.
 One-time pad with XOR gate.
 Linear feedback shift register.
What is block ciphers?
Block ciphers are a form of symmetric cryptography which uses a key of a fixed length to
encrypt a block of fix length.
There are two rules for a block cipher to be considered valid:
 You must be able to derive the plain text from the cipher text and vice versa given a key.
 The function must be efficiently computable.

Examples of block ciphers


1. Data Encryption Standard (DES)
 Block sizes of 64 bits.
 Key size of 56 bits.
Was the government standard till 2001.
2. Advanced Encryption Standard (AES)
 128 bit blocksize.
 128, 192 or 256 bit key size.
Considered very secure and widely used nowadays

The problems with symmetric cryptography


Even though the overhead is significantly lesser, there are a lot of problems with symmetric
cryptography.

Problem #1: The shared key : The fact that the encryption and decryption is done with one
single key is a huge problem. First and foremost, the sharing of the key needs to be done in a
very secured manner, if anyone gets hold the of key then all your data will be compromised.

Problem #2: It is not scalable: Another huge problem with symmetric cryptography is that it
is not scalable at all. Suppose Alice runs an information center and sends data via symmetric
key cryptography. It’s ok if she is only dealing with 3-4 clients. But the most clients she gets,
the more unique public keys she will have to handle and take care of. Eventually, it will
become too much to handle.

Blockchain Technology – Compiled by G Sreenivasulu, Associate Professor of CSE, JBIET Page 9


The mathematical form of the Diffie-Hellman exchange
Suppose there is a generator g for a finite field of size n. And in that field, we choose two
random values a and b. It will be hard for an attacker to determine g^ab given only g, g^a and
g^b. This is the condition which activates the trapdoor function. Given this condition, two
parties can exchange messages and reach the same conclusion without explicitly
communicating it with each other.

So, mathematically this is what happens.

Alice chooses a random value “a” from the field n and determines a message M1 such that:

M1 = g^a mod n.
Similarly, Bob chooses a random value “b” from the field n and creates message M2 such
that:

M2 = g^b mod n.
Both Alice and Bob can now relay the message to each other.

Alice now determines special message K by doing the following:

K = M2^a mod n= g^ab mod n.


Bob now determines the same message K by:

K = M1 ^ a mod n = g^ab mod n.


So, both Alice and Bob reached the same conclusion without explicitly sharing this
information.

This Diffie-Hellman key exchange was invaluable in the formation of asymmetric


cryptography:

What is asymmetric cryptography?


Asymmetric cryptography utilizes two keys, a public key and a private to encrypt and decrypt
a particular data. The use of one key cancels out the use of the other.

There are two real world use of asymmetric cryptography that we will look into in this guide
and both are important for their own reasons:

The Rivest-Shamir-Adleman algorithm aka the RSA.


The Elliptical Curve Cryptography.
What is the RSA algorithm?
The RSA algorithm is the most widely used and popular asymmetric cryptographic algorithm
in history. It is named after MIT professors Rivest, Shamir and Adleman who discovered this

Blockchain Technology – Compiled by G Sreenivasulu, Associate Professor of CSE, JBIET Page 10


algorithm. Now, how does it work? The idea is derived from the breakthroughs that Diffie-
Hellman had.

So, these are the variables that we will work with:


Suppose you have the secret message “m”. “m” raised to the power of a random number e
and then the modulus of that with a random number N will give you the cipher text c.
Basically. m^e mod N= c
Take note, it is EASY to perform this function to get the output c BUT given only c, e and N
it is difficult to get the message “m”. It will require a lot of trial and error. This is the one-
way trapdoor function that we will apply to find “m”.
But now, the idea of the trapdoor function is to have a key which will make the reverse
process (the decryption) simple for the recipient. So, for that we will need to find a random
variable “d” which will make this process possible:
c^d mod N = m.
Now keep in mind, c = m^e mod N, so on substituting.

m ^ e ^ d mod N = m.
OR

m ^ ed mod N = m
So, in the above equations:

Public key = e and N.


Private key = d.
Now, before we even begin to see the method behind the madness, let’s do a simple
calculation to see how the entire process works. (Shout out to Anthony Vance’s youtube
channel for this example).

Suppose the message that you have to send is 42. In other words, m=42.

Along with that:

e = 17.
N = 3233.
d = 2753
The encryption process

c = m^e mod N.

Using simple substitution:

c = 42^17 mod 3233 = 2557.

So the cipher text is 2557.

Blockchain Technology – Compiled by G Sreenivasulu, Associate Professor of CSE, JBIET Page 11


The decryption process

Let’s do c^d mod N.

2557^2753 mod 3233

This gives us the value of m that is 42.

Genius isn’t it?

Now, remember when we talked about trapdoor functions we came to the conclusion that
private and public key needs to be mathematical derivatives of each other in a way that:

F(private key) = public key, where F() is another trapdoor function.

It should be difficult for anyone to determine the private key from the public key. In fact, it
should be so difficult that it will take the world’s most powerful computer decades upon
decades to derive one from the other.

To answer this conundrum, we go back centuries and meet our next genius, Euclid.

Euclid and prime factorization

Euclid found out centuries ago that any number > 1 can be written as a product of prime
numbers.

Eg. 15 can be written as 5*3.


255 can be written as 5*17*3.
Let’s go back to our two equations:

C= m^e mod N.

Here, N is the key in the trapdoor function. While N maybe publicly known it should be hard
to determine prime factors that make up the number N. If you know the prime factors, then it
is child’s play to discover the product N.

Eg. You can use your web browser to multiply two huge numbers and find the product in less
than a second:

The Science Behind Cryptocurrrencies Cryptography


It took less than a second, 0.22 seconds, to do the calculation. And the bigger the number
gets, it will take a little more time, but still, the calculations will be done super fast.

Blockchain Technology – Compiled by G Sreenivasulu, Associate Professor of CSE, JBIET Page 12


However, if you input a huge number and ask your computer to find its prime factors then it
may take days, months and even years to find the prime factors.

This is the trapdoor function that cryptographers used to determine the value of N. This is
basically, the heart of the trick.

This is what you have to do to use RSA algorithm:

First, generate a big random prime number P1.


Generate a second big random prime number P2.
Find N by calculating P1 and P2.
Hide the values of P1 and P2 and make N public.
N should be a huge number and it will take the most sophisticated machines in the world
decades to find the values of P1 and P2.
So to summarise, N is the trapdoor and its prime factors P1 and P2 are the keys to the
trapdoor.
Ok, so now we have determined how N is calculated and the trapdoor that works in it. But we
still haven’t determined the value of “e” and “d” and we still haven’t seen how the private
key is derived from the public key. In order to generate all these remaining values, we need to
find a function that depends on knowing the factorization of N. And for that we need to go
and visit our next genius, Leonhard Euler.

Euler and breakability

In 1760, Swiss mathematician Leonhard Euler did some path breaking studies. He studied the
nature of numbers and more specifically the breakability of the numbers which he called the
phi function.

Basically given phi(N) where N is a random integer, the value of N will be the number of
numbers between 1 and N which do not share any common factors with N.

So, if N is 8 then:

The numbers between 1-8 are: 1,2,3,4,5,6,7 and 8.

Among these numbers, only 1,3,5 and 7 don’t share any factors with 8 except 1.

Meaning, phi(8) = 4.

Now, calculating the phi function is difficult except for one case. To know this, check out the
following graph. The graph tracks the distribution of phi values over integers upto 1000.

The Science Behind Cryptocurrrencies Cryptography


Image courtesy: Khan Academy

Blockchain Technology – Compiled by G Sreenivasulu, Associate Professor of CSE, JBIET Page 13


See that straight green line at the top which is conveniently arranged? That is the phi of prime
numbers. Since the definition of a prime number is that it is unfactorizable apart from by
itself, for any prime number p the phi(p) = p-1.

Let’s see this in practice. Suppose you have a prime number 7.

The numbers between 1 and 7 are: 1,2,3,4,5,6,7.

The only number that shares a factor with 7 in this series is…7!

So the phi(7) = 6.

Similarly, if you were to find the phi of a large prime number say 541 then:

Phi(541) = 541-1 = 540.

It becomes very simple to calculate the phi for a prime number. And this gains, even more,
significance when you consider the multiplicative nature of phi functions. What is the
multiplicative nature of phi functions?

For any two numbers A and B:

Phi(A*B) = phi(A) * phi(B).

Now, let’s go back to algorithms. Alice has determined two large prime numbers P1 and P2
and has determined a number N by doing P1 * P2.

So, using the multiplicative property of phi functions:

Phi(N) = phi(P1) * phi(P2).

OR

Phi(N) = (P1-1)*(P2-1).

And just like that, we have discovered the trapdoor function for phi. If we know the prime
factors of N then it is easy to calculate the phi(N).

For eg. the number 77 has prime factors 7 and 11.

So phi(77) = (7-1)*(11-1) = 60.

It becomes very easy when you know the prime factors of N.

Blockchain Technology – Compiled by G Sreenivasulu, Associate Professor of CSE, JBIET Page 14


Now, one final bit of mathematical wizardry was required. We have the phi function and we
have the modular exponentiation functions that we have determined before, we need to bring
these two together in one neat equation.

And for this, we turn to Euler for help once again.

The Euler’s theorem


Euler’s theorem states that:

For any two numbers m and n that don’t share a factor:

m ^ phi(n) ≡ 1 mod n

Meaning, for any two numbers m and n, as long as they don’t share a factor, m raised to the
phi(n) divided by n will always leave a remainder of 1. Let’s see this in an example.

Suppose, m= 8 and n = 5.

Phi(5) = 4

So, 8 ^ 4 = 4096.

Replacing this in the Euler’s theorem equation:

4096 ≡ 1 mod 5 holds true because 4096 on being divided by 5 leaves a remainder of 1.

Now, the equation: m ^ phi(n) ≡ 1 mod n needs to be modified a little bit before we get our
final solution.

Modification #1

1^k = 1 for all k.

So, keeping this in mind, if in m ^ phi(n) ≡ 1 mod n we multiply the exponent phi(n) with any
number k, the final solution will be 1^k which is still 1.

Now, this modifies the equation like this:

m ^ k*phi(n) ≡ 1 mod n

Modification #2

For all m, m*1 = m.

Blockchain Technology – Compiled by G Sreenivasulu, Associate Professor of CSE, JBIET Page 15


So, in our modified equation, if we multiply both sides by m we get:

m*m ^ k*phi(n) ≡ m*1 mod n

Which becomes:

m ^ k*phi(n)+1 ≡ m mod n

Now, this is the final form of our equation.

Before we proceed, let’s bring back the old equations to refresh our memory:

c = m^e mod N.
m = c^d mod N
m ^ e*d mod N = m
Now, checkout the last equation doesn’t that look similar to our new modified equation:

m ^ k*phi(n)+1 ≡ m mod n

And this is the breakthrough.

On comparing the two equations, we get:

e*d = k*phi(n) + 1

We FINALLY have an equation where the value of e and d depends on phi(n).

Now, since we already know the value of e, it is easy to calculate d, the private key, ONLY if
the factorization of N is known (which is a secret that Alice has kept to herself).

So, d= (k*phi(n) + 1)/e.

This is the trapdoor that will undo the encryption done by her private keys e and n.

Example to see how this all works

Suppose Bob and Alice are exchanging messages.

Bob wants to send a message M to Alice where M=89.

Now, Alice needs to generate her keys.

She uses to prime numbers p1 and p2 where:

Blockchain Technology – Compiled by G Sreenivasulu, Associate Professor of CSE, JBIET Page 16


P1 = 53.

P2 = 59.

N = P1 * P2 = 53 * 59 = 3127.

Phi (N) = Phi(P1) * Phi (P2) = (P1 – 1) * (P2 – 1) = 52 * 58 = 3016

Now, she needs to generate a value e which will have no factors with the value of phi(N).

So, she decides e = 3.

Now, she will generate her private key d:

d = (k*phi(N) + 1)/e

Taking k = 2 we get:

d = (2* 3016 + 1) / 3 = 2011.

Now, she will lock up all the values except N and e which are her public key and make the
knowledge of these two global.

Bob encrypts the message

Now, Bob needs to send message M, which is 89, and he needs to calculate the cipher text c
such that:

c = M^e mod N.

Now, we know that: M = 89, e = 3 and N = 3127.

So: c = 89^3 mod 3127 = 1394.

He then sends it over to Alice.

Alice decrypts the message


Alice gets the cipher text and all that she has to do is to decrypt it using her private key d
which we know to be 2011.

So, Alice does this calculation: c^d mod N

1394^2011 mod 3127 which is 89 aka the original message M.

Blockchain Technology – Compiled by G Sreenivasulu, Associate Professor of CSE, JBIET Page 17


And this, is the RSA algorithm, the most widely used cryptographic algorithm

What is elliptical curve cryptography?


Elliptical curve cryptography is what is used by bitcoin, ethereum etc. for their encryption
purposes. So what is an elliptical curve? An elliptical curve is any curve that satisfies the
following equation:

Y^2 = x^3 + ax + b

Where (x,y) is a point on the curve and a and b are constants.

What is the Game theory?


What is Cryptoeconomics? An Intro to Game Theory
Game theory is the study of strategic decision making. This is how many corporations make
decisions while keeping in mind the actions that their competitors will take. Game theory was
devised by John Van Neumann and Osker Morgenstern in 1944 and was considered a
breakthrough in the study of oligopoly markets.

Since then the game theory has found a life of its own and has seen widespread
implementations in various other technologies and fields.

A game theory model has at least 3 components:


 Players: The decision makers. Eg. The managers in the firms.
 Strategies: The decisions they want to take to further their companies.
 Payoff: Outcome of the strategies.
In game theory, there are two types of games.
 Zero sum game: It is a game in which the gain of one player comes at the expense of
another player.
 Non zero sum game: A game where the gain of one player doesn’t come at the
expense of another player.

What is Nash Equilibrium?


The Nash equilibrium is a solution to a game where each player chooses their optimal
strategy given the strategy was chosen by the other and they have nothing to gain by shifting
their strategy. This was formulated by John F Nash. In fact, the blockchain is “cheat-free”
because the entire protocol is in a Nash Equilibrium.

The Prisoner’s Dilemma


Suppose Rob and Ben were caught stealing a liquor shop and during the investigation, it was
discovered that both of them have committed a far more serious crime in the past, say a bank
robbery. During the investigation, the cops interrogate both of them and present them with a
proposition.

Blockchain Technology – Compiled by G Sreenivasulu, Associate Professor of CSE, JBIET Page 18


Proposition 1: If you both don’t rat the other guy out then you will both get four years in jail.
Proposition 2: If one of you rats the other one out then the person who confessed will get 0
years while the other gets seven years.
Proposition 3: If both of you confess then you will both get two years each.

In a decentralized peer-to-peer system like a public blockchain, there needs to be consensus.


The individual parts of the system need to agree on the history of the blockchain up until the
present moment as well as on how to move forward since there is no central authority to
assume responsibility over it.
That’s easier said than done. There is always a risk of misinformation or miscommunication
between users, whether accidental or deliberate. The Byzantine Generals Problem is a way of
explaining the problem of misalignment between users of a decentralized system and its
solution, without which decentralized Distributed Ledger Technology, and several other types
of computer networks would fail to function properly.

Take a public blockchain for example. To make it work, enough participants in the
blockchain must agree on the history of validation and permanent registration of transactions
on the blockchain ledger up until that point. If we could rely on everybody to be honest, there
would be little or no problem — but we can’t. The temptation to register fraudulent
transactions or illicitly reverse genuine transactions, while hanging onto their ill-gotten gains
is simply too much for some users to resist.

Public blockchain protocols must deal with this issue autonomously. No single participant
can step in and unilaterally declare transactions to be valid or invalid. That would make
nonsense of the principle of decentralization. But to understand how a blockchain protocol
can handle such a challenge, we first need to know more about the problem.
Let’s allow the Byzantine Generals step forward and tell us all about it. The Byzantine
Generals Problem was given its name by Leslie Lamport, one of the three authors of a pivotal
paper on the subject in 1982. He reasoned that ‘the best way to attract attention to a problem
is to present it in terms of a story’, meaning the Byzantine Generals didn’t actually have a
problem with achieving decentralized consensus — it’s just an effective way of helping
people understand the problem.
Imagine a military operation in the East Roman Empire (aka Byzantium), more than 1,000
years ago. Several Byzantine generals and their armies are positioned around a rebel city.
Each general and army is in a separate camp. Communication between the generals is only
possible by messengers who must cross the open terrain from one camp to another.
For the generals and their armies to successfully attack the city or retreat safely from it, they
must all act together. Failure to coordinate their actions by even one of the generals will mean
that all the armies will be individually massacred by the forces of the rebel city. To act
together and take over the rebel city, they must agree on when to attack and at what time —
but here’s the catch:
They could send messengers on horseback, but what if one is captured or killed before
delivering the message?

Blockchain Technology – Compiled by G Sreenivasulu, Associate Professor of CSE, JBIET Page 19


They’d need to reply to one another to confirm they’ve received and agree with the message,
but this would entail sending another messenger on horseback who may also be captured or
killed.
What if a messenger is intercepted by the enemy and the message is changed in order to
confuse the generals?
How do any of the generals know that the messages they received are genuine?
What if one or more of the generals are traitors and intentionally send the wrong message to
other generals?

It’s a tough problem to crack, but one that Satoshi Nakamoto managed to solve through the
Bitcoin blockchain.
Distributed systems with mechanisms to overcome this problem are said to have Byzantine
Fault Tolerance or BFT. Bitcoin has BFT built into its protocol. Its proof of work consensus
mechanism is designed to produce new blocks every 10 minutes, using the total available
computing power in the Bitcoin network and rewarding the first node to mine the next valid
block.
What is Proof-of-Work (PoW)?
All the other Bitcoin nodes in the network can easily and individually check that a new block
of transactions proposed by one of the nodes has been correctly mined. In this way they can
then reach agreement on whether to add the new block to the existing blockchain.
And so, unlike the Byzantine generals who — rumour has it, are still stationed around the
rebel city to this day — users of public blockchain systems can safely and securely run their
operations.

Blockchain Technology – Compiled by G Sreenivasulu, Associate Professor of CSE, JBIET Page 20

You might also like