17
Bitcoin, Blockcha in & CryptoCo ntracts Part 1 cryptographic fundamentals Prithwis Mukerjee, PhD, Praxis Business School, Calcutta, India

Bitcoin, Blockchain and the Crypto Contracts - Part 1

Embed Size (px)

Citation preview

Page 1: Bitcoin, Blockchain and the Crypto Contracts - Part 1

Bitcoin, Blockchai

n & CryptoCon

tractsPart 1

cryptographic fundamentals

Prithwis Mukerjee, PhD, Praxis Business School, Calcutta, India

Page 2: Bitcoin, Blockchain and the Crypto Contracts - Part 1

What is Cryptography ?Cryptography is a mathematical technique by which information in the form of text files or any digital string of numbers and characters are changed into another string so that the contents are not readily understandable by others.

It was originally used for keeping secrets but now it has many uses.

Page 3: Bitcoin, Blockchain and the Crypto Contracts - Part 1

Cryptographic FunctionsA cryptographic function is an operator that converts an input string of numbers and characters into an output string as per rules defined by the function and a key value

k=2, x+k

k=2, xk

k=2, Crypt()

anagram(2)

9 11

3 9

prithwis rtkvjyku

prithwis wish trip

Page 4: Bitcoin, Blockchain and the Crypto Contracts - Part 1

One Way FunctionsIn a one-way cryptographic function it is quite difficult to reverse the process. Difficult to derive the input by looking at the output

125 8sum of digits

40706 8sum of digits

prithwis mukerjee BODPM4264EPAN(:-)

prithwis mukerjee SHA-256 1b18b866382f05d8698ebcb8eae7c8811b3a988e7112503c1ecc9aacd9cc63e8

collision

Page 5: Bitcoin, Blockchain and the Crypto Contracts - Part 1

SHA-256 Hash FunctionGenerates 256 bit output irrespective of the size (or length) of input.

Collision resistant - two inputs will “never” generate the same output.

Hash(“prithwis”) 1b18b866382f05d8698ebcb8eae7c8811b3a988e7112503c1ecc9aacd9cc63e8

Hash(“prithwish”) 4486d9ef726a5a4a559f24cce58480968a4527004cfb7ceb8cf6fccbef2886bc

Hash(“Our price bid is Rs 2,00,000”) 62b72cda490d54e56ac0978d263906ef892b6449c1175ebf0af839c7f99e772f

Hash(pm.jpg) <- a full image file af9493c777bcb88e57fb3e08cf05807d117f945fdffc932f3deddcc82835b385

Page 6: Bitcoin, Blockchain and the Crypto Contracts - Part 1

Tamper-proof messagesIf we send the message along with its hash, then recipient can detect if the message has been altered later on

Communication Transmitted“Pay Rs 2,00,000 to Prithwis Mukerjee”Hash = 4949504ab01a4a8d4ebec5f38bd13a7ea2819a60d1004690a09b6aa518a02922

Communication Received“Pay Rs 20,00,000 to Prithwis Mukerjee”Hash = 4949504ab01a4a8d4ebec5f38bd13a7ea2819a60d1004690a09b6aa518a02922

Recipient Verifies Hash of message“Pay Rs 20,00,000 to Prithwis Mukerjee”Hash = 5331cf192a895d1b7cb8d0d5b1e78090aa8f33e1a781103ed4d9eab8282704a7

You can also send the hash of [message+hash of message] to make sure that the hash value has not been tampered with either!

Mismatch detected

Page 7: Bitcoin, Blockchain and the Crypto Contracts - Part 1

EncryptionHashing is irreversible. Encryption is reversible

It is a two step process of converting clear-text (human understandable) into cypher-text by sender and reconverting it back to clear-text by receiver using passphrases

Original Message in Clear Text secretKey

ENCRYPT function

Unreadable Message in Cypher Text

Unreadable Message in Cypher Text

DECRYPT function

Retrieved Message in Clear Text

secretKey

Page 8: Bitcoin, Blockchain and the Crypto Contracts - Part 1

Encryption for Privacy during TransmissionHere we see that Arup is sending a secret message to Bina and both of them do not want anybody else to read the message

Arup will meet Bina at 2PM at Victoria

p@ssw0rd

ENCRYPT

xyza erty 78s& a3 0w@ uTc99srt

xyza erty 78s& a3 0w@ uTc99srt

DECRYPT

Arup will meet Bina at 2PM at Victoria

p@ssw0rd

secure, private transmission

insecure transmissioncan be intercepted and used to break privacy

Page 9: Bitcoin, Blockchain and the Crypto Contracts - Part 1

Asymmetric Encryption & DecryptionTwo Keys

Encryption with one key, decryption with other.

Called Public key, Private Key

Clear Text MessageK2 K1

ENCRYPT

Cypher Text 1 Cypher Text 2K2

DECRYPT

K1 K1

ENCRYPT

K2

DECRYPT DECRYPT DECRYPT

Clear Text Message

Page 10: Bitcoin, Blockchain and the Crypto Contracts - Part 1

Asymmetric Encryption : PrivacyArup, Bina have a pair of keys, one Private Key and one Public Key

KPrA, KPrB are “private” keys and KPuA, KPuB are “public” keys of Arup and Bina

Arup will meet Bina at 2PM at Victoria

KPuAKPrA

Arup will meet Bina at 2PM at Victoria

KPuB

KPuB

ENCRYPT

xyza erty 78s& a3 0w@ uTc99srt

xyza erty 78s& a3 0w@ uTc99srt KPrB

DECRYPT

secure, private transmission

insecure transmissioncan be intercepted but cannot be used to break privacy

Page 11: Bitcoin, Blockchain and the Crypto Contracts - Part 1

Asymmetric Encryption : AuthenticationArup appends his encrypted public key as signature to message

Bina confirms that signature was created by person whose public key is same as that of Arup

Hence authentic

Arup loves BinaKPrAKPuA

ENCRYPT

DECRYPT

public transmission

sigA Arup loves Bina

sigA Arup loves BinaKPuA

Arup loves BinaKPuAKPuA

Page 12: Bitcoin, Blockchain and the Crypto Contracts - Part 1

Contracts without Trust!Bina transfers and asset, House25, to Chandru

Bina claims that Arup transferred this asset to Bina and so she has clear title to transfer asset to Chandru

Chandru does not trust Bina

Bina produces transfer contract that Arup gave to Bina

How can we use cryptofunctions to ensure that Bina does have the asset that she is transferring to Chandru

Page 13: Bitcoin, Blockchain and the Crypto Contracts - Part 1

Arup transfers asset to BinaArup creates contract C1transferring H25 to B

Arup adds his signature to C1

sigA

Arup completes the contract by adding a hash HC1

KPuA KPrA

KPuA H25 KPuB

KPuA H25 KPuB

sigA KPuA H25 KPuBHC1

Since all individuals are anonymous, the contract will represent them by their public keys

Page 14: Bitcoin, Blockchain and the Crypto Contracts - Part 1

Bina tries to transfer asset to Chandru

Bina creates similar contract C2

sigB KPuB H25 KPuCHC2

Chandru does not trust Bina. Does she really own H25?

sigB KPuB H25 KPuCHC2

Bina prefixes C1 to C2 but still not trusted! sigB KPuB H25 KPuCHC2

sigA KPuA H25 KPuBHC1

Since all individuals are anonymous, the contract will represent them by their public keys

Page 15: Bitcoin, Blockchain and the Crypto Contracts - Part 1

Chandru verifies cryptographicallySince all individuals are anonymous, the contract will represent them by their public keys

Has Bina tampered with C1? Perhaps Arup has sold House 22? Did he sell to Bina? Check Hash

sigB KPuB H25 KPuCHC2

sigA KPuA H25 KPuBHC1

sigB KPuB H25 KPuCHC2

sigA KPuA H25 KPuBHC1Hash matches! We know house was sold to Bina. Is Bina the Bina referred to in C1? Check Bina signature

sigB KPuB H25 KPuCHC2

sigB KPuB

KPuB

sigA KPuA H25 KPuBKPuA

Chandru accepts1. Bina got H25 from Arup2. Bina can sell to Chandru

sigB KPuB H25 KPuCHC2

YES! matches

bitcoin txn validation is similar, not same

Page 16: Bitcoin, Blockchain and the Crypto Contracts - Part 1

When Chandru transfer to DipaSince all individuals are anonymous, the contract will represent them by their public keys

Chandru will create unverified contract C3 that transfers H25 to Dipak

sigB KPuB H25 KPuCHC2

sigC KPuC H25 KPuDHC3

Process Continues

Page 17: Bitcoin, Blockchain and the Crypto Contracts - Part 1

What about?What if Bina had already sold the house to Esha? -- Double Spend?

Who will do all this verification? Why will they do all this?

The first contract? How do we know that Arup owns the asset? How far in the past do we go? -- the “Genesis” ?

All these issues are addressed by Bitcoin. See next presentation

Prithwis Mukerjee, PhD, Praxis Business School, Calcutta, India