Unit-1 Introduction to BlockChain Technology
Unit-1 Introduction to BlockChain Technology
Block-Chain Technology
By
Mr. Nitish Patidar
Syllabus
• Introduction and crypto foundation: Elliptic
curve Cryptography
• ECDSA
• Encryption and decryption.
• Introduction to Block-chain Technology with
its Applications, Block-chain Network,
• Hashing Algorithm: SHA-256
• Immutable Ledger
• Centralized and Distributed P2P Network.
Cryptography
• Cryptography is technique of securing information and
communications through use of codes so that only those person
for whom the information is intended can understand it and
process it.
• As a result preventing unauthorized access to information.
• Cryptography uses mathematical techniques to transform data
and prevent it from being read or tampered with by
unauthorized parties.
• The prefix “crypt” means “hidden” and suffix “graphy” means
“writing”.
• It converting intelligible text into unintelligible text, and vice
versa. Cryptographic techniques allow only a message’s sender
and intended recipient to read the decoded contents.
• Techniques used For Cryptography: In today’s age of computers
cryptography is often associated with the process where an ordinary
plain text is converted to cipher text which is the text made such that
intended receiver of the text can only decode it and hence this process
is known as encryption.
• The process of conversion of cipher text to plain text this is known as
decryption.
“There are Two types of encryption”
• Symmetric-key Encryption (secret key
encryption): Symmetric-key algorithms are
cryptographic algorithms that employ the same
cryptographic keys both for plain-text encryption and
cipher-text decoding. The keys could be identical, or
there could be a simple transition between them.
• Asymmetric-key encryption (public key
encryption): Asymmetric-key algorithms encrypt and
decrypt a message using a pair of related keys (one
public key and one private key) and safeguard it from
unauthorized access or usage.
Some Terminology
• Public key– Key which is known to everyone. Ex-public key of A
is 7, this information is known to everyone.
• Private key– Key which is only known to the person who’s
private key it is.
• Authentication-Authentication is any process by which a system
verifies the identity of a user who wishes to access it.
• Non- repudiation– Non-repudiation is a way to guarantee that the
sender of a message cannot later deny having sent the message
and that the recipient cannot deny having received the message.
• Integrity– to ensure that the message was not altered during the
transmission.
• Message digest -The representation of text in the form of a single
string of digits, created using a formula called a one way hash
function. Encrypting a message digest with a private key creates a
digital signature which is an electronic means of authentication.
Types of Cryptography
• Here are the different types of cryptography:
• Secret Key Cryptography: Secret-key cryptography is also
called symmetric cryptography because the same key is used to both
encrypt and decrypt the data.
• Well-known secret-key cryptographic algorithms include Advanced
Encryption Standard (AES),
• Triple Data Encryption Standard (3DES), and
• Rivest Cipher 4 (RC4).
Public Key Cryptography
• The sender uses a public key to encrypt the message, and
the receiver uses a private key to decrypt it. If the
message is intercepted, the contents can’t be deciphered
without the private key.
Digital Signature
• A digital signature is a cryptographic
technique used to verify the authenticity and
integrity of digital messages or documents.
• It provides a way to ensure that a message or
document has not been altered during transit
and that it was definitely created by the
claimed sender.
Here's how digital signatures typically
work
• Hashing: The content of the message or document is first passed through
a hash function to generate a fixed-size string of characters, often referred
to as a hash value or digest. This hash value is unique to the content of
the message.
• Private Key Encryption: The hash value is then encrypted with the
sender's private key. The private key is a part of a key pair (along with a
corresponding public key), and it is kept secret by the owner.
• Digital Signature: The encrypted hash value, along with other
information such as the public key of the sender, forms the digital
signature. This signature is attached to the original message or document.
• Verification: To verify the digital signature, the recipient uses the
sender's public key to decrypt the encrypted hash value. This produces a
hash value that should match the one generated from the received
message. If the two hash values match, the signature is considered valid,
and the message or document is deemed authentic and unaltered.
Digital Signature
Benefits
• Authentication: The recipient can be
confident about the identity of the sender.
• Integrity: Any modification of the message or
document, intentional or accidental, can be
detected.
• Non-repudiation: The sender cannot later
deny having sent the message, as their private
key is used to create the digital signature.
Hash Functions
• Hash functions don’t rely on keys.
• Instead, they scramble data of varying size
into values of uniform length.
• A hash function is a mathematical function
that converts a numerical input value into
another compressed numerical value. The
input to the hash function is of arbitrary
length but output is always of fixed length.
• Values returned by a hash function are
called message digest or simply hash
values.
• With hash functions, both a one-word
message and a 1000-page novel create a
fixed-sized output of encoded text (called a
hash value), making it nearly impossible to
determine the original content. Commonly
using the MD5 hashing algorithm, hashing is
often used for authentication purposes.
A peer-to-peer (P2P) network
• A Peer-to-Peer (P2P) network is created when
two or more PCs are connected and share
resources without going through a separate
server computer.
• A P2P network can be a couple of computers
connected via a Universal Serial Bus to
transfer files.
Cryptocurrency
• A Crypto-Currency, crypto-currency, or crypto is
a digital currency designed to work as a medium
of exchange through a Computer network that is
not reliant on any central authority, such as
a government or bank, to uphold or maintain it.
• It is a decentralized system for verifying that the
parties to a transaction have the money they claim
to have, eliminating the need for traditional
intermediaries, such as banks, when funds are
being transferred between two entities.
Crypto-currency
• Crypto-currency is a digital payment system that doesn't rely on
banks to verify transactions.
• It’s a peer-to-peer system that can enable anyone anywhere to
send and receive payments.
• Instead of being physical money carried around and exchanged
in the real world, crypto currency payments exist purely as
digital entries to an online database describing specific
transactions.
• When you transfer Crypto-currency funds, the transactions are
recorded in a public ledger.
• Crypto-currency is stored in digital wallets.
• Crypto-currency received its name because it uses encryption to
verify transactions.
• This means advanced coding is involved in storing and
transmitting Crypto-currency data between wallets and to public
Example of Cryptocurrency
• Bitcoin
• Ethereum
• Tether
• XRP
• Bitcoin cash
• Bitcoin SV
• Litecoin
• Binance Coin
• EOSA
• Tezos
What is Block chain?
– A Linked List
– Replicated
– Distributed
– Consistency maintained by Consensus
– Cryptographically linked
– Cryptographically assured integrity of data
– Used as
– Immutable Ledger of events, transactions or time stamped data
– Tamper resistant log
– Platform to Create and Transact in Crypto-currency
– log of events/transactions unrelated to currency
Imagine four friends Jack, Ted, Sam and Phil meet up
for dinner after they're done Jack pays the bill and all of
them decide to split the expense amongst each other.
To Solve this problems
Block-chain Technology Definitions
• Blockchain is a method of recording information that makes it
impossible or difficult for the system to be changed, hacked, or
manipulated.
xR = ∆ 2 - x P - x Q
yR = -yP + ∆(xP - xR)
Algebraic Description of Addition
• We also need to be able to add a point to itself:
P + P = 2P = R. When yP ≠ 0, the expressions
are:
Elliptic Curves over Zp
• The rules for addition over Ep(a, b), correspond to the algebraic
technique described for elliptic curves defined over real numbers.
• For all points P, Q ∈ Ep(a, b):
Elliptic Curves over Zp
Elliptic Curves over Zp
ECC Diffie–Hellman Key Exchange
Elliptic Curve Encryption and
Decryption
• To encode the plaintext message m to be sent as
an (x, y) point Pm.
Application of Elliptic Curve Cryptography
• Diffie-Hellman: The basic public-key cryptosystem suggested for secret key
sharing is the Diffie-Hellman protocol. If A (Alice) and B (Bob) initially agree on a
given curve, field size, and mathematical type. They then distribute the secret key
in the following manner. We can see that all we need to build the Diffie-Hellman
protocol is scalar multiplication.
• Elliptic Curve Digital Signature Algorithm (ECDSA): ECC is one of the most
widely utilized digital signature implementation approaches in cryptocurrencies. In
order to sign transactions, both Bitcoin and Ethereum use the field inverse
multiplication, but also arithmetic multiplication, inverse function, and modular
operation.
• Online application: Moreover, ECC is not limited to cryptocurrencies. It is an
encryption standard that will be utilized by most online apps in the future due to its
reduced key size and efficiency. Most commonly used in cryptocurrencies such as
Bitcoin and Ethereum, along with single-way encryption of emails, data, and
software.
• Blockchain application: The cryptocurrency Bitcoin employs elliptic curve
cryptography. Ethereum 2.0 makes heavy use of elliptic curve pairs with BLS
signatures, as stated in the IETF proposed BLS specification, to cryptographically
ensure that a specific Eth2 validator has really verified a specific transaction.
Elliptic Curve Digital Signature
Algorithm (ECDSA)
• Elliptic Curve Digital Signature Algorithm (ECDSA) is a
widely used cryptographic algorithm for creating digital
signatures.
• It relies on the mathematics of elliptic curves over finite fields
to provide a secure and efficient method for digital signature
generation and verification.
• In ECDSA n is approximately
1157920892373161954235709850086879078528375642790749
0438260516314151816149433711579208923731619542357098
5008687907852837564279074904382605163141518161494337.
• “n” is the order of a point on the curve is the number of times the
point must be added to itself until it reaches the point at infinity.
Idea behind ECDSA
ECDSA
• Key Generation:
• Choose an Elliptic Curve:
– Select a specific elliptic curve over a finite field. The curve is
represented by the equation
– y2=x3+ax+b
– along with certain parameters.
• Select a Base Point:
– Choose a base point (G) on the elliptic curve.
• Generate a Private Key:
– Select a random integer (private key, d) from a specified range.
• Calculate the Public Key:
– Compute the public key (Q) by multiplying the base point (G) by the
private key (d):
– Q = d.G
ECDSA
• Signature Generation:
• Choose a Random Number:
– Select a random number (k) from a specified range.
• Calculate a Point (x, y) on the Curve:
– Compute the point (x, y)=k.G
• Calculate R (X-coordinate of the Point):
– R = x mod n, where n is the order of the base
point.
• Calculate S (Signature Component):
– S=(k−1.(H(m) + d.r)) mod n,
– Where H(m) is the hash of the message.
• The Signature is (R, S).
ECDSA
• Signature Verification:
• Receive Signature (R, S), Public Key Q, and the Message m.
• Check that R and S are within the valid range(not equal to zero).
• Calculate W (Multiplicative Inverse of S):
W=S−1 mod n.
• Calculate u1and u2:
u1=(H(m).w) mod n
u2=(R.w) mod n
• Calculate the Point (x, y) =u1.G + u2.Q
• Verify that R equals the X-coordinate of the resulting point:
R = = X mod n
– If true, the signature is valid; otherwise, it is invalid.
ECDSA
Example
private key =
1127575574181142035880934023364522067755657511792319
77388358956335153294300646
public key =
{ x:
338862860998134191820545952520423487421469509146083
22024530631065951421850289,
y:
952975295348788123369407826395340711622249963235929
8014255097182349749987176
}
Demo ECDSA
• https://
kjur.github.io/jsrsasign/sample/sample-ecdsa.h
tml
• https://learnmeabitcoin.com/technical/ecdsa
Hashing Algorithm
• A hashing algorithm is a mathematical function that takes an
input of any size (like a text, password, or file) and produces a
fixed-size output, called a hash value or message digest.
• It acts like a unique digital fingerprint for that input.
• It's one-way, meaning you can't reverse the process to get the
original input from the hash value.
• Key properties:
– Deterministic: Same input always yields the same hash
value.
– Fast to compute.
– Difficult to find two inputs that produce the same hash
value (collision resistance).
How it works
• Input: You feed any data (text, file, etc.) into the algorithm.
• Hash function: The algorithm applies mathematical
operations to scramble and condense the input.
• Hash value: A unique, fixed-size string of characters (the
fingerprint) is generated.
Common uses
• Data integrity: Ensure data hasn't been tampered with by
comparing hash values before and after transmission or
storage.
• Password storage: Securely store passwords without
storing them in plain text.
• Digital signatures: Verify the authenticity of digital
documents and messages.
• File identification: Quickly detect duplicate files or
malware.
• Block-chain technology: Essential for linking blocks of
data in a secure and tamper-proof manner.
Popular hashing algorithms
• MD5 (Message-Digest Algorithm 5)
• SHA-1 (Secure Hash Algorithm 1)
• SHA-256 (Secure Hash Algorithm 256)
• SHA-3 (Secure Hash Algorithm 3)
• RIPEMD-160 (RACE Integrity Primitives
Evaluation Message Digest)
SHA-256
SHA-256 stands for Secure Hash Algorithm 256-bit.
It's a widely used cryptographic hash function that
generates a unique 256-bit (32-byte) hash value for any
input data.
It's known for its security and collision resistance, making
it suitable for sensitive applications.
Key features
• Output size: 256-bit hash value (64 hexadecimal
characters)
• Collision resistance: Extremely difficult to find
two inputs that produce the same hash value
• Deterministic: Same input always yields the same
hash value
• Irreversible: Cannot recover the original input
from the hash value
• Fast: Efficient to compute
Use in Block-chain Technology
Requirement of SHA 256
How it works
• Padding: The input is padded with extra bits to
make its length a multiple of 512 bits
Parameters
Parameters
Mathematical Operations
w is Number of bits in a word.
Initial Hash Value
• For SHA-256, the initial hash value, H(0), shall consist of
the following eight 32-bit words, in hex:
H0(0) = 6a09e667
H1(0) = bb67ae85
H2(0) = 3c6ef372
H3(0) = a54ff53a
H4(0) = 510e527f
H5(0) = 9b05688c
H6(0) = 1f83d9ab
H7(0) = 5be0cd19
– These words were obtained by taking the first thirty-two bits of
the fractional parts of the square roots of the first eight prime
numbers.
Sixty Four 32-bit words
Padding
• Suppose that the length of the message, M, is L bits.
• Append the bit “1” to the end of the message, followed by k zero
bits, where k is the smallest, non-negative solution to the equation L
+ 1 + k ≡ 448 mod 512 .
• Then append the 64-bit block that is equal to the number L
expressed using a binary representation.
• For example, the (8-bit ASCII) message “abc” has length 8 × 3 =
24 , so the message is padded with a one bit, then 448 − (24 + 1) =
423 zero bits, and then the message length, to become the 512-bit
padded message.
Working Continue…..
• SHA-256 used to hash a message, M, having a length of L bits,
where 0 ≤ L < 264 .
• The algorithm uses
1. A message schedule of sixty-four 32-bit words.
2. Eight working variables of 32 bits each, and
3. A hash value of eight 32-bit words.
• The final result of SHA-256 is a 256-bit message digest.
• The words of the message schedule are labeled W0, W1,…, W63.
• The eight working variables are labeled a, b, c, d, e, f, g, and h.
• The words of the hash value are labeled H0(i) , H1(i) … H7(i), which
will hold the initial hash value.
• H(0), replaced by each successive intermediate hash value (after
each message block is processed), H(i) , and ending with the final
hash value, H(N).
• SHA256 also uses two temporary words, T1 and T2.
Working Continue…..
• Message blocks: The padded input is divided into 512-
bit blocks.
• Initialization: Eight 32-bit initial hash values (H0 to
H7) are set.
• Compression function: Each block is processed
through 64 rounds of mathematical operations
(including bit shifts, logical functions, and modular
additions) using the initial hash values and constant
values.
• Final hash: After processing all blocks, the final 256-bit
hash value is produced
Working Continue…..
• SHA-256 both use six logical functions, where each
function operates on 32-bit words, which are represented as
x, y, and z. The result of each function is a new 32-bit word