SlideShare une entreprise Scribd logo
1  sur  28
Télécharger pour lire hors ligne
Bitcoin Addresses
How they are generated from public keys
(a step-by-step guide)

Ash Moran
aviewfromafar.net
ash@ashleymoran.net
Anatomy of an Address
1kqHKEYYC8CQPxyV53nCju4Lk2ufpQqA2

address

prefix

Base58Check encoding of
the cryptographic hash

of something

(indicated by the prefix)
Step 1:

Representing Numbers
What’s Base58?
Represents numbers (eg decimal, base ten, numbers
using the digits 0-9) using 58 characters
Uses 1-9, most of A-Z and a-z, except:
No letter capital i (I), lowercase L (l), O or 0
Like hexadecimal, but with more digits
What’s hexadecimal?
Represents numbers (eg decimal, base ten, numbers
using the digits 0-9) using 16 characters
Uses 0-9, A-F
A = 10, B = 11, etc
Number -> Hexadecimal
Decimal

Hex

0

0

1

1

2

2

3

3

4

4

5

5

6

6

7

7

8

8

9

9

10

A

11

B

12

C

13

D

14

E

15

F
Hexadecimal example

C6A =
2 + 6 * 161 + 10 * 160 =
12 * 16
12 * (256) + 6 * (16) + 10 * (1) =
3178
Number -> Base58
Decimal

Base58

Decimal

Base58

Decimal

Base58

0

1

20

M

40

h

1

2

21

N

41

i

2

3

22

P

42

j

3

4

23

Q

43

k

4

5

24

R

44

m

5

6

25

S

45

n

6

7

26

T

46

o

7

8

27

U

47

p

8

9

28

V

48

q

9

A

29

W

49

r

10

B

30

X

50

s

11

C

31

Y

51

t

12

D

32

Z

52

u

13

E

33

a

53

v

14

F

34

b

54

w

15

G

35

c

55

x

16

H

36

d

56

y

17

J

37

e

57

z

18

K

38

f

19

L

39

g
Base58 example

4iX =
2 + 41 * 581 + 30 * 580 =
3 * 58
3 * (3364) + 41 * (58) + 30 * (1) =
12500
Step 2:
Message digests / hashes
Hashing
A hash function takes a value in
eg “This is my message”
Returns a fixed length number out
eg 1129729371291755845
Generates a different number if the input changes even
slightly
“This it my message” => 3763820994290329705
Cryptographic hashing
Like hashing but designed so it’s very very hard to figure out the message from the hash.
hash_function(“This is my message”) => hash_value – EASY!
hash_value => <?what was the message?> – HARD!
Bitcoin uses SHA256 and RIPEMD-160 hash functions
SHA256(“This is my message”) =>

3311b7c0bd91b6c73a38212de8ade31c51910f17480ad212ed2b9798a35b7747
SHA256(“This it my message”) =>
26a9911800b6115eb7ee508f60a2fd6479d45155a8aef1b1a35eb3173a512063
RIPEMD160(“This is my message”) =>

bdb6824f7b28e7dd9b9d6b457142547064435937
Base58 version of a hash
RIPEMD160(“This is my message”) =>

bdb6824f7b28e7dd9b9d6b457142547064435937
hex: 

bdb6824f7b28e7dd9b9d6b457142547064435937 

decimal:
1083069342955023797228115257453753838398332950839
Base58(1083069342955023797228115257453753838398332
950839) =>

3eJ7uPEgX8h56UJmTNmqwTvHs9H8
Step 3:
Bitcoin encryption keys
Public/private key signing

Problem: Alice wants to send Bob a message and
want anybody to be able to verify that the message
came from her. She wants to make sure nobody can
forge her signature on the message.
Elliptic Curve Cryptography

See the excellent guide
A (relatively easy to understand) primer on elliptic curve cryptography
by Nick Sullivan
Elliptic Curve Cryptography
Private key: a random 256-bit (32-byte) integer
Public key: an (x, y) point on the curve, either:
the number 4, followed by 256-bit x and y coordinates
(old uncompressed 65-byte format)

[4, x, y]
the number 2 or 3 followed by a 256-bit x coordinate
(new compressed 33-byte format)

[2, x, y] or [3, x, y]
Step 4:
Checksums
European Article Number

Colgate Total 75 ml
4011200296908
Colgate Total 75ml EAN
checksum
Total of odd numbers = 25

27 + 25 = 52
Last digit of 52 = 2

4 0 1 1 2 0 0 2 9 6 9 0 8
Total of even numbers = 9

9 * 3 = 27

10 - 2 = 8
yay!
Step 5:
Putting it together
Bitcoin pubkey address
Take the pubkey with header byte, e.g. [4, x, y]
Run it through the SHA256 hash function

pubkey_hash_step_1 = SHA256([4, x, y])
Run it through the RIPEMD160 hash function

pubkey_hash = RIPEMD160(pubkey_hash_step_1)
Add a byte to the start to indicate which network it’s for (Bitcoin 00,
Namecoin 34, Bitcoin testnet 6f)

plain_binary_address = [00, pubkey_hash]
TBC…
Checksum generation
Take the plain binary address, and run it through the SHA256 function
twice:

plain_address_hash = SHA256(SHA256(plain_binary_address))
Take the first four bytes of this hash as a checksum:

checksum = first_4_bytes(plain_binary_address)
Add the checksum onto the end to give the binary_address:

binary_address = [00, pubkey_hash, checksum]
Base58 encode the result:

bitcoin_address = Base58(binary_address)
Now we have the result, eg “16UwLL9Risc3QfPqBUvKofHmBQ7wMtjvM”
Demo!
(source for live demo now on the next
slide)
Example Ruby source
require 'bitcoin'

!

def hex_string_to_bytes(string)
[string].pack("H*")
end

!

def bytes_to_hex_string(bytes)
bytes.unpack("H*").first
end

!

# https://en.bitcoin.it/wiki/Technical_background_of_Bitcoin_addresses
private_key_hex_string = "18E14A7B6A307F426A94F8114701E7C8E774E7F9A47E2C2035DB29A206321725"

!

key = Bitcoin::Key.new(private_key_hex_string)
pub_key_bytes = hex_string_to_bytes(key.pub_uncompressed)

!

hash_step_1 = Digest::SHA256.digest(pub_key_bytes)
hash160 = Digest::RMD160.digest(hash_step_1)
hash160_hex_string = bytes_to_hex_string(hash160)

!

versioned_hash160_hex_string = "00" + hash160_hex_string
versioned_hash160 = hex_string_to_bytes(versioned_hash160_hex_string)

!

checksum_hash_round_1 = Digest::SHA256.digest(versioned_hash160)
checksum_hash_round_2 = Digest::SHA256.digest(checksum_hash_round_1)
checksum = checksum_hash_round_2[0,4]

!

binary_address = versioned_hash160 + checksum
binary_address_hex_string = bytes_to_hex_string(binary_address)

!

human_address = Bitcoin.encode_base58(binary_address_hex_string)
p human_address

https://gist.github.com/ashmoran/7582071
Other address types
Other address types
Bitcoin script addresses: 3xxx, e.g.:

3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzQX
Bitcoin private key (uncompressed pubkey), 5xxx, e.g.:

5Htn3FzuH3b1X5VF2zLTsAQzBcyzkZNJsa2egXN8ZFJ
TCqQm3Rq
Bitcoin private key (compressed pubkey), [K/L]xxx, e.g.:

L1aW4aubDFB7yfras2S1mN3bqg9nwySY8nkoLmJebS
LD5BWv3ENZ
Done!

Contenu connexe

Tendances

Blockchain Technology | Blockchain Technology Explained | Edureka
Blockchain Technology | Blockchain Technology Explained | EdurekaBlockchain Technology | Blockchain Technology Explained | Edureka
Blockchain Technology | Blockchain Technology Explained | EdurekaEdureka!
 
Blockchain 101 by imran bashir
Blockchain 101  by imran bashirBlockchain 101  by imran bashir
Blockchain 101 by imran bashirImran Bashir
 
Understanding Bitcoin
Understanding BitcoinUnderstanding Bitcoin
Understanding BitcoinLeslie Bayona
 
Crypto Wallet Types Explained
Crypto Wallet Types ExplainedCrypto Wallet Types Explained
Crypto Wallet Types Explained101 Blockchains
 
Introduction to Blockchain and Smart Contracts
Introduction to Blockchain and Smart ContractsIntroduction to Blockchain and Smart Contracts
Introduction to Blockchain and Smart ContractsSaad Zaher
 
PoW vs. PoS - Key Differences
PoW vs. PoS - Key DifferencesPoW vs. PoS - Key Differences
PoW vs. PoS - Key Differences101 Blockchains
 
Introduction to bitcoin
Introduction to bitcoinIntroduction to bitcoin
Introduction to bitcoinWolf McNally
 
Post Quantum Cryptography: Technical Overview
Post Quantum Cryptography: Technical OverviewPost Quantum Cryptography: Technical Overview
Post Quantum Cryptography: Technical OverviewRamesh Nagappan
 
Zero-Knowledge Proofs: Privacy-Preserving Digital Identity with Clare Nelson
Zero-Knowledge Proofs: Privacy-Preserving Digital Identity with Clare NelsonZero-Knowledge Proofs: Privacy-Preserving Digital Identity with Clare Nelson
Zero-Knowledge Proofs: Privacy-Preserving Digital Identity with Clare NelsonSSIMeetup
 
암호화 이것만 알면 된다.
암호화 이것만 알면 된다.암호화 이것만 알면 된다.
암호화 이것만 알면 된다.KwangSeob Jeong
 
Introduction To Solidity
Introduction To SolidityIntroduction To Solidity
Introduction To Solidity101 Blockchains
 
Blockchain Security Issues and Challenges
Blockchain Security Issues and Challenges Blockchain Security Issues and Challenges
Blockchain Security Issues and Challenges Merlec Mpyana
 
Blockchain Technology | Blockchain Explained | Blockchain Tutorial | Blockcha...
Blockchain Technology | Blockchain Explained | Blockchain Tutorial | Blockcha...Blockchain Technology | Blockchain Explained | Blockchain Tutorial | Blockcha...
Blockchain Technology | Blockchain Explained | Blockchain Tutorial | Blockcha...Edureka!
 
Understanding Proof of Work (PoW) and Proof of Stake (PoS) Algorithms
Understanding Proof of Work (PoW) and Proof of Stake (PoS) AlgorithmsUnderstanding Proof of Work (PoW) and Proof of Stake (PoS) Algorithms
Understanding Proof of Work (PoW) and Proof of Stake (PoS) AlgorithmsGautam Anand
 
Ten Blockchain Applications
Ten Blockchain ApplicationsTen Blockchain Applications
Ten Blockchain ApplicationsAhmed Banafa
 

Tendances (20)

Blockchain Technology | Blockchain Technology Explained | Edureka
Blockchain Technology | Blockchain Technology Explained | EdurekaBlockchain Technology | Blockchain Technology Explained | Edureka
Blockchain Technology | Blockchain Technology Explained | Edureka
 
Blockchain 101 by imran bashir
Blockchain 101  by imran bashirBlockchain 101  by imran bashir
Blockchain 101 by imran bashir
 
Understanding Bitcoin
Understanding BitcoinUnderstanding Bitcoin
Understanding Bitcoin
 
Crypto Wallet Types Explained
Crypto Wallet Types ExplainedCrypto Wallet Types Explained
Crypto Wallet Types Explained
 
Cryptography - 101
Cryptography - 101Cryptography - 101
Cryptography - 101
 
Introduction to Blockchain and Smart Contracts
Introduction to Blockchain and Smart ContractsIntroduction to Blockchain and Smart Contracts
Introduction to Blockchain and Smart Contracts
 
PoW vs. PoS - Key Differences
PoW vs. PoS - Key DifferencesPoW vs. PoS - Key Differences
PoW vs. PoS - Key Differences
 
An Introduction to Blockchain
An Introduction to BlockchainAn Introduction to Blockchain
An Introduction to Blockchain
 
Bitcoin MOOC Lecture 2.pptx
Bitcoin MOOC Lecture 2.pptxBitcoin MOOC Lecture 2.pptx
Bitcoin MOOC Lecture 2.pptx
 
Introduction to bitcoin
Introduction to bitcoinIntroduction to bitcoin
Introduction to bitcoin
 
Post Quantum Cryptography: Technical Overview
Post Quantum Cryptography: Technical OverviewPost Quantum Cryptography: Technical Overview
Post Quantum Cryptography: Technical Overview
 
Block chain technology
Block chain technologyBlock chain technology
Block chain technology
 
Zero-Knowledge Proofs: Privacy-Preserving Digital Identity with Clare Nelson
Zero-Knowledge Proofs: Privacy-Preserving Digital Identity with Clare NelsonZero-Knowledge Proofs: Privacy-Preserving Digital Identity with Clare Nelson
Zero-Knowledge Proofs: Privacy-Preserving Digital Identity with Clare Nelson
 
암호화 이것만 알면 된다.
암호화 이것만 알면 된다.암호화 이것만 알면 된다.
암호화 이것만 알면 된다.
 
Introduction To Solidity
Introduction To SolidityIntroduction To Solidity
Introduction To Solidity
 
Blockchain Security Issues and Challenges
Blockchain Security Issues and Challenges Blockchain Security Issues and Challenges
Blockchain Security Issues and Challenges
 
Blockchain Technology | Blockchain Explained | Blockchain Tutorial | Blockcha...
Blockchain Technology | Blockchain Explained | Blockchain Tutorial | Blockcha...Blockchain Technology | Blockchain Explained | Blockchain Tutorial | Blockcha...
Blockchain Technology | Blockchain Explained | Blockchain Tutorial | Blockcha...
 
bitcoin technology
bitcoin technologybitcoin technology
bitcoin technology
 
Understanding Proof of Work (PoW) and Proof of Stake (PoS) Algorithms
Understanding Proof of Work (PoW) and Proof of Stake (PoS) AlgorithmsUnderstanding Proof of Work (PoW) and Proof of Stake (PoS) Algorithms
Understanding Proof of Work (PoW) and Proof of Stake (PoS) Algorithms
 
Ten Blockchain Applications
Ten Blockchain ApplicationsTen Blockchain Applications
Ten Blockchain Applications
 

En vedette

Introduction to Bitcoin
Introduction to BitcoinIntroduction to Bitcoin
Introduction to Bitcoinashmoran
 
Bitcoin: The Internet of Money
Bitcoin: The Internet of MoneyBitcoin: The Internet of Money
Bitcoin: The Internet of Moneywinklevosscap
 
Prosumer Report Vida Moderna México
Prosumer Report Vida Moderna MéxicoProsumer Report Vida Moderna México
Prosumer Report Vida Moderna Méxicoeurorscgmx
 
The Bitcoin Protocol for Humans
The Bitcoin Protocol for HumansThe Bitcoin Protocol for Humans
The Bitcoin Protocol for HumansJohn Mardlin
 
How to demystify cross-border payments in travel
How to demystify cross-border payments in travelHow to demystify cross-border payments in travel
How to demystify cross-border payments in traveltnooz
 
Cross Border Payment- India and New 15CA/15CB Requirements
Cross Border Payment- India and New 15CA/15CB RequirementsCross Border Payment- India and New 15CA/15CB Requirements
Cross Border Payment- India and New 15CA/15CB RequirementsStuti Shah
 
Peer_to_Peer_Affine_Commitment
Peer_to_Peer_Affine_CommitmentPeer_to_Peer_Affine_Commitment
Peer_to_Peer_Affine_CommitmentKruti Sharma
 
Banking presentation
Banking presentationBanking presentation
Banking presentationGrafic.guru
 
BANK Automated Clearing System
BANK Automated Clearing SystemBANK Automated Clearing System
BANK Automated Clearing SystemAjay Kumar ☁
 
Payments and transaction processing systems - Global and Indian Overview
Payments and transaction processing systems - Global and Indian OverviewPayments and transaction processing systems - Global and Indian Overview
Payments and transaction processing systems - Global and Indian OverviewAkshay Kaul
 
RTGS REAL TIME GROSS SETTLEMENT
RTGS REAL TIME GROSS SETTLEMENTRTGS REAL TIME GROSS SETTLEMENT
RTGS REAL TIME GROSS SETTLEMENTAyush Verma
 
An introduction to SwiftNET
An introduction to SwiftNETAn introduction to SwiftNET
An introduction to SwiftNETRishabh Dangwal
 

En vedette (19)

Bitcoins Math
Bitcoins MathBitcoins Math
Bitcoins Math
 
Introduction to Bitcoin
Introduction to BitcoinIntroduction to Bitcoin
Introduction to Bitcoin
 
Bitcoin: The Internet of Money
Bitcoin: The Internet of MoneyBitcoin: The Internet of Money
Bitcoin: The Internet of Money
 
Payment system
Payment systemPayment system
Payment system
 
Prosumer Report Vida Moderna México
Prosumer Report Vida Moderna MéxicoProsumer Report Vida Moderna México
Prosumer Report Vida Moderna México
 
The Bitcoin Protocol for Humans
The Bitcoin Protocol for HumansThe Bitcoin Protocol for Humans
The Bitcoin Protocol for Humans
 
A2Apay Domestic Cross Border Payment Flow
A2Apay Domestic Cross Border Payment FlowA2Apay Domestic Cross Border Payment Flow
A2Apay Domestic Cross Border Payment Flow
 
How to demystify cross-border payments in travel
How to demystify cross-border payments in travelHow to demystify cross-border payments in travel
How to demystify cross-border payments in travel
 
Bitcoin Level 2
Bitcoin Level 2Bitcoin Level 2
Bitcoin Level 2
 
Cross Border Payment- India and New 15CA/15CB Requirements
Cross Border Payment- India and New 15CA/15CB RequirementsCross Border Payment- India and New 15CA/15CB Requirements
Cross Border Payment- India and New 15CA/15CB Requirements
 
Peer_to_Peer_Affine_Commitment
Peer_to_Peer_Affine_CommitmentPeer_to_Peer_Affine_Commitment
Peer_to_Peer_Affine_Commitment
 
Banking presentation
Banking presentationBanking presentation
Banking presentation
 
General Introduction to Bitcoin
General Introduction to BitcoinGeneral Introduction to Bitcoin
General Introduction to Bitcoin
 
FedLink Wire Transfer System
FedLink Wire Transfer SystemFedLink Wire Transfer System
FedLink Wire Transfer System
 
Logistics II Western Union & DHL
Logistics II   Western Union & DHLLogistics II   Western Union & DHL
Logistics II Western Union & DHL
 
BANK Automated Clearing System
BANK Automated Clearing SystemBANK Automated Clearing System
BANK Automated Clearing System
 
Payments and transaction processing systems - Global and Indian Overview
Payments and transaction processing systems - Global and Indian OverviewPayments and transaction processing systems - Global and Indian Overview
Payments and transaction processing systems - Global and Indian Overview
 
RTGS REAL TIME GROSS SETTLEMENT
RTGS REAL TIME GROSS SETTLEMENTRTGS REAL TIME GROSS SETTLEMENT
RTGS REAL TIME GROSS SETTLEMENT
 
An introduction to SwiftNET
An introduction to SwiftNETAn introduction to SwiftNET
An introduction to SwiftNET
 

Similaire à Bitcoin Addresses

Blockchain Cryptography for Developers (Nakov @ BlockWorld 2018, San Jose)
Blockchain Cryptography for Developers (Nakov @ BlockWorld 2018, San Jose)Blockchain Cryptography for Developers (Nakov @ BlockWorld 2018, San Jose)
Blockchain Cryptography for Developers (Nakov @ BlockWorld 2018, San Jose)Svetlin Nakov
 
SHA- Secure hashing algorithm
SHA- Secure hashing algorithmSHA- Secure hashing algorithm
SHA- Secure hashing algorithmRuchi Maurya
 
Blockchain Cryptography for Developers (Nakov @ BGWebSummit 2018)
Blockchain Cryptography for Developers (Nakov @ BGWebSummit 2018)Blockchain Cryptography for Developers (Nakov @ BGWebSummit 2018)
Blockchain Cryptography for Developers (Nakov @ BGWebSummit 2018)Svetlin Nakov
 
Implementation of Bitcoin Miner on SW and HW
Implementation of Bitcoin Miner on SW and HWImplementation of Bitcoin Miner on SW and HW
Implementation of Bitcoin Miner on SW and HWJoe Jiang
 
Data streaming algorithms
Data streaming algorithmsData streaming algorithms
Data streaming algorithmsHridyesh Bisht
 
BERserk: New RSA Signature Forgery Attack
BERserk: New RSA Signature Forgery AttackBERserk: New RSA Signature Forgery Attack
BERserk: New RSA Signature Forgery AttackAlex Matrosov
 
Data Encryption Standards (1).pptx
Data Encryption Standards (1).pptxData Encryption Standards (1).pptx
Data Encryption Standards (1).pptxSanthosh Prabhu
 
Hash mac algorithms
Hash mac algorithmsHash mac algorithms
Hash mac algorithmsYoung Alista
 
Hash mac algorithms
Hash mac algorithmsHash mac algorithms
Hash mac algorithmsDavid Hoen
 
Hash& mac algorithms
Hash& mac algorithmsHash& mac algorithms
Hash& mac algorithmsHarry Potter
 
Hash mac algorithms
Hash mac algorithmsHash mac algorithms
Hash mac algorithmsJames Wong
 
Hash mac algorithms
Hash mac algorithmsHash mac algorithms
Hash mac algorithmsTony Nguyen
 
Hash mac algorithms
Hash mac algorithmsHash mac algorithms
Hash mac algorithmsFraboni Ec
 
Hands on with Smart Contracts session #3
Hands on with Smart Contracts session #3Hands on with Smart Contracts session #3
Hands on with Smart Contracts session #3Gene Leybzon
 

Similaire à Bitcoin Addresses (20)

Secure Hash Algorithm
Secure Hash AlgorithmSecure Hash Algorithm
Secure Hash Algorithm
 
Blockchain Cryptography for Developers (Nakov @ BlockWorld 2018, San Jose)
Blockchain Cryptography for Developers (Nakov @ BlockWorld 2018, San Jose)Blockchain Cryptography for Developers (Nakov @ BlockWorld 2018, San Jose)
Blockchain Cryptography for Developers (Nakov @ BlockWorld 2018, San Jose)
 
SHA- Secure hashing algorithm
SHA- Secure hashing algorithmSHA- Secure hashing algorithm
SHA- Secure hashing algorithm
 
Blockchain Cryptography for Developers (Nakov @ BGWebSummit 2018)
Blockchain Cryptography for Developers (Nakov @ BGWebSummit 2018)Blockchain Cryptography for Developers (Nakov @ BGWebSummit 2018)
Blockchain Cryptography for Developers (Nakov @ BGWebSummit 2018)
 
Implementation of Bitcoin Miner on SW and HW
Implementation of Bitcoin Miner on SW and HWImplementation of Bitcoin Miner on SW and HW
Implementation of Bitcoin Miner on SW and HW
 
Sha
ShaSha
Sha
 
Data streaming algorithms
Data streaming algorithmsData streaming algorithms
Data streaming algorithms
 
Renas Rajab Asaad
Renas Rajab AsaadRenas Rajab Asaad
Renas Rajab Asaad
 
BERserk: New RSA Signature Forgery Attack
BERserk: New RSA Signature Forgery AttackBERserk: New RSA Signature Forgery Attack
BERserk: New RSA Signature Forgery Attack
 
Blockchain
BlockchainBlockchain
Blockchain
 
Secure hashing algorithm
Secure hashing algorithmSecure hashing algorithm
Secure hashing algorithm
 
Data Encryption Standards (1).pptx
Data Encryption Standards (1).pptxData Encryption Standards (1).pptx
Data Encryption Standards (1).pptx
 
Hash mac algorithms
Hash mac algorithmsHash mac algorithms
Hash mac algorithms
 
Hash mac algorithms
Hash mac algorithmsHash mac algorithms
Hash mac algorithms
 
Hash& mac algorithms
Hash& mac algorithmsHash& mac algorithms
Hash& mac algorithms
 
Hash mac algorithms
Hash mac algorithmsHash mac algorithms
Hash mac algorithms
 
Hash mac algorithms
Hash mac algorithmsHash mac algorithms
Hash mac algorithms
 
Hash mac algorithms
Hash mac algorithmsHash mac algorithms
Hash mac algorithms
 
Hash mac algorithms
Hash mac algorithmsHash mac algorithms
Hash mac algorithms
 
Hands on with Smart Contracts session #3
Hands on with Smart Contracts session #3Hands on with Smart Contracts session #3
Hands on with Smart Contracts session #3
 

Dernier

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 

Dernier (20)

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 

Bitcoin Addresses

  • 1. Bitcoin Addresses How they are generated from public keys (a step-by-step guide) Ash Moran aviewfromafar.net ash@ashleymoran.net
  • 2. Anatomy of an Address 1kqHKEYYC8CQPxyV53nCju4Lk2ufpQqA2 address
 prefix Base58Check encoding of the cryptographic hash
 of something
 (indicated by the prefix)
  • 4. What’s Base58? Represents numbers (eg decimal, base ten, numbers using the digits 0-9) using 58 characters Uses 1-9, most of A-Z and a-z, except: No letter capital i (I), lowercase L (l), O or 0 Like hexadecimal, but with more digits
  • 5. What’s hexadecimal? Represents numbers (eg decimal, base ten, numbers using the digits 0-9) using 16 characters Uses 0-9, A-F A = 10, B = 11, etc
  • 7. Hexadecimal example C6A = 2 + 6 * 161 + 10 * 160 = 12 * 16 12 * (256) + 6 * (16) + 10 * (1) = 3178
  • 9. Base58 example 4iX = 2 + 41 * 581 + 30 * 580 = 3 * 58 3 * (3364) + 41 * (58) + 30 * (1) = 12500
  • 11. Hashing A hash function takes a value in eg “This is my message” Returns a fixed length number out eg 1129729371291755845 Generates a different number if the input changes even slightly “This it my message” => 3763820994290329705
  • 12. Cryptographic hashing Like hashing but designed so it’s very very hard to figure out the message from the hash. hash_function(“This is my message”) => hash_value – EASY! hash_value => <?what was the message?> – HARD! Bitcoin uses SHA256 and RIPEMD-160 hash functions SHA256(“This is my message”) =>
 3311b7c0bd91b6c73a38212de8ade31c51910f17480ad212ed2b9798a35b7747 SHA256(“This it my message”) => 26a9911800b6115eb7ee508f60a2fd6479d45155a8aef1b1a35eb3173a512063 RIPEMD160(“This is my message”) =>
 bdb6824f7b28e7dd9b9d6b457142547064435937
  • 13. Base58 version of a hash RIPEMD160(“This is my message”) =>
 bdb6824f7b28e7dd9b9d6b457142547064435937 hex: 
 bdb6824f7b28e7dd9b9d6b457142547064435937 
 decimal: 1083069342955023797228115257453753838398332950839 Base58(1083069342955023797228115257453753838398332 950839) =>
 3eJ7uPEgX8h56UJmTNmqwTvHs9H8
  • 15. Public/private key signing Problem: Alice wants to send Bob a message and want anybody to be able to verify that the message came from her. She wants to make sure nobody can forge her signature on the message.
  • 16. Elliptic Curve Cryptography See the excellent guide A (relatively easy to understand) primer on elliptic curve cryptography by Nick Sullivan
  • 17. Elliptic Curve Cryptography Private key: a random 256-bit (32-byte) integer Public key: an (x, y) point on the curve, either: the number 4, followed by 256-bit x and y coordinates (old uncompressed 65-byte format)
 [4, x, y] the number 2 or 3 followed by a 256-bit x coordinate (new compressed 33-byte format)
 [2, x, y] or [3, x, y]
  • 19. European Article Number Colgate Total 75 ml 4011200296908
  • 20. Colgate Total 75ml EAN checksum Total of odd numbers = 25 27 + 25 = 52 Last digit of 52 = 2 4 0 1 1 2 0 0 2 9 6 9 0 8 Total of even numbers = 9
 9 * 3 = 27 10 - 2 = 8 yay!
  • 21. Step 5: Putting it together
  • 22. Bitcoin pubkey address Take the pubkey with header byte, e.g. [4, x, y] Run it through the SHA256 hash function
 pubkey_hash_step_1 = SHA256([4, x, y]) Run it through the RIPEMD160 hash function
 pubkey_hash = RIPEMD160(pubkey_hash_step_1) Add a byte to the start to indicate which network it’s for (Bitcoin 00, Namecoin 34, Bitcoin testnet 6f)
 plain_binary_address = [00, pubkey_hash] TBC…
  • 23. Checksum generation Take the plain binary address, and run it through the SHA256 function twice:
 plain_address_hash = SHA256(SHA256(plain_binary_address)) Take the first four bytes of this hash as a checksum:
 checksum = first_4_bytes(plain_binary_address) Add the checksum onto the end to give the binary_address:
 binary_address = [00, pubkey_hash, checksum] Base58 encode the result:
 bitcoin_address = Base58(binary_address) Now we have the result, eg “16UwLL9Risc3QfPqBUvKofHmBQ7wMtjvM”
  • 24. Demo! (source for live demo now on the next slide)
  • 25. Example Ruby source require 'bitcoin' ! def hex_string_to_bytes(string) [string].pack("H*") end ! def bytes_to_hex_string(bytes) bytes.unpack("H*").first end ! # https://en.bitcoin.it/wiki/Technical_background_of_Bitcoin_addresses private_key_hex_string = "18E14A7B6A307F426A94F8114701E7C8E774E7F9A47E2C2035DB29A206321725" ! key = Bitcoin::Key.new(private_key_hex_string) pub_key_bytes = hex_string_to_bytes(key.pub_uncompressed) ! hash_step_1 = Digest::SHA256.digest(pub_key_bytes) hash160 = Digest::RMD160.digest(hash_step_1) hash160_hex_string = bytes_to_hex_string(hash160) ! versioned_hash160_hex_string = "00" + hash160_hex_string versioned_hash160 = hex_string_to_bytes(versioned_hash160_hex_string) ! checksum_hash_round_1 = Digest::SHA256.digest(versioned_hash160) checksum_hash_round_2 = Digest::SHA256.digest(checksum_hash_round_1) checksum = checksum_hash_round_2[0,4] ! binary_address = versioned_hash160 + checksum binary_address_hex_string = bytes_to_hex_string(binary_address) ! human_address = Bitcoin.encode_base58(binary_address_hex_string) p human_address https://gist.github.com/ashmoran/7582071
  • 27. Other address types Bitcoin script addresses: 3xxx, e.g.:
 3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzQX Bitcoin private key (uncompressed pubkey), 5xxx, e.g.:
 5Htn3FzuH3b1X5VF2zLTsAQzBcyzkZNJsa2egXN8ZFJ TCqQm3Rq Bitcoin private key (compressed pubkey), [K/L]xxx, e.g.:
 L1aW4aubDFB7yfras2S1mN3bqg9nwySY8nkoLmJebS LD5BWv3ENZ
  • 28. Done!