M4 - Concepts of Bitcoin - Staff
M4 - Concepts of Bitcoin - Staff
- Addresses produced from public keys consist of a string of numbers and letters,
beginning with the digit “1.” eg.: 1J7mdg5rbQyUHENYdx39WVWK7fstLpEoXZy
- appears most commonly in a transaction as the “recipient” of the funds.
- The bitcoin address is derived from the public key through the use of one-way
cryptographic hashing.
- Algorithms used to make a BTC address from a public key are:
- Secure Hash Algorithm (SHA) specifically SHA256
- RACE Integrity Primitives Evaluation Message Digest (RIPEMD), specifically
RIPEMD160.
- A = RIPEMD160 (SHA256(K)), Where K – Public key and A – Resultant bitcoin
address.(160-bit (20 bytes) number.
Key & Addresses
Key & Addresses
- refers to the data structure used to store and manage a user’s keys.
- are two primary types of wallets
- nondeterministic wallet,
- where each key is independently generated from a random number.
- The keys are not related to each other.
- This type of wallet is also known as a JBOK “Just a Bunch Of Keys.”
- deterministic wallet,
- where all the keys are derived from a single master key, known as the
seed.
- All the keys in this type of wallet are related to each other and can be
generated again if one has the original seed.
- The most commonly used derivation method uses a tree-like structure and
is known as a hierarchical deterministic or HD wallet.
Wallets - Nondeterministic (Random) Wallets
- The disadvantage of random keys is that if you generate many of them you
must keep copies of all of them, meaning that the wallet must be backed
up frequently.
- transaction. Address reuse reduces privacy by associating multiple
transactions and addresses with each other.
Wallets - Deterministic (Seeded) Wallets
- wallets that contain private keys that are all derived from a common
seed, through the use of a one-way hash function.
- The seed is a randomly generated number that is combined with other
data, such as an index number or “chain code” to derive the private keys.
- the seed is sufficient
- to recover all the derived keys, and therefore a single backup at
creation time is sufficient.
- wallet export or import, allowing for easy migration of all the user’s
keys between different wallet implementations.
Wallets - Deterministic (Seeded) Wallets
HD Wallets (BIP-32/BIP-44)
- The most advanced form of deterministic wallets is the HD wallet defined
by the BIP-32 standard.
- HD wallets contain keys derived in a tree structure, such that a parent key
can derive a sequence of children keys, each of which can derive a
sequence of grandchildren keys, and so on, to an infinite depth.
Wallets - Deterministic (Seeded) Wallets
- Bitcoin Improvement Proposal 39 wordlist (or
'BIP39' for short) is a standardized set of words
for the recovery and backup of a bitcoin or
cryptocurrency wallet.
- Each word in the list is unique within the first four
letters of each word, meaning no two words on
the list share the same first four letters.
Github : BIP 39
Wallets - Deterministic (Seeded) Wallets
HD Wallets two major advantages over random (nondeterministic) keys.
1. Tree structure can be used to express additional organizational
meaning,
Eg: Branches of keys can also be used in corporate settings, allocating
different branches to departments, subsidiaries, specific functions, or
accounting categories.
1. Users can create a sequence of public keys without having access
to the corresponding private keys.
a. Thus HD wallets to be used on an insecure server
b. The public keys do not need to be preloaded or derived in
advance,
Wallets
Wallet Best Practices
- certain common industry standards have emerged that make bitcoin
wallets broadly interoperable, easy to use, secure, and flexible.
- These common standards are:
• Mnemonic code words, based on BIP-39
• HD wallets, based on BIP-32
• Multipurpose HD wallet structure, based on BIP-43
• Multicurrency and multiaccount wallets, based on BIP-44
- Eg : software wallets : Breadwallet, Copay, Multibit HD, and
Mycelium.
- Eg : Hardware : Keepkey, Ledger, and Trezor.
Wallets
Using a Bitcoin Wallet
Eg:
1. the device generated a mnemonic and seed from a built-in hardware
random number generator. During this initialization phase, the wallet
displayed a numbered sequence of words, one by one, on the
screen
2. By writing down this mnemonic, we can created a backup that can
be used for recovery in the case of loss or damage to the Trezor
device.
3. This mnemonic can be used for recovery in a new Trezor or in any
one of the many compatible software or hardware wallets.
Note : sequence of words is important,
Transaction Outputs and Inputs
- The fundamental building block of a bitcoin transaction is a transaction
output.
- Transaction outputs are indivisible chunks of bitcoin currency, recorded on
the blockchain, and recognized as valid by the entire network.
- Bitcoin full nodes track all available and spendable outputs, known as unspent
transaction outputs, or UTXO.
- The collection of all UTXO is known as the UTXO set and currently numbers in
the millions of UTXO.
- The UTXO set grows as new UTXO is created and shrinks when UTXO is
consumed.
- Every transaction represents a change (state transition) in the UTXO set.
Transaction Outputs and Inputs
Turing Incompleteness
- bitcoin transaction script language contains many operators
- there are no loops or complex flow control capabilities other
than conditional flow control.
- This ensures that the language is not Turing Complete,
- scripts have limited complexity and predictable execution times.
- Script is not a general-purpose language.
- These limitations ensure that the language cannot be used to
create an infinite loop or other form of “logic bomb” that could
be embedded in a transaction in a way that causes a denial-of-
service attack against the bitcoin network.
Transaction Scripts and Script Language
Turing Incompleteness
- Every transaction is validated by every full node on the bitcoin
network.
- A limited language prevents the transaction validation
mechanism from being used as a vulnerability.
Transaction Scripts and Script Language
Stateless Verification
- The bitcoin transaction script language is stateless, in that
there is no state prior to execution of the script, or state
saved after execution of the script.
- Therefore, all the information needed to execute a script is
contained within the script.
- A script will predictably execute the same way on any
system.
- A valid transaction is valid for everyone and everyone knows
this. This predictability of outcomes is an essential benefit
of the bitcoin system.
Transaction Scripts and Script Language
Courtesy : PC Magazine
Transaction Scripts and Script Language