Top Banner
Keychat: Secure Messaging via Bitcoin Robert Chen, John Kuszmaul, Yiming Zheng Mentored By Alin Tomescu 1
68

Keychat: Secure Messaging via Bitcoin

Feb 08, 2022

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Keychat: Secure Messaging via Bitcoin

Keychat: Secure Messaging via Bitcoin

Robert Chen, John Kuszmaul, Yiming ZhengMentored By Alin Tomescu

1

Page 2: Keychat: Secure Messaging via Bitcoin

Motivation

● We want to secure communications.

Alice Bob

Sensitive Financial Information

Yay, Money!

2

Page 3: Keychat: Secure Messaging via Bitcoin

End-to-end Encryption

● People generate a key pair. They broadcast public keys.

Alice Bob

C = PKB(Financial Information)

SKB(C) = Financial Information

I can’t decrypt this because I don’t have Bob’s secret key.

3

Page 4: Keychat: Secure Messaging via Bitcoin

The Problem: Public Key Distribution

Alice Bob

C = PKM(Financial Information)

C = PKB(Financial Information)

Mallory 4

● People can encrypt messages, but they might be encrypting them for the wrong person.

Page 5: Keychat: Secure Messaging via Bitcoin

The Current State of Common Communications Apps

● Facebook Messenger, Gmail - Do not use end-to-end encryption by default● WhatsApp, Signal - Public keys are stored in a central directory that may be insecure.

5

What is Bob’s Public Key?Alice Signal PKD

I know! It’s PKB.

Page 6: Keychat: Secure Messaging via Bitcoin

Are append-only PKDs enough for security?

6

Name Public Key

Alice PKA

Bob PKB PKM

Public Key Directory

If append-only, then Bob can detect fake PKM

What else can the malicious PKD do?

Page 7: Keychat: Secure Messaging via Bitcoin

Our Work: Public Key Directory Equivocation

Name Public Key

Alice PKA

Bob PKM

Name Public Key

Alice PKA

Bob PKB

Alice’s Perspective Bob’s Perspective

7

Name Public Key

Alice PKA

Version 1

Version 2A Version 2B

Page 8: Keychat: Secure Messaging via Bitcoin

Outline

Keybase

Bitcoin

Catena

Keychat

8

Optim

izesWitnesses

Keybase Bitcoin

Catena

Page 9: Keychat: Secure Messaging via Bitcoin

Keybase: A public key directory

9

Keybase PKD Server

Name Public Key

John PKJ

Robert PKR

Name Public Key

John PKJ

Robert PKR

Yiming PKY

S1 = H(DIR1) S2 = H(DIR2)

Page 10: Keychat: Secure Messaging via Bitcoin

Keybase Summaries

10

Yiming S1

Robert S1

Keybase PKD Server(1) Yiming PK?

(2) PKY

(3) Verify PKY against S1

(1) Yiming PK?

(2) PKY

(3) Verify PKY against S1

Page 11: Keychat: Secure Messaging via Bitcoin

Keybase Equivocation

11

Yiming S1, S2

Keybase PKD Server(1) Yiming PK?

(2) PKY

(3) Verify PKY against S2

(1) Yiming PK?

(2) PKM

(3) Verify PKM against S2’Robert S1, S2'

Page 12: Keychat: Secure Messaging via Bitcoin

Keybase Non-equivocation

● Important that Yiming and Robert have the same history of hashes/summaries: S1, S2, S3 ...

12

Keybase PKD Server

Bitcoin

S1, S2, S3 ...

Download S1, S2, S3 ...

Robert's, Yiming's Keychat apps

Page 13: Keychat: Secure Messaging via Bitcoin

Outline

Keybase

Bitcoin

Catena

Keychat

13

Optim

izesWitnesses

Keybase Bitcoin

Catena

Page 14: Keychat: Secure Messaging via Bitcoin

Bitcoin: Blockchain

A → B, 5 BTC

14

Block 1

C → D, 10 BTC

Page 15: Keychat: Secure Messaging via Bitcoin

Bitcoin: Blockchain

15

Block 1 Block 2

C → D, 10 BTC

D → B, 2 BTC

A → B, 1 BTC

A → B, 5 BTC

Page 16: Keychat: Secure Messaging via Bitcoin

Bitcoin: Blockchain

16

Block nBlock 1 Block 2

C → D, 10 BTC

D → B, 2 BTC

A → B, 1 BTC

M → A, 2 BTC A → B, 5 BTC

Page 17: Keychat: Secure Messaging via Bitcoin

However, Can Forks Happen?

17

Block nBlock 1 Block 2

C → D, 10 BTC

D → B, 2 BTC

A → B, 1 BTC

M → A, 2 BTC

Block n’

M → B, 2 BTC

A → B, 5 BTC

Page 18: Keychat: Secure Messaging via Bitcoin

However, Can Forks Happen?

18

Block nBlock 1 Block 2

C → D, 10 BTC

D → B, 2 BTC

A → B, 1 BTC

M → A, 2 BTC

Block n’

M → B, 2 BTC

Answer: No!

A → B, 5 BTC

Page 19: Keychat: Secure Messaging via Bitcoin

Keybase “Witnessing” Summaries

19

Block nBlock i Block j

C → D, 10 BTC

D → B, 2 BTC

A → B, 1 BTC

M → A, 2 BTC

K→ K, 1 BTCS1

K→ K, 1 BTCS2

K→ K, 1 BTCS3

A → B, 5 BTC

Page 20: Keychat: Secure Messaging via Bitcoin

Equivocation Within a Block?

20

Block j

D → B, 2 BTC A → B, 1 BTC

K→ K, 1 BTCS2

K→ K, 1 BTCS2’

Page 21: Keychat: Secure Messaging via Bitcoin

Hashes: A Reminder

21

SHA 256(Hash Function)

Page 22: Keychat: Secure Messaging via Bitcoin

Hashes: A Reminder

22

654324748 SHA 256(Hash Function)

Page 23: Keychat: Secure Messaging via Bitcoin

Hashes: A Reminder

23

654324748 SHA 256(Hash Function)

‘46f4e4edb6612295a20af8d927b6416a59398091dd82601668e441ac0bf26e2e’

Page 24: Keychat: Secure Messaging via Bitcoin

More Properties of Ideal Hash Functions

24

654324748 SHA 256(Hash Function)

'46f4e4edb6612295a20af8d927b6416a59398091dd82601668e441ac0bf26e2e'

SHA 256(Hash Function)

‘b7a4c0d08a9f74f47ce44d1f7a58d9344b35aab00c19975828ffb6fea556e6fa’

Always 256 bits

Always 256 bits

Bitcoin block

C → D, 10 BTC

Page 25: Keychat: Secure Messaging via Bitcoin

More Properties of Ideal Hash Functions

25

?????? SHA 256(Hash Function)

'c74c28b6dfc5099a3ce5386ae9866fadd44618c7db489ebe87b79053131f988d'

Given the output:

We should not be able to easily find the input

One Way (OW):

Given y, “infeasible” to find any x such that h(x) = y.

Page 26: Keychat: Secure Messaging via Bitcoin

Takeaways

- Can feed in any size data as input → fixed length output- Randomness: Small change in input data → entirely different

output - One-way: Given a hash, can’t feasibly find any data that hashes

to it- Perfect for a tamper-evident, append-only log!

26

Page 27: Keychat: Secure Messaging via Bitcoin

Blockchain: A Closer Look!

27

Block 1

H(TXNS1)

TXNS1

Block Header: - Contains hash pointer to TXN data- Contains hash pointer to previous block

h1= H( )

Page 28: Keychat: Secure Messaging via Bitcoin

Blockchain: A Closer Look!

28

Block 1

H(TXNS1)

Block 2

h1, H(TXNS2)

TXNS2

Block Header: - Contains hash pointer to TXN data- Contains hash pointer to previous block

h1= H( ) h2= H( )

TXNS1

Page 29: Keychat: Secure Messaging via Bitcoin

Blockchain: A Closer Look!

29

Block 1

H(TXNS1)

Block 2

h1, H(TXNS2)

TXNS2

Block n

hn-1, H(TXNSn)

TXNSn

h3 hn-1

Block Header: - Contains hash pointer to TXN data- Contains hash pointer to previous block

h1= H( h2= H( ) ) hn= H( )

TXNS1

Page 30: Keychat: Secure Messaging via Bitcoin

Transactions: A Closer Look!

- Transactions stored in Merkle Tree- Merkle Root hash stored in header

30

H(tx2)

A → C, 5 BTC

B → C, 10 BTC

tx2

H(tx1) H(tx3) H(tx4)

M1=H(H(tx1),H(tx2)) M2=H(H(tx3),H(tx4))

Rn=H(M1,M2)

Block n

hn-1,Rn

TXNSn

hn= H( )

Page 31: Keychat: Secure Messaging via Bitcoin

Transactions: Membership Proof

31

Membership proof for tx2?

H(tx2)H(tx1) H(tx3) H(tx4)

Block n

hn-1,Rnhn= H( )

A → C, 5 BTC

B → C, 10 BTC

tx2

TXNSn

Page 32: Keychat: Secure Messaging via Bitcoin

Transactions: Membership Proof

32

Membership proof for tx2

H(tx2)H(tx1) H(tx3) H(tx4)

Block n

hn-1,Rnhn= H( )

A → C, 5 BTC

B → C, 10 BTC

tx2

TXNSn

Page 33: Keychat: Secure Messaging via Bitcoin

Transactions: Membership Proof

33

Membership proof for tx2

H(tx2)H(tx1) H(tx3) H(tx4)

Block n

hn-1,Rnhn= H( )

M2

A → C, 5 BTC

B → C, 10 BTC

tx2

TXNSn

Page 34: Keychat: Secure Messaging via Bitcoin

Transactions: Membership Proof

34

Membership proof for tx2

H(tx2)H(tx1) H(tx3) H(tx4)

Block n

hn-1,Rnhn= H( )

M2

A → C, 5 BTC

B → C, 10 BTC

tx2

TXNSn

Page 35: Keychat: Secure Messaging via Bitcoin

Transactions: Membership Proof

35

Membership proof for tx2

H(tx2)H(tx1) H(tx3) H(tx4)

M1=H(H(tx1),H(tx2))

Block n

hn= H( )

M2

A → C, 5 BTC

B → C, 10 BTC

tx2

hn-1,Rn

TXNSn

Page 36: Keychat: Secure Messaging via Bitcoin

Membership Proof Success

36

Membership proof for tx2

H(tx2)H(tx1) H(tx3) H(tx4)

M1=H(H(tx1),H(tx2))

Rn'=H(M1,M2)

Block n

hn-1, Rn = Rn’

Yay!

hn= H( )

A → C, 5 BTC

B → C, 10 BTC

tx2 M2

TXNSn

Page 37: Keychat: Secure Messaging via Bitcoin

Block nBlock i Block j

Transaction Format

● Merkle tree of TXNs in each block

37

Page 38: Keychat: Secure Messaging via Bitcoin

Block nBlock i Block j

txa

Transaction Format

txb

PKB has 3Ƀ

● Transactions transfer coins

PKA has 3Ƀ

38

Page 39: Keychat: Secure Messaging via Bitcoin

Block nBlock i Block j

txb

txa

Transaction Format

from SKA PKB has 3Ƀ

● Transactions transfer coins● Output = # of coins and owner's PK● Input "spends" previous output

PKA has 3Ƀ

39

Page 40: Keychat: Secure Messaging via Bitcoin

Block nBlock i Block j

txb

txa

s1

Transaction Format

PKA has 3Ƀ from SKA

Arbitrary statement s1

PKB has 3Ƀ

Data can be embedded in TXNs.

40

Page 41: Keychat: Secure Messaging via Bitcoin

Block nBlock i Block j

txb

txc

s1

Transaction Format

PKB has 3Ƀ

Bob gives Carl 3Ƀ,

What happens if Bob tries to double spend?

41

Page 42: Keychat: Secure Messaging via Bitcoin

Transaction Format

Block i Block j Block n

s1

txb

txc

txc'

No double-spent coins: A TXN output can only be referred to by a single TXN input.

42

Page 43: Keychat: Secure Messaging via Bitcoin

Outline

Keybase

Bitcoin

Catena

Keychat

43

Optim

izesWitnesses

Keybase Bitcoin

Catena

Page 44: Keychat: Secure Messaging via Bitcoin

Problem with Keybase - Equivocation Within a Block?

44

Block j

D → B, 2 BTC A → B, 1 BTC

K→ K, 1 BTCS2

K→ K, 1 BTCS2’

Auditors must download the entire Bitcoin blockchain to check if any blocks contain invalid Keybase transactions

Page 45: Keychat: Secure Messaging via Bitcoin

Key idea behind Catena

TX1

TX'2

TX2

Efficiently use Bitcoin's mechanism that prevents double spends as proof of non-equivocation.

45

Page 46: Keychat: Secure Messaging via Bitcoin

Key idea behind Catena

TX1

TX'2

TX2

Efficiently use Bitcoin's mechanism that prevents double spends as proof of non-equivocation.

s1

s2

s'2

46

Page 47: Keychat: Secure Messaging via Bitcoin

Catena

Block i Block j Block n

No inconsistent s'3 as it would require a

double-spend!

s1 s2TX TX

TX s3

TX s'3

Linear chain of transactions containing statements

47

Page 48: Keychat: Secure Messaging via Bitcoin

Efficient auditing

Keybase server

Keychat client

Header i

GTX

Bitcoin Network

48

Page 49: Keychat: Secure Messaging via Bitcoin

Keybase server

Keychatclient

Header i

GTX

Bitcoin Network

Q: Next block header(s)?

Efficient auditing

49

Page 50: Keychat: Secure Messaging via Bitcoin

Keybase server

Keychatclient

Header i

GTX

Bitcoin Network

Header i+1 Header j

Efficient auditing

50

Page 51: Keychat: Secure Messaging via Bitcoin

Keybase server

Keychatclient

Header i Header j

GTX

Bitcoin Network

Efficient auditing

51

Page 52: Keychat: Secure Messaging via Bitcoin

Keybase server

Keychat client

Header i Header j

GTX

Bitcoin Network

Q: What is s1 in the log?

Efficient auditing

52

Page 53: Keychat: Secure Messaging via Bitcoin

Keybase server

Keychat client

Header i Header j

GTX

Bitcoin Network

TX1 s1

Efficient auditing

53

Page 54: Keychat: Secure Messaging via Bitcoin

Keybase server

Keychatclient

Header i Header j

TX1 s1GTX

Bitcoin Network

Efficient auditing

54

Page 55: Keychat: Secure Messaging via Bitcoin

Keybase server

Keychatclient

Header i Header j

TX1 s1GTX

Bitcoin Network

Q: Next block header(s)?

Efficient auditing

55

Page 56: Keychat: Secure Messaging via Bitcoin

Keybase server

Keychatclient

Header i Header j

TX1 s1GTX

Bitcoin Network

Header j+1 Header n

Efficient auditing

56

Page 57: Keychat: Secure Messaging via Bitcoin

Keybase server

Keychatclient

Header i Header j Header n

TX1 s1GTX

Bitcoin Network

Efficient auditing

57

Page 58: Keychat: Secure Messaging via Bitcoin

Keybase server

Keychatclient

Header i Header j Header n

TX1 s1GTX

Bitcoin Network

Q: What is s2 in the log?

Efficient auditing

58

Page 59: Keychat: Secure Messaging via Bitcoin

Keybase server

Keychatclient

Header i Header j Header n

TX1 s1GTX

Bitcoin Network TX2 s2

Efficient auditing

59

Page 60: Keychat: Secure Messaging via Bitcoin

Keybase server

Keychat client

Header i Header j Header n

TX1 s1GTX TX2 s2

Bitcoin Network

Efficient auditing

60

Page 61: Keychat: Secure Messaging via Bitcoin

Auditing bandwidth

e.g., 460K block headers + 10K statements = ~41 MB (80 bytes each) (around 600 bytes each)

61

Page 62: Keychat: Secure Messaging via Bitcoin

Recap

● Keybase can equivocate, so they witness the directory in Bitcoin, but inefficiently

62

S1, S2, S3,...

Keybase Bitcoin

Keychat client(110 GB)

S1 , S

2 , S3 ,...

Page 63: Keychat: Secure Messaging via Bitcoin

Recap

● Keybase can equivocate, so they witness the directory in Bitcoin, but inefficiently● Use Catena to make auditing the Keybase PKD more efficient

63

S1, S2, S3,...

Keybase

Keychat client (41 MB)

S 1, S 2

, S 3,...

CatenaBitcoin

Page 64: Keychat: Secure Messaging via Bitcoin

Outline

Keybase

Bitcoin

Catena

Keychat

64

Optim

izesWitnesses

Keybase Bitcoin

Catena

Page 65: Keychat: Secure Messaging via Bitcoin

Keychat

● Uses the Keybase PKD, so users can communicate securely without fear of public key equivocation

● Implemented using Meteor, a Javascript framework that allows KeyChat to work as both a website and an Android app

65

Keychat

Page 66: Keychat: Secure Messaging via Bitcoin

Next steps

● Implement Catena for Keybase using Java to efficiently witness the Keybase Public Key Directory in the Bitcoin blockchain

● Implement Keychat using Meteor

66

Page 67: Keychat: Secure Messaging via Bitcoin

Acknowledgements

Thanks to our mentor Alin Tomescu for his support and guidance!

Thanks to PRIMES for this opportunity!

Thanks to our parents for their support!

Thanks to all of you for being such a great audience!

67

Page 68: Keychat: Secure Messaging via Bitcoin

Ask us questions!

6868

Optim

izesWitnesses

Keybase Bitcoin

CatenaUses

Keychat