Professional Documents
Culture Documents
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Cryptography
• Cryptography is the science of secret, or hidden writing
• It has two main Components:
1. Encryption
– Practice of hiding messages so that they can not be read by anyone
other than the intended recipient
2. Authentication
– Ensuring that users of data/resources are the persons they claim to be
and that a message has not been surreptitiously altered
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Symmetric-key cryptography
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Note
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
How DES works and Key Generation
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Introduction to Blockchain and distributed
ledger & 19CS3618
Department of Computer Science and
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Introduction to Blockchain and distributed
ledger & 19CS3618
Department of Computer Science and
Round Function of DES
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
DES
• In July 1998, DES was officially cracked by a machine
built by the EFF
– Total cost: under $250,000
– Total time: 6-8 months
• They then published the details of their approach,
which essentially was a brute force attack
• Note: 56 bits means 256 keys to try.
• Also, not as easy as just trying. What do you always
do to files before sending them somewhere?
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Modes of Operation
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Cipher Block chaining
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Cipher Feedback(CFB)
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Live Example
• https://www.tools4noobs.com.
• https://www.tools4noobs.com/online_tools/e
ncrypt/
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
3DES
• Effort to salvage DES
• Main algorithm: repeat DES 3 times with
different keys (so key size is now 168 bits)
• Still very secure - brute force attacks would
take too long, and that is the only way to
attack this algorithm
• Main problem: SLOW
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Advanced Encryption Standard
(AES)
• Designed in response to a call by NIST in 1998, and
officially adopted in 2001
• Block length is 128 bits, and keys can be 128, 192, or
256 bits.
• Essentially, proceeds in 4 rounds (which are
repeated):
– Substitute bytes
– Permute
– Mix columns
– Add round key
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Advanced Encryption Standard
• Block size –128 bit.
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Stage 1: substitute bytes
• AES computes a matrix which maps every 8-bit value
to a different 8-bit value.
• Computed using properties of finite fields (go take
some math classes to learn more about this).
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Stage 2: permute
• AES then shifts each row, where each row is shifted a
different amount.
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Stage 3: Mix columns
• Here, the 4 bytes in each column are
combined using a linear transformation
• Essentially, the output of any byte depends on
all the input bytes, so this “mixes” them
together
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Stage 4: Add round key
• Use XOR to combine the key with the message
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Expansion Keys
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Symmetric-key cryptography
• Advantages:
– Simple
– Faster
• Disadvantages:
– Key must exchanges in secure way
– Easy for hacker to get a key as it is passed in
unsecure way.
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Figure 30.4 Asymmetric-key cryptography
Advantages
1. More Secured
2. Authentication
Disadvantages
1. Relatively Complex
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Figure 30.6 Comparison between two categories of cryptography
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
How it WORKS…….?
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Key Points in Asymmetric Encryption
❖ The Public key(s) is distributed freely between the sender and receiver.
❖ The Private Key is only used for Decryption and will not be shared
between the sender and receiver.
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
What is Asymmetric Encryption
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Asymmetric Encryption Algorithms
❖RSA:
❖Digital Signature Algorithm:
❖Diffie-Helman:
❖ SHA, SHA-256:
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
RSA Algorithm
• Invented in 1978 by Ron Rivest, Adi Shamir and Leonard Adleman.
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
RSA Public Key Crypto System
Key generation:
Decryption
Given a ciphertext C, use private key (d)
Compute Cd mod n = (Me mod n)d mod n = Med mod n = M
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
C = Me mod (n=pq)
Plaintext: M Ciphertext: C
Cd mod n
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
RSA Example
• p = 11, q = 7, n = 77, (n) = 60
• d = 13, e = 37 (ed = 481; ed mod 60 = 1)
• Let M = 15. Then C Me mod n
– C 1537 (mod 77) = 71
• M Cd mod n
– M 7113 (mod 77) = 15
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
RSA Example 2
• Parameters:
– p = 3, q = 5, pq = 15
– (n) = ?
• Let e = 3, what is d?
• Given M=2, what is C?
• How to decrypt?
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
RSA Example
• p=11, q=19.
• p=7, q=13.
• p=17 q=11.
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Hash Functions
• Hashing algorithm is a hash function that creates unique finger print of
digital data from arbitrary size to a fixed size value.
• The values returned by a hash function are called hash values, hash codes,
digests or simply hashes.
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Hash Functions
Cryptographic hash functions are hash functions with additional
security requirements
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Usages of Cryptographic Hash Functions
• Software integrity
– E.g., tripwire
• Time stamping
– How to prove that you have discovered a secret on an
earlier date without disclosing it?
• Covered later
– Message authentication
– One-time passwords
– Digital signature
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Well Known Hash Functions
• MD5
– output 128 bits
– collision resistance completely broken by researchers in China in 2004
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Secure Hash Algorithm(SHA)
• Developed by NIST, Specified in the secure hash standard,
originally 1993.
2. Similar to SHA1.
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Merkle-Tree Construction for Hash Functions
• Message is divided into fixed-size blocks and padded.
• Uses a compression function f, which takes a chaining variable (of size of
hash output) and a message block, and outputs the next chaining variable.
• Final chaining variable is the hash value.
Merits:
❖ Two parties don't need to have their private keys already shared in order to
communicate using encryption.
❖ Authentication and Non-Repudiation are possible. (Authentication means that you can
encrypt the message with my public key and only I can decrypt it with my private key.
Non-repudiation means that you can "sign" the message with your private key and I can
verify that it came from you with your public key.)
De-Merits:
❖Asymmetric Encryption algorithms are comparatively complex.
❖Time consuming process for Encryption and Decryption.
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering
Introduction to Blockchain and distributed ledger & 19CS3618 Department of Computer Science and Engineering