• No results found

Keys, Addresses, Wallets

N/A
N/A
Protected

Academic year: 2022

Share "Keys, Addresses, Wallets"

Copied!
31
0
0

Loading.... (view fulltext now)

Full text

(1)

Keys, Addresses, Wallets

Dr.Piyawad Kasabai piyawad.k (at) udru.ac.th

https://piyk.github.io

(2)

Outline

● Cryptography behind Bitcoin

● Keys

○ Private keys

○ Public keys

○ Key formats

● Addresses

○ Creating address from keys

● Wallets

○ Wallet types

○ Nondeterministic Wallets

○ Deterministic Wallets

(3)

Mastering Bitcoin

Bitcoin Overview

(4)

Blockchain

Block Example #0 Block Example #1 Block Example #2

(5)

Address in genesis block

https://www.blockchain.com/btc/address/1A1zP1eP5QGefi2DMPTfTL5S Lmv7DivfNa

(6)

“Not your keys, not your coins”

(7)

Cryptography in Bitcoin

ECDSA (Elliptic Curve Digital Signature Algorithm)

(8)

Keys

● Bitcoin account (Wallet) is produced from a public key and a private key.

Public key is the account number or address.

Private key is used to prevent other people from using bitcoins from your address.

● Private Key is just a randomly generated number.

(9)

Keys

● From the private key, elliptic curve multiplication, a one-way

cryptographic function is used to generate a public key.

Private Key ef235aacf90d9f4aadd8c92e4b2562e1d9eb97f0df9ba3b508258739cb013db2 Public Key 02b4632d08485ff1df2db55b9dafd23347d1c47a457072a1e87be26896549a8737

(10)

Blockchain Demo: Public / Private Keys & Signing

https://andersbrownworth.com/blockchain/public-private-keys/keys

(11)

Address

● Address is created from the public key using sha256/RIPEMD-160/base58.

(12)

Public key to bitcoin address

Conversion of a public key into a bitcoin address

A = RIPEMD160(SHA256(K))

where K is the public key and A is the resulting bitcoin address.

(13)

Base58Check Encoding

Base58 is a text-based binary-encoding format developed for use in bitcoin to balance between compact representation, readability, and error detection and prevention.

Base58 is a subset of Base64, using upper- and lowercase letters and numbers, but omitting some characters that are frequently mistaken for one another and can appear identical when displayed in certain fonts.

Specifically, Base58 is Base64 without the 0 (number zero), O (capital o), l (lower L), I (capital i), and the symbols “``” and "/".

Bitcoin’s Base58 alphabet

123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijk mnopqrstuvwxyz

(14)

Address version prefix

Type Version prefix (hex) Base58 result prefix

Bitcoin Address 0x00 1

Pay-to-Script-Hash Address 0x05 3

Bitcoin Testnet Address 0x6F m or n

Private Key WIF* 0x80 5, K, or L

BIP-38 Encrypted Private Key 0x0142 6P

BIP-32 Extended Public Key 0x0488B21E xpub

(15)

Key Formats

● Both private and public keys can be represented in a number of different formats.

Private key formats

Example: Same key, different formats

Type Prefix Description

Raw None 32 bytes

Hex None 64 hexadecimal digits

WIF 5 Base58Check encoding: Base58 with version prefix of 0x80 and 4-byte checksum WIF-compressed K or L As above, with added suffix 0x01 before encoding

Format Private key

Hex 1e99423a4ed27608a15a2616a2b0e9e52ced330ac530edcc32c8ffc6a526aedd WIF 5J3mBbAH58CpQ3Y5RNJpUKPE62SQ5tfcvU2JpbnkeyhfsYB1Jcn

WIF-compressed KxFC1jmwwCoACiCAWZ3eXa96mBM6tb3TYzGmf6YwgdGWZgawvrtJ

(16)

Key Formats

Public key formats: can be presented in different ways, usually compressed or uncompressed

(17)

Wallets

● Types of wallets:

Nondeterministic (Random) Wallets: Type-0 a collection of randomly generated keys

Deterministic (Seeded) Wallets: Type-1 a deterministic sequence of keys derived from a seed

HD Wallets: Type-2 a tree of keys generated from a single seed

(18)

Types of Wallets

Nondeterministic Wallets Deterministic Wallets Hierarchical Deterministic Wallets

(19)

Wallet Technology Details

The wallet starts from a source of entropy, adds a checksum, and then maps the entropy to a word list:

1. Create a random sequence (entropy) of 128 to 256 bits.

2. Create a checksum of the random sequence by taking the first (entropy-length/32) bits of its SHA256 hash.

3. Add the checksum to the end of the random sequence.

4. Split the result into 11-bit length segments.

5. Map each 11-bit value to a word from the predefined dictionary of 2048 words.

6. The mnemonic code is the sequence of words.

(20)

Mnemonic codes: entropy and word length

Entropy (bits)

Check sum (bits)

Entropy + checksum

(bits)

Mnemonic length (words)

128 4 132 12

160 5 165 15

192 6 198 18

224 7 231 21

256 8 264 24

(21)

● Creating master keys and chain code from a root seed

Creating Hierarchical Deterministic (HD) Wallet from the Seed

(22)

● Extending a parent private key to create a child private key

Creating Hierarchical Deterministic (HD) Wallet from the Seed

(23)

● Extending a parent public key to create a child public key

Creating Hierarchical Deterministic (HD) Wallet from the Seed

(24)

Summary: HD Wallet

A hierarchical deterministic (HD

wallet) provides a useful method

for generating new private keys

and public keys.

(25)

Using Bitcoin Wallets

● Hot Wallet vs. Cold Wallet

Hot wallet: required to be connected to the Internet

Cold wallet: store in offline mode and provide more security

● Software wallets

Web: Bitkub, Binance, etc.

Desktop and Mobile Apps: Bitcoin core (full node), electrum (light node), Exodus, Mycelium,

samouraiwallet

● Hardware wallets

Trezor

Ledger

(26)

Paper wallet

(27)

Demo: electrum

(https://electrum.org)

(28)

Example keys in Python

Code:

https://drive.google.com/file/d/1jPjiEJDVlRlG6nKM_4qoYFgwaS5LgPMO/view?usp=sharing

Run:

https://www.programiz.com/python-programming/online-compiler/

(29)

Work3: การใช้งาน Electrum

https://elearning.chonburi.spu.ac.th

(30)

Q/A

(31)

Ref.

● https://learnmeabitcoin.com/

● https://github.com/bitcoinbook/bitcoinbook

● https://blockchain.info

● https://mempool.space

References

Related documents

Objectives: We studied the biochemical and biophysical properties of gastric aspirates (GA) from prematurely born infants with NRDS and healthy full term infants with an aim to

He listed the work of other collectors – Frances Tolmie, Lucy Broadwood, Amy Murray, Margaret Fay Shaw, Calum Maclean, the Linguistic Survey of Scotland, and ‘the

These findings, from analysis of the micrographs and C-scan images, imply that the values of critical energy release rate obtained by the area method do not describe accurately

The first one, initiated by Ledoux, relies on functional inequalities, such as Poincar´e or logarithmic Sobolev inequality (see for example [2] or [33]) and has attracted a lot

A public key infrastructure (PKI) manages the distribution of public and private keys and provides a level of assurance for users by maintaining lists of which keys

In this paper, two simple yet powerful user-friendly methods were developed using robust mathematical functions to calculate phase angles of asphalt mixtures from

Equivalently: Traditional keyword-based searching (e.g. Google-based) will take more time than the intention- driven, dialogue-based search method when the user is unfamiliar with

An article on Saturday about an exhibition at the Rose Art Museum at Brandeis University featuring the work of Dor Guez, an artist from Jerusalem whose work is critical of