132
Introduction to Blockchain Lecture 1: RSA, SHA and Digital Signatures Ras Dwivedi IIT Kanpur May 21, 2018 Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 1 / 23

Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

Introduction to BlockchainLecture 1: RSA, SHA and Digital Signatures

Ras Dwivedi

IIT Kanpur

May 21, 2018

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 1 / 23

Page 2: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

Outline

1 Introduction

2 Cryptography

3 RSA

4 HASH function

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 2 / 23

Page 3: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

Introduction

Outline

1 Introduction

2 Cryptography

3 RSA

4 HASH function

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 3 / 23

Page 4: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

Introduction

Course Logistic

Week 1 ( 21st May to 25th May)

BlockchainWeek 2 ( 28st May to 1st June)

Software SecurityAttendance: Compulsory

Passing this course requires satisfactory number of classes to beattended

Quiz:1 on 1st JuneWould have questions from both the sectionDuration: About 30 minsMandatory to pass the quiz

AssignmentWould not be gradedjust for practice

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 4 / 23

Page 5: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

Introduction

Course Logistic

Week 1 ( 21st May to 25th May)Blockchain

Week 2 ( 28st May to 1st June)Software Security

Attendance: CompulsoryPassing this course requires satisfactory number of classes to beattended

Quiz:1 on 1st JuneWould have questions from both the sectionDuration: About 30 minsMandatory to pass the quiz

AssignmentWould not be gradedjust for practice

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 4 / 23

Page 6: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

Introduction

Course Logistic

Week 1 ( 21st May to 25th May)Blockchain

Week 2 ( 28st May to 1st June)

Software SecurityAttendance: Compulsory

Passing this course requires satisfactory number of classes to beattended

Quiz:1 on 1st JuneWould have questions from both the sectionDuration: About 30 minsMandatory to pass the quiz

AssignmentWould not be gradedjust for practice

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 4 / 23

Page 7: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

Introduction

Course Logistic

Week 1 ( 21st May to 25th May)Blockchain

Week 2 ( 28st May to 1st June)Software Security

Attendance: CompulsoryPassing this course requires satisfactory number of classes to beattended

Quiz:1 on 1st JuneWould have questions from both the sectionDuration: About 30 minsMandatory to pass the quiz

AssignmentWould not be gradedjust for practice

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 4 / 23

Page 8: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

Introduction

Course Logistic

Week 1 ( 21st May to 25th May)Blockchain

Week 2 ( 28st May to 1st June)Software Security

Attendance: Compulsory

Passing this course requires satisfactory number of classes to beattended

Quiz:1 on 1st JuneWould have questions from both the sectionDuration: About 30 minsMandatory to pass the quiz

AssignmentWould not be gradedjust for practice

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 4 / 23

Page 9: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

Introduction

Course Logistic

Week 1 ( 21st May to 25th May)Blockchain

Week 2 ( 28st May to 1st June)Software Security

Attendance: CompulsoryPassing this course requires satisfactory number of classes to beattended

Quiz:1 on 1st JuneWould have questions from both the sectionDuration: About 30 minsMandatory to pass the quiz

AssignmentWould not be gradedjust for practice

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 4 / 23

Page 10: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

Introduction

Course Logistic

Week 1 ( 21st May to 25th May)Blockchain

Week 2 ( 28st May to 1st June)Software Security

Attendance: CompulsoryPassing this course requires satisfactory number of classes to beattended

Quiz:

1 on 1st JuneWould have questions from both the sectionDuration: About 30 minsMandatory to pass the quiz

AssignmentWould not be gradedjust for practice

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 4 / 23

Page 11: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

Introduction

Course Logistic

Week 1 ( 21st May to 25th May)Blockchain

Week 2 ( 28st May to 1st June)Software Security

Attendance: CompulsoryPassing this course requires satisfactory number of classes to beattended

Quiz:1 on 1st June

Would have questions from both the sectionDuration: About 30 minsMandatory to pass the quiz

AssignmentWould not be gradedjust for practice

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 4 / 23

Page 12: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

Introduction

Course Logistic

Week 1 ( 21st May to 25th May)Blockchain

Week 2 ( 28st May to 1st June)Software Security

Attendance: CompulsoryPassing this course requires satisfactory number of classes to beattended

Quiz:1 on 1st JuneWould have questions from both the section

Duration: About 30 minsMandatory to pass the quiz

AssignmentWould not be gradedjust for practice

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 4 / 23

Page 13: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

Introduction

Course Logistic

Week 1 ( 21st May to 25th May)Blockchain

Week 2 ( 28st May to 1st June)Software Security

Attendance: CompulsoryPassing this course requires satisfactory number of classes to beattended

Quiz:1 on 1st JuneWould have questions from both the sectionDuration: About 30 mins

Mandatory to pass the quizAssignment

Would not be gradedjust for practice

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 4 / 23

Page 14: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

Introduction

Course Logistic

Week 1 ( 21st May to 25th May)Blockchain

Week 2 ( 28st May to 1st June)Software Security

Attendance: CompulsoryPassing this course requires satisfactory number of classes to beattended

Quiz:1 on 1st JuneWould have questions from both the sectionDuration: About 30 minsMandatory to pass the quiz

AssignmentWould not be gradedjust for practice

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 4 / 23

Page 15: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

Introduction

Course Logistic

Week 1 ( 21st May to 25th May)Blockchain

Week 2 ( 28st May to 1st June)Software Security

Attendance: CompulsoryPassing this course requires satisfactory number of classes to beattended

Quiz:1 on 1st JuneWould have questions from both the sectionDuration: About 30 minsMandatory to pass the quiz

Assignment

Would not be gradedjust for practice

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 4 / 23

Page 16: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

Introduction

Course Logistic

Week 1 ( 21st May to 25th May)Blockchain

Week 2 ( 28st May to 1st June)Software Security

Attendance: CompulsoryPassing this course requires satisfactory number of classes to beattended

Quiz:1 on 1st JuneWould have questions from both the sectionDuration: About 30 minsMandatory to pass the quiz

AssignmentWould not be graded

just for practice

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 4 / 23

Page 17: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

Introduction

Course Logistic

Week 1 ( 21st May to 25th May)Blockchain

Week 2 ( 28st May to 1st June)Software Security

Attendance: CompulsoryPassing this course requires satisfactory number of classes to beattended

Quiz:1 on 1st JuneWould have questions from both the sectionDuration: About 30 minsMandatory to pass the quiz

AssignmentWould not be gradedjust for practice

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 4 / 23

Page 18: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

Introduction

Course Logistic

Week 1 ( 21st May to 25th May)Blockchain

Week 2 ( 28st May to 1st June)Software Security

Attendance: CompulsoryPassing this course requires satisfactory number of classes to beattended

Quiz:1 on 1st JuneWould have questions from both the sectionDuration: About 30 minsMandatory to pass the quiz

AssignmentWould not be gradedjust for practice

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 4 / 23

Page 19: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

Introduction

Blockchain

RSA, SHA and Digital SignaturesIntroduction to Cryptocurrency and BitcoinIntroduction to Ethereum and MistHands on Mist and GethByzantine General Problem

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 5 / 23

Page 20: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

Introduction

Blockchain

RSA, SHA and Digital Signatures

Introduction to Cryptocurrency and BitcoinIntroduction to Ethereum and MistHands on Mist and GethByzantine General Problem

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 5 / 23

Page 21: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

Introduction

Blockchain

RSA, SHA and Digital SignaturesIntroduction to Cryptocurrency and Bitcoin

Introduction to Ethereum and MistHands on Mist and GethByzantine General Problem

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 5 / 23

Page 22: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

Introduction

Blockchain

RSA, SHA and Digital SignaturesIntroduction to Cryptocurrency and BitcoinIntroduction to Ethereum and Mist

Hands on Mist and GethByzantine General Problem

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 5 / 23

Page 23: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

Introduction

Blockchain

RSA, SHA and Digital SignaturesIntroduction to Cryptocurrency and BitcoinIntroduction to Ethereum and MistHands on Mist and Geth

Byzantine General Problem

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 5 / 23

Page 24: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

Introduction

Blockchain

RSA, SHA and Digital SignaturesIntroduction to Cryptocurrency and BitcoinIntroduction to Ethereum and MistHands on Mist and GethByzantine General Problem

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 5 / 23

Page 25: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

Introduction

Blockchain

RSA, SHA and Digital SignaturesIntroduction to Cryptocurrency and BitcoinIntroduction to Ethereum and MistHands on Mist and GethByzantine General Problem

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 5 / 23

Page 26: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

Cryptography

Outline

1 Introduction

2 Cryptography

3 RSA

4 HASH function

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 6 / 23

Page 27: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

Cryptography

Cryptography

Figure:Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 7 / 23

Page 28: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

Cryptography

Cesar Cipher

Figure: Cesar Cipher!!

RAS − > UDVRas Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 8 / 23

Page 29: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

Cryptography

Symmetric key Cryptography

Figure:Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 9 / 23

Page 30: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

Cryptography

Public key cryptography

Figure:Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 10 / 23

Page 31: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

Outline

1 Introduction

2 Cryptography

3 RSA

4 HASH function

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 11 / 23

Page 32: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

Factoring is hard

6 = 2× 3Convince yourself that factoring is hard!!100 = 10× 10 = 2× 2× 5× 5299 = 13× 23437 = 19× 23589 = 19× 31So how to use it?

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 12 / 23

Page 33: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

Factoring is hard

6 = 2× 3

Convince yourself that factoring is hard!!100 = 10× 10 = 2× 2× 5× 5299 = 13× 23437 = 19× 23589 = 19× 31So how to use it?

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 12 / 23

Page 34: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

Factoring is hard

6 = 2× 3Convince yourself that factoring is hard!!

100 = 10× 10 = 2× 2× 5× 5299 = 13× 23437 = 19× 23589 = 19× 31So how to use it?

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 12 / 23

Page 35: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

Factoring is hard

6 = 2× 3Convince yourself that factoring is hard!!100 =

10× 10 = 2× 2× 5× 5299 = 13× 23437 = 19× 23589 = 19× 31So how to use it?

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 12 / 23

Page 36: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

Factoring is hard

6 = 2× 3Convince yourself that factoring is hard!!100 = 10× 10 = 2× 2× 5× 5

299 = 13× 23437 = 19× 23589 = 19× 31So how to use it?

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 12 / 23

Page 37: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

Factoring is hard

6 = 2× 3Convince yourself that factoring is hard!!100 = 10× 10 = 2× 2× 5× 5299 =

13× 23437 = 19× 23589 = 19× 31So how to use it?

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 12 / 23

Page 38: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

Factoring is hard

6 = 2× 3Convince yourself that factoring is hard!!100 = 10× 10 = 2× 2× 5× 5299 = 13× 23

437 = 19× 23589 = 19× 31So how to use it?

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 12 / 23

Page 39: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

Factoring is hard

6 = 2× 3Convince yourself that factoring is hard!!100 = 10× 10 = 2× 2× 5× 5299 = 13× 23437 =

19× 23589 = 19× 31So how to use it?

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 12 / 23

Page 40: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

Factoring is hard

6 = 2× 3Convince yourself that factoring is hard!!100 = 10× 10 = 2× 2× 5× 5299 = 13× 23437 = 19× 23

589 = 19× 31So how to use it?

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 12 / 23

Page 41: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

Factoring is hard

6 = 2× 3Convince yourself that factoring is hard!!100 = 10× 10 = 2× 2× 5× 5299 = 13× 23437 = 19× 23589 = 19× 31So how to use it?

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 12 / 23

Page 42: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

Fermat’s little theorem

ap−1 = 1 modulo p

p is primeExample24 %5 = 16%5 = 1410 %11= 1048576%11 = 1

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 13 / 23

Page 43: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

Fermat’s little theorem

ap−1 = 1 modulo pp is prime

Example24 %5 = 16%5 = 1410 %11= 1048576%11 = 1

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 13 / 23

Page 44: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

Fermat’s little theorem

ap−1 = 1 modulo pp is primeExample24 %5 =

16%5 = 1410 %11= 1048576%11 = 1

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 13 / 23

Page 45: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

Fermat’s little theorem

ap−1 = 1 modulo pp is primeExample24 %5 = 16%5 = 1

410 %11= 1048576%11 = 1

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 13 / 23

Page 46: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

Fermat’s little theorem

ap−1 = 1 modulo pp is primeExample24 %5 = 16%5 = 1410 %11

= 1048576%11 = 1

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 13 / 23

Page 47: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

Fermat’s little theorem

ap−1 = 1 modulo pp is primeExample24 %5 = 16%5 = 1410 %11= 1048576%11 = 1

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 13 / 23

Page 48: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA

proposed by Rivest,Shamir,Adlemanchoose two large distinct prime number p, qcalculate n = pqcalculate φ = lcm(p − 1, q − 1)choose e such that gcd(e, φ) = 1calculate d such that d = e−1modφ −→ e × d = 1 mod φ

Idea: me×d = med = m modulo nencryption: c = me mod ndecryption: p = cd mod n

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 14 / 23

Page 49: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA

proposed by Rivest,Shamir,Adleman

choose two large distinct prime number p, qcalculate n = pqcalculate φ = lcm(p − 1, q − 1)choose e such that gcd(e, φ) = 1calculate d such that d = e−1modφ −→ e × d = 1 mod φ

Idea: me×d = med = m modulo nencryption: c = me mod ndecryption: p = cd mod n

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 14 / 23

Page 50: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA

proposed by Rivest,Shamir,Adlemanchoose two large distinct prime number p, q

calculate n = pqcalculate φ = lcm(p − 1, q − 1)choose e such that gcd(e, φ) = 1calculate d such that d = e−1modφ −→ e × d = 1 mod φ

Idea: me×d = med = m modulo nencryption: c = me mod ndecryption: p = cd mod n

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 14 / 23

Page 51: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA

proposed by Rivest,Shamir,Adlemanchoose two large distinct prime number p, qcalculate n = pq

calculate φ = lcm(p − 1, q − 1)choose e such that gcd(e, φ) = 1calculate d such that d = e−1modφ −→ e × d = 1 mod φ

Idea: me×d = med = m modulo nencryption: c = me mod ndecryption: p = cd mod n

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 14 / 23

Page 52: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA

proposed by Rivest,Shamir,Adlemanchoose two large distinct prime number p, qcalculate n = pqcalculate φ = lcm(p − 1, q − 1)

choose e such that gcd(e, φ) = 1calculate d such that d = e−1modφ −→ e × d = 1 mod φ

Idea: me×d = med = m modulo nencryption: c = me mod ndecryption: p = cd mod n

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 14 / 23

Page 53: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA

proposed by Rivest,Shamir,Adlemanchoose two large distinct prime number p, qcalculate n = pqcalculate φ = lcm(p − 1, q − 1)choose e such that gcd(e, φ) = 1

calculate d such that d = e−1modφ −→ e × d = 1 mod φ

Idea: me×d = med = m modulo nencryption: c = me mod ndecryption: p = cd mod n

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 14 / 23

Page 54: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA

proposed by Rivest,Shamir,Adlemanchoose two large distinct prime number p, qcalculate n = pqcalculate φ = lcm(p − 1, q − 1)choose e such that gcd(e, φ) = 1calculate d such that d = e−1modφ

−→ e × d = 1 mod φ

Idea: me×d = med = m modulo nencryption: c = me mod ndecryption: p = cd mod n

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 14 / 23

Page 55: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA

proposed by Rivest,Shamir,Adlemanchoose two large distinct prime number p, qcalculate n = pqcalculate φ = lcm(p − 1, q − 1)choose e such that gcd(e, φ) = 1calculate d such that d = e−1modφ −→ e × d = 1 mod φ

Idea: me×d = med = m modulo nencryption: c = me mod ndecryption: p = cd mod n

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 14 / 23

Page 56: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA

proposed by Rivest,Shamir,Adlemanchoose two large distinct prime number p, qcalculate n = pqcalculate φ = lcm(p − 1, q − 1)choose e such that gcd(e, φ) = 1calculate d such that d = e−1modφ −→ e × d = 1 mod φ

Idea: me×d = med = m modulo n

encryption: c = me mod ndecryption: p = cd mod n

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 14 / 23

Page 57: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA

proposed by Rivest,Shamir,Adlemanchoose two large distinct prime number p, qcalculate n = pqcalculate φ = lcm(p − 1, q − 1)choose e such that gcd(e, φ) = 1calculate d such that d = e−1modφ −→ e × d = 1 mod φ

Idea: me×d = med = m modulo nencryption: c = me mod n

decryption: p = cd mod n

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 14 / 23

Page 58: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA

proposed by Rivest,Shamir,Adlemanchoose two large distinct prime number p, qcalculate n = pqcalculate φ = lcm(p − 1, q − 1)choose e such that gcd(e, φ) = 1calculate d such that d = e−1modφ −→ e × d = 1 mod φ

Idea: me×d = med = m modulo nencryption: c = me mod ndecryption: p = cd mod n

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 14 / 23

Page 59: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA

proposed by Rivest,Shamir,Adlemanchoose two large distinct prime number p, qcalculate n = pqcalculate φ = lcm(p − 1, q − 1)choose e such that gcd(e, φ) = 1calculate d such that d = e−1modφ −→ e × d = 1 mod φ

Idea: me×d = med = m modulo nencryption: c = me mod ndecryption: p = cd mod n

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 14 / 23

Page 60: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 5,

q = 7 p × q = 35p − 1 = 4 , q − 1 = 6 , φ = 24Oops! φ = 12, but 24 would still worke = 11 ,d = 11e × d = 12124× 5 = 120

121% 24 =1m = 2c = me mod n= 211 mod 35c = 2048 mod 35 ; c = 18 (35× 58 = 2030)Decryptiond = 11 , c = 18m = cd mod nm = 1811 mod 35= 64268410079232%35m = 2

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 15 / 23

Page 61: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 5, q = 7

p × q = 35p − 1 = 4 , q − 1 = 6 , φ = 24Oops! φ = 12, but 24 would still worke = 11 ,d = 11e × d = 12124× 5 = 120

121% 24 =1m = 2c = me mod n= 211 mod 35c = 2048 mod 35 ; c = 18 (35× 58 = 2030)Decryptiond = 11 , c = 18m = cd mod nm = 1811 mod 35= 64268410079232%35m = 2

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 15 / 23

Page 62: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 5, q = 7 p × q = 35

p − 1 = 4 , q − 1 = 6 , φ = 24Oops! φ = 12, but 24 would still worke = 11 ,d = 11e × d = 12124× 5 = 120

121% 24 =1m = 2c = me mod n= 211 mod 35c = 2048 mod 35 ; c = 18 (35× 58 = 2030)Decryptiond = 11 , c = 18m = cd mod nm = 1811 mod 35= 64268410079232%35m = 2

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 15 / 23

Page 63: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 5, q = 7 p × q = 35p − 1 = 4

, q − 1 = 6 , φ = 24Oops! φ = 12, but 24 would still worke = 11 ,d = 11e × d = 12124× 5 = 120

121% 24 =1m = 2c = me mod n= 211 mod 35c = 2048 mod 35 ; c = 18 (35× 58 = 2030)Decryptiond = 11 , c = 18m = cd mod nm = 1811 mod 35= 64268410079232%35m = 2

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 15 / 23

Page 64: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 5, q = 7 p × q = 35p − 1 = 4 , q − 1 = 6

, φ = 24Oops! φ = 12, but 24 would still worke = 11 ,d = 11e × d = 12124× 5 = 120

121% 24 =1m = 2c = me mod n= 211 mod 35c = 2048 mod 35 ; c = 18 (35× 58 = 2030)Decryptiond = 11 , c = 18m = cd mod nm = 1811 mod 35= 64268410079232%35m = 2

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 15 / 23

Page 65: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 5, q = 7 p × q = 35p − 1 = 4 , q − 1 = 6 , φ = 24

Oops! φ = 12, but 24 would still worke = 11 ,d = 11e × d = 12124× 5 = 120

121% 24 =1m = 2c = me mod n= 211 mod 35c = 2048 mod 35 ; c = 18 (35× 58 = 2030)Decryptiond = 11 , c = 18m = cd mod nm = 1811 mod 35= 64268410079232%35m = 2

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 15 / 23

Page 66: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 5, q = 7 p × q = 35p − 1 = 4 , q − 1 = 6 , φ = 24Oops! φ = 12, but 24 would still worke = 11

,d = 11e × d = 12124× 5 = 120

121% 24 =1m = 2c = me mod n= 211 mod 35c = 2048 mod 35 ; c = 18 (35× 58 = 2030)Decryptiond = 11 , c = 18m = cd mod nm = 1811 mod 35= 64268410079232%35m = 2

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 15 / 23

Page 67: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 5, q = 7 p × q = 35p − 1 = 4 , q − 1 = 6 , φ = 24Oops! φ = 12, but 24 would still worke = 11 ,d =

11e × d = 12124× 5 = 120

121% 24 =1m = 2c = me mod n= 211 mod 35c = 2048 mod 35 ; c = 18 (35× 58 = 2030)Decryptiond = 11 , c = 18m = cd mod nm = 1811 mod 35= 64268410079232%35m = 2

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 15 / 23

Page 68: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 5, q = 7 p × q = 35p − 1 = 4 , q − 1 = 6 , φ = 24Oops! φ = 12, but 24 would still worke = 11 ,d = 11e × d = 121

24× 5 = 120121% 24 =1m = 2c = me mod n= 211 mod 35c = 2048 mod 35 ; c = 18 (35× 58 = 2030)Decryptiond = 11 , c = 18m = cd mod nm = 1811 mod 35= 64268410079232%35m = 2

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 15 / 23

Page 69: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 5, q = 7 p × q = 35p − 1 = 4 , q − 1 = 6 , φ = 24Oops! φ = 12, but 24 would still worke = 11 ,d = 11e × d = 121

24× 5 = 120121% 24 =1m = 2c = me mod n= 211 mod 35c = 2048 mod 35 ; c = 18 (35× 58 = 2030)Decryptiond = 11 , c = 18m = cd mod nm = 1811 mod 35= 64268410079232%35m = 2

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 15 / 23

Page 70: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 5, q = 7 p × q = 35p − 1 = 4 , q − 1 = 6 , φ = 24Oops! φ = 12, but 24 would still worke = 11 ,d = 11e × d = 12124× 5 = 120

121% 24 =1

m = 2c = me mod n= 211 mod 35c = 2048 mod 35 ; c = 18 (35× 58 = 2030)Decryptiond = 11 , c = 18m = cd mod nm = 1811 mod 35= 64268410079232%35m = 2

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 15 / 23

Page 71: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 5, q = 7 p × q = 35p − 1 = 4 , q − 1 = 6 , φ = 24Oops! φ = 12, but 24 would still worke = 11 ,d = 11e × d = 12124× 5 = 120

121% 24 =1m = 2

c = me mod n= 211 mod 35c = 2048 mod 35 ; c = 18 (35× 58 = 2030)Decryptiond = 11 , c = 18m = cd mod nm = 1811 mod 35= 64268410079232%35m = 2

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 15 / 23

Page 72: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 5, q = 7 p × q = 35p − 1 = 4 , q − 1 = 6 , φ = 24Oops! φ = 12, but 24 would still worke = 11 ,d = 11e × d = 12124× 5 = 120

121% 24 =1m = 2c = me mod n

= 211 mod 35c = 2048 mod 35 ; c = 18 (35× 58 = 2030)Decryptiond = 11 , c = 18m = cd mod nm = 1811 mod 35= 64268410079232%35m = 2

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 15 / 23

Page 73: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 5, q = 7 p × q = 35p − 1 = 4 , q − 1 = 6 , φ = 24Oops! φ = 12, but 24 would still worke = 11 ,d = 11e × d = 12124× 5 = 120

121% 24 =1m = 2c = me mod n= 211 mod 35c = 2048 mod 35

; c = 18 (35× 58 = 2030)Decryptiond = 11 , c = 18m = cd mod nm = 1811 mod 35= 64268410079232%35m = 2

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 15 / 23

Page 74: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 5, q = 7 p × q = 35p − 1 = 4 , q − 1 = 6 , φ = 24Oops! φ = 12, but 24 would still worke = 11 ,d = 11e × d = 12124× 5 = 120

121% 24 =1m = 2c = me mod n= 211 mod 35c = 2048 mod 35 ; c = 18

(35× 58 = 2030)Decryptiond = 11 , c = 18m = cd mod nm = 1811 mod 35= 64268410079232%35m = 2

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 15 / 23

Page 75: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 5, q = 7 p × q = 35p − 1 = 4 , q − 1 = 6 , φ = 24Oops! φ = 12, but 24 would still worke = 11 ,d = 11e × d = 12124× 5 = 120

121% 24 =1m = 2c = me mod n= 211 mod 35c = 2048 mod 35 ; c = 18 (35× 58 = 2030)Decryptiond = 11

, c = 18m = cd mod nm = 1811 mod 35= 64268410079232%35m = 2

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 15 / 23

Page 76: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 5, q = 7 p × q = 35p − 1 = 4 , q − 1 = 6 , φ = 24Oops! φ = 12, but 24 would still worke = 11 ,d = 11e × d = 12124× 5 = 120

121% 24 =1m = 2c = me mod n= 211 mod 35c = 2048 mod 35 ; c = 18 (35× 58 = 2030)Decryptiond = 11 , c = 18

m = cd mod nm = 1811 mod 35= 64268410079232%35m = 2

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 15 / 23

Page 77: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 5, q = 7 p × q = 35p − 1 = 4 , q − 1 = 6 , φ = 24Oops! φ = 12, but 24 would still worke = 11 ,d = 11e × d = 12124× 5 = 120

121% 24 =1m = 2c = me mod n= 211 mod 35c = 2048 mod 35 ; c = 18 (35× 58 = 2030)Decryptiond = 11 , c = 18m = cd mod n

m = 1811 mod 35= 64268410079232%35m = 2

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 15 / 23

Page 78: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 5, q = 7 p × q = 35p − 1 = 4 , q − 1 = 6 , φ = 24Oops! φ = 12, but 24 would still worke = 11 ,d = 11e × d = 12124× 5 = 120

121% 24 =1m = 2c = me mod n= 211 mod 35c = 2048 mod 35 ; c = 18 (35× 58 = 2030)Decryptiond = 11 , c = 18m = cd mod nm = 1811 mod 35= 64268410079232%35

m = 2

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 15 / 23

Page 79: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 5, q = 7 p × q = 35p − 1 = 4 , q − 1 = 6 , φ = 24Oops! φ = 12, but 24 would still worke = 11 ,d = 11e × d = 12124× 5 = 120

121% 24 =1m = 2c = me mod n= 211 mod 35c = 2048 mod 35 ; c = 18 (35× 58 = 2030)Decryptiond = 11 , c = 18m = cd mod nm = 1811 mod 35= 64268410079232%35m = 2Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 15 / 23

Page 80: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 5, q = 7 p × q = 35p − 1 = 4 , q − 1 = 6 , φ = 24Oops! φ = 12, but 24 would still worke = 11 ,d = 11e × d = 12124× 5 = 120

121% 24 =1m = 2c = me mod n= 211 mod 35c = 2048 mod 35 ; c = 18 (35× 58 = 2030)Decryptiond = 11 , c = 18m = cd mod nm = 1811 mod 35= 64268410079232%35m = 2Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 15 / 23

Page 81: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 7,

q = 13 p × q = 91p − 1 = 6 , q − 1 = 12 , φ = 72Oops! φ = 12, but 72 would still worke = 5 ,d = 2972× 2 = 1445× 29 = 145(145)%72 == 1m = 15 c = me mod n= 155 mod 91c = 759375 mod 91 ; c = 71 Decryptiond = 47 , c = 71m = cd mod nm = 7129 mod 91=485838707624806667708811381704053376792688975925323431%91m = 15

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 16 / 23

Page 82: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 7, q = 13

p × q = 91p − 1 = 6 , q − 1 = 12 , φ = 72Oops! φ = 12, but 72 would still worke = 5 ,d = 2972× 2 = 1445× 29 = 145(145)%72 == 1m = 15 c = me mod n= 155 mod 91c = 759375 mod 91 ; c = 71 Decryptiond = 47 , c = 71m = cd mod nm = 7129 mod 91=485838707624806667708811381704053376792688975925323431%91m = 15

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 16 / 23

Page 83: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 7, q = 13 p × q = 91

p − 1 = 6 , q − 1 = 12 , φ = 72Oops! φ = 12, but 72 would still worke = 5 ,d = 2972× 2 = 1445× 29 = 145(145)%72 == 1m = 15 c = me mod n= 155 mod 91c = 759375 mod 91 ; c = 71 Decryptiond = 47 , c = 71m = cd mod nm = 7129 mod 91=485838707624806667708811381704053376792688975925323431%91m = 15

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 16 / 23

Page 84: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 7, q = 13 p × q = 91p − 1 = 6

, q − 1 = 12 , φ = 72Oops! φ = 12, but 72 would still worke = 5 ,d = 2972× 2 = 1445× 29 = 145(145)%72 == 1m = 15 c = me mod n= 155 mod 91c = 759375 mod 91 ; c = 71 Decryptiond = 47 , c = 71m = cd mod nm = 7129 mod 91=485838707624806667708811381704053376792688975925323431%91m = 15

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 16 / 23

Page 85: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 7, q = 13 p × q = 91p − 1 = 6 , q − 1 = 12

, φ = 72Oops! φ = 12, but 72 would still worke = 5 ,d = 2972× 2 = 1445× 29 = 145(145)%72 == 1m = 15 c = me mod n= 155 mod 91c = 759375 mod 91 ; c = 71 Decryptiond = 47 , c = 71m = cd mod nm = 7129 mod 91=485838707624806667708811381704053376792688975925323431%91m = 15

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 16 / 23

Page 86: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 7, q = 13 p × q = 91p − 1 = 6 , q − 1 = 12 , φ = 72Oops! φ = 12, but 72 would still worke = 5

,d = 2972× 2 = 1445× 29 = 145(145)%72 == 1m = 15 c = me mod n= 155 mod 91c = 759375 mod 91 ; c = 71 Decryptiond = 47 , c = 71m = cd mod nm = 7129 mod 91=485838707624806667708811381704053376792688975925323431%91m = 15

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 16 / 23

Page 87: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 7, q = 13 p × q = 91p − 1 = 6 , q − 1 = 12 , φ = 72Oops! φ = 12, but 72 would still worke = 5 ,d =

2972× 2 = 1445× 29 = 145(145)%72 == 1m = 15 c = me mod n= 155 mod 91c = 759375 mod 91 ; c = 71 Decryptiond = 47 , c = 71m = cd mod nm = 7129 mod 91=485838707624806667708811381704053376792688975925323431%91m = 15

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 16 / 23

Page 88: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 7, q = 13 p × q = 91p − 1 = 6 , q − 1 = 12 , φ = 72Oops! φ = 12, but 72 would still worke = 5 ,d = 29

72× 2 = 1445× 29 = 145(145)%72 == 1m = 15 c = me mod n= 155 mod 91c = 759375 mod 91 ; c = 71 Decryptiond = 47 , c = 71m = cd mod nm = 7129 mod 91=485838707624806667708811381704053376792688975925323431%91m = 15

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 16 / 23

Page 89: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 7, q = 13 p × q = 91p − 1 = 6 , q − 1 = 12 , φ = 72Oops! φ = 12, but 72 would still worke = 5 ,d = 2972× 2 = 1445× 29 = 145(145)%72 == 1

m = 15 c = me mod n= 155 mod 91c = 759375 mod 91 ; c = 71 Decryptiond = 47 , c = 71m = cd mod nm = 7129 mod 91=485838707624806667708811381704053376792688975925323431%91m = 15

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 16 / 23

Page 90: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 7, q = 13 p × q = 91p − 1 = 6 , q − 1 = 12 , φ = 72Oops! φ = 12, but 72 would still worke = 5 ,d = 2972× 2 = 1445× 29 = 145(145)%72 == 1m = 15

c = me mod n= 155 mod 91c = 759375 mod 91 ; c = 71 Decryptiond = 47 , c = 71m = cd mod nm = 7129 mod 91=485838707624806667708811381704053376792688975925323431%91m = 15

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 16 / 23

Page 91: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 7, q = 13 p × q = 91p − 1 = 6 , q − 1 = 12 , φ = 72Oops! φ = 12, but 72 would still worke = 5 ,d = 2972× 2 = 1445× 29 = 145(145)%72 == 1m = 15 c = me mod n

= 155 mod 91c = 759375 mod 91 ; c = 71 Decryptiond = 47 , c = 71m = cd mod nm = 7129 mod 91=485838707624806667708811381704053376792688975925323431%91m = 15

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 16 / 23

Page 92: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 7, q = 13 p × q = 91p − 1 = 6 , q − 1 = 12 , φ = 72Oops! φ = 12, but 72 would still worke = 5 ,d = 2972× 2 = 1445× 29 = 145(145)%72 == 1m = 15 c = me mod n= 155 mod 91c = 759375 mod 91

; c = 71 Decryptiond = 47 , c = 71m = cd mod nm = 7129 mod 91=485838707624806667708811381704053376792688975925323431%91m = 15

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 16 / 23

Page 93: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 7, q = 13 p × q = 91p − 1 = 6 , q − 1 = 12 , φ = 72Oops! φ = 12, but 72 would still worke = 5 ,d = 2972× 2 = 1445× 29 = 145(145)%72 == 1m = 15 c = me mod n= 155 mod 91c = 759375 mod 91 ; c = 71

Decryptiond = 47 , c = 71m = cd mod nm = 7129 mod 91=485838707624806667708811381704053376792688975925323431%91m = 15

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 16 / 23

Page 94: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 7, q = 13 p × q = 91p − 1 = 6 , q − 1 = 12 , φ = 72Oops! φ = 12, but 72 would still worke = 5 ,d = 2972× 2 = 1445× 29 = 145(145)%72 == 1m = 15 c = me mod n= 155 mod 91c = 759375 mod 91 ; c = 71 Decryptiond = 47

, c = 71m = cd mod nm = 7129 mod 91=485838707624806667708811381704053376792688975925323431%91m = 15

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 16 / 23

Page 95: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 7, q = 13 p × q = 91p − 1 = 6 , q − 1 = 12 , φ = 72Oops! φ = 12, but 72 would still worke = 5 ,d = 2972× 2 = 1445× 29 = 145(145)%72 == 1m = 15 c = me mod n= 155 mod 91c = 759375 mod 91 ; c = 71 Decryptiond = 47 , c = 71

m = cd mod nm = 7129 mod 91=485838707624806667708811381704053376792688975925323431%91m = 15

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 16 / 23

Page 96: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 7, q = 13 p × q = 91p − 1 = 6 , q − 1 = 12 , φ = 72Oops! φ = 12, but 72 would still worke = 5 ,d = 2972× 2 = 1445× 29 = 145(145)%72 == 1m = 15 c = me mod n= 155 mod 91c = 759375 mod 91 ; c = 71 Decryptiond = 47 , c = 71m = cd mod n

m = 7129 mod 91=485838707624806667708811381704053376792688975925323431%91m = 15

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 16 / 23

Page 97: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 7, q = 13 p × q = 91p − 1 = 6 , q − 1 = 12 , φ = 72Oops! φ = 12, but 72 would still worke = 5 ,d = 2972× 2 = 1445× 29 = 145(145)%72 == 1m = 15 c = me mod n= 155 mod 91c = 759375 mod 91 ; c = 71 Decryptiond = 47 , c = 71m = cd mod nm = 7129 mod 91=485838707624806667708811381704053376792688975925323431%91

m = 15

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 16 / 23

Page 98: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

RSA: Example

p = 7, q = 13 p × q = 91p − 1 = 6 , q − 1 = 12 , φ = 72Oops! φ = 12, but 72 would still worke = 5 ,d = 2972× 2 = 1445× 29 = 145(145)%72 == 1m = 15 c = me mod n= 155 mod 91c = 759375 mod 91 ; c = 71 Decryptiond = 47 , c = 71m = cd mod nm = 7129 mod 91=485838707624806667708811381704053376792688975925323431%91m = 15

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 16 / 23

Page 99: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

Digital signature Attempt 1

AIM: Convince everybody that Alice have signed the document

nobody should be able to forge the documentsimple pasting a copy of signature do not workIDEA: USE RSAfor document m Alice uses s = md as her digital signature. To verify,verifier calculates se and if m = se mod n, signature is genuined is called Alice’s secret key and e is called Alice’s Public key

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 17 / 23

Page 100: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

Digital signature Attempt 1

AIM: Convince everybody that Alice have signed the documentnobody should be able to forge the document

simple pasting a copy of signature do not workIDEA: USE RSAfor document m Alice uses s = md as her digital signature. To verify,verifier calculates se and if m = se mod n, signature is genuined is called Alice’s secret key and e is called Alice’s Public key

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 17 / 23

Page 101: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

Digital signature Attempt 1

AIM: Convince everybody that Alice have signed the documentnobody should be able to forge the documentsimple pasting a copy of signature do not work

IDEA: USE RSAfor document m Alice uses s = md as her digital signature. To verify,verifier calculates se and if m = se mod n, signature is genuined is called Alice’s secret key and e is called Alice’s Public key

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 17 / 23

Page 102: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

Digital signature Attempt 1

AIM: Convince everybody that Alice have signed the documentnobody should be able to forge the documentsimple pasting a copy of signature do not workIDEA: USE RSA

for document m Alice uses s = md as her digital signature. To verify,verifier calculates se and if m = se mod n, signature is genuined is called Alice’s secret key and e is called Alice’s Public key

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 17 / 23

Page 103: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

Digital signature Attempt 1

AIM: Convince everybody that Alice have signed the documentnobody should be able to forge the documentsimple pasting a copy of signature do not workIDEA: USE RSAfor document m Alice uses s = md as her digital signature. To verify,verifier calculates se and if m = se mod n, signature is genuine

d is called Alice’s secret key and e is called Alice’s Public key

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 17 / 23

Page 104: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

Digital signature Attempt 1

AIM: Convince everybody that Alice have signed the documentnobody should be able to forge the documentsimple pasting a copy of signature do not workIDEA: USE RSAfor document m Alice uses s = md as her digital signature. To verify,verifier calculates se and if m = se mod n, signature is genuined is called Alice’s secret key and e is called Alice’s Public key

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 17 / 23

Page 105: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

Digital signature Attempt 1

AIM: Convince everybody that Alice have signed the documentnobody should be able to forge the documentsimple pasting a copy of signature do not workIDEA: USE RSAfor document m Alice uses s = md as her digital signature. To verify,verifier calculates se and if m = se mod n, signature is genuined is called Alice’s secret key and e is called Alice’s Public key

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 17 / 23

Page 106: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

Is the Scheme secure?

No!given (n, e) private key of Alice cannot be calculatedgiven document m, s = md could not be guessed.Problem: forging given m1,m2 as two document, and s1, s2 as theirdigital signature, one can find the valid signature of m1.m2 as s1.s2

Also the length of the signature is proportional to the size of thedocumentslow

What could we do now?

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 18 / 23

Page 107: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

Is the Scheme secure?

No!

given (n, e) private key of Alice cannot be calculatedgiven document m, s = md could not be guessed.Problem: forging given m1,m2 as two document, and s1, s2 as theirdigital signature, one can find the valid signature of m1.m2 as s1.s2

Also the length of the signature is proportional to the size of thedocumentslow

What could we do now?

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 18 / 23

Page 108: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

Is the Scheme secure?

No!given (n, e) private key of Alice cannot be calculated

given document m, s = md could not be guessed.Problem: forging given m1,m2 as two document, and s1, s2 as theirdigital signature, one can find the valid signature of m1.m2 as s1.s2

Also the length of the signature is proportional to the size of thedocumentslow

What could we do now?

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 18 / 23

Page 109: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

Is the Scheme secure?

No!given (n, e) private key of Alice cannot be calculatedgiven document m, s = md could not be guessed.

Problem: forging given m1,m2 as two document, and s1, s2 as theirdigital signature, one can find the valid signature of m1.m2 as s1.s2

Also the length of the signature is proportional to the size of thedocumentslow

What could we do now?

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 18 / 23

Page 110: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

Is the Scheme secure?

No!given (n, e) private key of Alice cannot be calculatedgiven document m, s = md could not be guessed.Problem: forging given m1,m2 as two document, and s1, s2 as theirdigital signature, one can find the valid signature of m1.m2 as s1.s2

Also the length of the signature is proportional to the size of thedocumentslow

What could we do now?

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 18 / 23

Page 111: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

Is the Scheme secure?

No!given (n, e) private key of Alice cannot be calculatedgiven document m, s = md could not be guessed.Problem: forging given m1,m2 as two document, and s1, s2 as theirdigital signature, one can find the valid signature of m1.m2 as s1.s2

Also the length of the signature is proportional to the size of thedocument

slowWhat could we do now?

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 18 / 23

Page 112: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

Is the Scheme secure?

No!given (n, e) private key of Alice cannot be calculatedgiven document m, s = md could not be guessed.Problem: forging given m1,m2 as two document, and s1, s2 as theirdigital signature, one can find the valid signature of m1.m2 as s1.s2

Also the length of the signature is proportional to the size of thedocumentslow

What could we do now?

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 18 / 23

Page 113: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

RSA

Is the Scheme secure?

No!given (n, e) private key of Alice cannot be calculatedgiven document m, s = md could not be guessed.Problem: forging given m1,m2 as two document, and s1, s2 as theirdigital signature, one can find the valid signature of m1.m2 as s1.s2

Also the length of the signature is proportional to the size of thedocumentslow

What could we do now?

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 18 / 23

Page 114: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

HASH function

Outline

1 Introduction

2 Cryptography

3 RSA

4 HASH function

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 19 / 23

Page 115: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

HASH function

SHA: Secure Hash Functions

An Ideal Hash function is one which has following propertiesgiven f (x) it is impossible to guess x

given x1 its is impossible to find x2 such that f (x1) = f (x2)it is impossible to find x1, x2, such that x1 6= x2 and f (x1) = f (x2)

Lets understand by example

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 20 / 23

Page 116: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

HASH function

SHA: Secure Hash Functions

An Ideal Hash function is one which has following propertiesgiven f (x) it is impossible to guess xgiven x1 its is impossible to find x2 such that f (x1) = f (x2)

it is impossible to find x1, x2, such that x1 6= x2 and f (x1) = f (x2)Lets understand by example

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 20 / 23

Page 117: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

HASH function

SHA: Secure Hash Functions

An Ideal Hash function is one which has following propertiesgiven f (x) it is impossible to guess xgiven x1 its is impossible to find x2 such that f (x1) = f (x2)it is impossible to find x1, x2, such that x1 6= x2 and f (x1) = f (x2)

Lets understand by example

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 20 / 23

Page 118: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

HASH function

SHA: Secure Hash Functions

An Ideal Hash function is one which has following propertiesgiven f (x) it is impossible to guess xgiven x1 its is impossible to find x2 such that f (x1) = f (x2)it is impossible to find x1, x2, such that x1 6= x2 and f (x1) = f (x2)

Lets understand by example

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 20 / 23

Page 119: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

HASH function

Example: Hash Function

Suppose I can see Future. So I can foretell score of tomorrow’s IPL’smatch.

But If I tell score before, you can always change it and prove mewrong. I publish Hash of tomorrow’s score as: ”a34728bfed78dc89...”

can you tell what score I had in Mind?can I later change the score I thought before?can I purposely find hash such that two score are possible for thathash ?

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 21 / 23

Page 120: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

HASH function

Example: Hash Function

Suppose I can see Future. So I can foretell score of tomorrow’s IPL’smatch. But If I tell score before, you can always change it and prove mewrong.

I publish Hash of tomorrow’s score as: ”a34728bfed78dc89...”can you tell what score I had in Mind?can I later change the score I thought before?can I purposely find hash such that two score are possible for thathash ?

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 21 / 23

Page 121: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

HASH function

Example: Hash Function

Suppose I can see Future. So I can foretell score of tomorrow’s IPL’smatch. But If I tell score before, you can always change it and prove mewrong. I publish Hash of tomorrow’s score as: ”a34728bfed78dc89...”

can you tell what score I had in Mind?can I later change the score I thought before?can I purposely find hash such that two score are possible for thathash ?

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 21 / 23

Page 122: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

HASH function

Example: Hash Function

Suppose I can see Future. So I can foretell score of tomorrow’s IPL’smatch. But If I tell score before, you can always change it and prove mewrong. I publish Hash of tomorrow’s score as: ”a34728bfed78dc89...”

can you tell what score I had in Mind?

can I later change the score I thought before?can I purposely find hash such that two score are possible for thathash ?

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 21 / 23

Page 123: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

HASH function

Example: Hash Function

Suppose I can see Future. So I can foretell score of tomorrow’s IPL’smatch. But If I tell score before, you can always change it and prove mewrong. I publish Hash of tomorrow’s score as: ”a34728bfed78dc89...”

can you tell what score I had in Mind?can I later change the score I thought before?

can I purposely find hash such that two score are possible for thathash ?

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 21 / 23

Page 124: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

HASH function

Example: Hash Function

Suppose I can see Future. So I can foretell score of tomorrow’s IPL’smatch. But If I tell score before, you can always change it and prove mewrong. I publish Hash of tomorrow’s score as: ”a34728bfed78dc89...”

can you tell what score I had in Mind?can I later change the score I thought before?can I purposely find hash such that two score are possible for thathash ?

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 21 / 23

Page 125: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

HASH function

Example: Hash Function

Suppose I can see Future. So I can foretell score of tomorrow’s IPL’smatch. But If I tell score before, you can always change it and prove mewrong. I publish Hash of tomorrow’s score as: ”a34728bfed78dc89...”

can you tell what score I had in Mind?can I later change the score I thought before?can I purposely find hash such that two score are possible for thathash ?

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 21 / 23

Page 126: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

HASH function

SHA: Secure Hash Functions

An Ideal Hash function is one which has following propertiesgiven f (x) it is impossible to guess xgiven x1 its is impossible to find x2 such that f (x1) = f (x2)it is impossible to find x1, x2, such that x1 6= x2 and f (x1) = f (x2)

Difference between 2nd and 3rd condition?

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 22 / 23

Page 127: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

HASH function

SHA: Secure Hash Functions

An Ideal Hash function is one which has following propertiesgiven f (x) it is impossible to guess xgiven x1 its is impossible to find x2 such that f (x1) = f (x2)it is impossible to find x1, x2, such that x1 6= x2 and f (x1) = f (x2)

Difference between 2nd and 3rd condition?

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 22 / 23

Page 128: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

HASH function

Merkle Demgrad Construction

Need of Padding message m?

m is prefix of PAD(m)if |m1| = |m2| then |PAD(m1)| = |PAD(m2)|if |m1| 6= |m2| then the last block of PAD(m1) 6= PAD(m2)

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 23 / 23

Page 129: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

HASH function

Merkle Demgrad Construction

Need of Padding message m?m is prefix of PAD(m)

if |m1| = |m2| then |PAD(m1)| = |PAD(m2)|if |m1| 6= |m2| then the last block of PAD(m1) 6= PAD(m2)

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 23 / 23

Page 130: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

HASH function

Merkle Demgrad Construction

Need of Padding message m?m is prefix of PAD(m)if |m1| = |m2| then |PAD(m1)| = |PAD(m2)|

if |m1| 6= |m2| then the last block of PAD(m1) 6= PAD(m2)

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 23 / 23

Page 131: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

HASH function

Merkle Demgrad Construction

Need of Padding message m?m is prefix of PAD(m)if |m1| = |m2| then |PAD(m1)| = |PAD(m2)|if |m1| 6= |m2| then the last block of PAD(m1) 6= PAD(m2)

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 23 / 23

Page 132: Introduction to Blockchain - Lecture 1: RSA, SHA and ... · Week 2 ( 28st May to 1st June) Software Security Attendance: Compulsory Passing this course requires satisfactory number

HASH function

Merkle Demgrad Construction

Need of Padding message m?m is prefix of PAD(m)if |m1| = |m2| then |PAD(m1)| = |PAD(m2)|if |m1| 6= |m2| then the last block of PAD(m1) 6= PAD(m2)

Ras Dwivedi (IIT Kanpur) Introduction to Blockchain May 21, 2018 23 / 23