Unit-II
Unit-II
– IOE411
Bitcoin core
Coinbase
Electrum
Blockchain.info
Exodus
Mycelium
https://www.thebalance.com/best-bitcoin-wallets-4160642
Categories of Bitcoin wallets – Based on
Platforms
• Desktop wallet
• Runs on general use OS such as Windows and Mac OS.
• Has a few security disadvantages.
• Mobile wallet
• Runs on smartphones such as Apple IoS or Android.
• Ease-of use, simplicity.
• Web wallet
• Runs through webbrowser and store the user wallet on a
server owned by third party.
• It is not advisable to store a large volume of bitcoins on web
wallet.
Categories of Bitcoin wallets – Based on
Platforms
• Hardware wallet
• These are devices that operate a secure self-contained bitcoin
wallet on special-purpose hardware.
• Paper wallet
• The keys controlling bitcoin can also be printed for long-term
storage. These are known as paper wallets.
Categories of Bitcoin wallets – Based on
Degree of Autonomy
• Full node wallet
• It is a client that stores the entire history of bitcoin
transactions.
• A full node handles all aspects of the protocols.
• Lightweight wallet
• A lightweight client (also known as simple-payment-
verification client) connects to bitcoin full nodes for access to
the bitcoin transaction information.
• Third-party API client
• Here, a third party API client interacts with bitcoin through a
third-party system (i.e, the client will not be connected with the
bitcoin network directly)
How to get bitcoins?
• Buy bitcoins online
• Eg. coinbase
• Buy bitcoins in person
• Use websites like Coin ATM Radar
• Use websites like LibertyX
• Use websites like LocalBitcoins
• Get bitcoins for free
• Play mobile or online games
• you can join a bitcoin casino
• Do online jobs to earn bitcoins (e.g., Bitcoinget, Bitfortip)
• Read classic books to earn bitcoins (e.g, Bitcoin Aliens,
PaidBooks)
• Write about cryptocurrency to earn bitcoins (E.g, Bitcointalk,
Coinality).
https://blog.hubspot.com/marketing/how-to-get-bitcoins
Who sets the bitcoin price?
• Bitcoin is like a commodity.
• Its price is determined by the market in which it
trades.
• i.e. the price of bitcoin is determined by how much someone
is willing to pay for that bitcoin.
• When the currency was first launched, it had no official
price at all, because no one was selling it for US
dollars.
• It started small, at around 6 cents, and didn’t hit a full
dollar until around February 2011.
• It started climbing rapidly, reaching over $140 that
April, and then topping $1,000 by December of 2013.
Current Status…
https://www.coindesk.com/price/bitcoin
BitCoins
• Money transfer (Centralized)
• Decentralized issues
• Double spending
• What is bitcoin?
• Public ledger.
• Issues to consider:
– Tamper-proof
– Size of ledger
– Maintain anonymity
Bitcoin Transactions
• Transactions are the most important part of the bitcoin
system.
• Transactions are data structures that encode the
transfer of value between participants in the bitcoin
system.
• Each transaction is a public entry in a bitcoin system.
What they contain? See via.Blockchain explorer
Input=output
https://www.blockchain.com/btc/tx/06decc8f081ef6323cfd53835f798edc0d7afcfeebd8dbc1158817ce1066b281
https://live.blockcypher.com/btc/tx/06decc8f081ef6323cfd53835f798edc0d7afcfeebd8dbc1158817ce1066b281/
Transaction Inputs/Outputs
• Every transaction outputs are indivisible chunks of
bitcoin currency that are recorded in a public
blockchain and recognized as valid by the entire
network.
• As like USD has two decimal points to represent
cents, bitcoins have 8 decimal points to represent
BTC.
• Each wallet has Unspent Transaction Outputs
(UTXO).
• Transaction outputs consists of two parts:
• An amount of bitcoin.
• Cryptographic addresses
• Each transactions have two outputs:
• To modify your wallet
• To modify others wallet
Transactions – contd…
• Transactions include transaction fees
• Fees (or incentives or rewards) compensate
– the bitcoin miners for securing the network.
– The security software to protect attackers (who could flood the
network with unnecessary transactions).
• Fees are not included in the transaction datastructure.
However,
– Fees = Sum(inputs) – Sum(outputs)
• A new block containing transactions is mined every 10
minutes on average (before adding into the ledger).
• Transactions include status information
• Confirmed (validated by miners)
• Unconfirmed transaction (not yet validated)
Outcome of transactions…
• If person X has 1 BTC and transfers 0.25BTC to
person Y (who has 0.25BTC in his wallet).
• To confirm the transaction is valid, the Bitcoin network
will “ask” the full nodes to confirm
• if person X has enough coins and
• how much person Y will have after the transaction.
• Once valid, the transaction will be evaluated by miners
to add the information to a block.
Keys and Addresses
• Bitcoin is based on cryptography (i.e., secret writing).
• Ownership of bitcoin is established through
Digital
keys
Digital Bitcoin
signatures addresses
Digital Keys
• Digital keys are generated and managed by the user’s
wallet software.
• Keys are represented in pairs (private and public key).
• Analogous example
• Public key – similar to bank account number
• Private key – secret PIN number
• Bitcoin address – Pay to (address to whom you need to make
the transaction).
Public key cryptography
• It was invented in 1970.
• They are mathematical functions
• They are practically irreversible (ie., easy to calculate in one
direction; not possible to calculate in the opposite direction).
• In general, keys are utilized to provide encryption.
Plaintext + key = ciphertext:
hello + 2jd8932kd8 = X5xJCSycg14=
• In a public-key
encryption system, anyone
with a public key can encrypt a
message (Wikipedia).
• But, only those who know the
corresponding private key can
decrypt the ciphertext to obtain
the original message.
• Hence, it is named as
asymmetric encryption
technique.
Public key cryptography
• A bitcoin wallet will contain a collection of key pairs
(i.e., private and public key).
Bitcoin P2P network
• Bitcoin is structured as a P2P network architecture on
top of the internet.
• Bitcoin P2P network consists of computing nodes.
• i.e., A bitcoin network refers to the collection of nodes
running the bitcoin P2P protocol.
• Ie. There is no centralized service, centralized server,
or hierarchy within a network.
Bitcoin Nodes and Functions
• A blockchain node is responsible for a collection of
functions such as
• Routing, Peer discovery
• Blockchain database, initial block download
• Mining
• Wallet services
• Types of nodes (as similar to wallets) in a bitcoin
network
• Full node
– It maintains a complete copy of the blockchain (MBs)
• Lightweight nodes 0r SPV nodes
– Some nodes maintain only a subset of the blockchain and verify
transactions using the Simplified Payment Verification (SPV).
• Mining nodes
– They compete to create new blocks by running Proof of Work
algorithm.
Bitcoin nodes and functions
Block Generation at Bitcoins
• What is a blockchain?
• Blockchain is a data structure.
• It is an ordered, back-linked list of blocks of transactions.
(NOTE: The transactions are ordered…)
• What is a block?
• A block is a bunch of transactions that have been added to a
blockchain.
• As of Feb. 22, 2024, there are 831639 blocks.
• A blockchain can be stored as a flat file or in a simple
database.
• A blockchain is visualized as a vertical stack …
• with blocks layered on top of each other, and
• The first block serves as the foundation of the stack.
How are blocks formed?
• When you make a bitcoin transaction, it isn’t added to
the blockchain straight away. Instead, it is held in a
transaction pool (or memory pool).
How are blocks formed?
• If you are a miner, your job is to gather transactions
from the transaction pool in to a “candidate block”, and
to try and add this candidate block to the blockchain.
Structure of a block
• A block is a container data structure that aggregates
transactions for inclusion in the public ledger.
• The block header is 80 bytes.
• An average transaction is atleast 250 bytes.
• An average block contains more than 500
transactions.
• A complete block, with all transactions is over 1000
times larger than the block header.
Structure of a block
https://www.investopedia.com/news/what-genesis-block-bitcoin-terms/
Mining and Consensus
• Bitcoin’s consensus is a decentralized mechanism.
• 4 processes are involved :
• Independent verification of each transactions (by every full
node).
• Independent aggregation of those transactions into new
blocks (by mining nodes)
• Independent verification of new blocks (by all nodes) and
assembly into the chain.
• Independent selection of the chain with the most cumulative
computation demonstrated through Proof-of-Work.
Independent Verification of Transactions
The transaction’s syntax and data structure
Is the sum of input value is less than the sum of Functions such as
output values?
i) AcceptToMemoryPool,
• bitcoin-cli getmininginfo
PoW – Puzzle – the Mathematical Problem
• Why the mathematical problem should be difficult to
solve?
• If anyone could produce as many Bitcoin as they wanted at
anytime, Bitcoin would be worthless...
• The Bitcoin algorithm releases some Bitcoin to a winning
member of its network every 10 minutes, with a maximum
supply to be reached in about 122 years (i.e., around year
2131).
• This release schedule also controls inflation to a certain
extent, since the entire fixed supply isn’t released at the
beginning.
Proof of Work -- Math
• One-way cryptography takes in a human readable
input like “Hello world” and applies a function to it (i.e.
the math problem) to produce an indecipherable
output (verifiable output).
• These functions (or algorithms) vary in nature and
complexity.
• The more complicated the algorithm, the harder it is to
reverse engineer.
• Eg. SHA-256
• http://www.xorbin.com/tools/sha256-hash-calculator
Cryptographic Hashes - Math
• Try hashing “Hello world” over and over again. You get
the same hash every time.
• A fundamental property of cryptographic algorithms is
that they should be extremely hard to reverse engineer
to find the input, but extremely easy to verify the
output.
https://medium.com/@mycoralhealth/code-your-own-blockchain-mining-algorithm-
in-go-82c6a71aba1f
What is PoW?
• A proof of work is a consensus algorithm in which it’s
costly and time-consuming to produce a piece of data,
but it’s easy for others to verify that the data is correct.
• How complex a puzzle is depends on
• the number of users,
• the current power and
• the network load.
https://cointelegraph.com/explained/proof-of-work-explained
PoW systems
• 2 major systems apply PoW
• Bitcoin
• Ethereum
• The puzzle applied in the PoW of bitcoin is called as
hashcash puzzle.
• Hashcash algorithm allows changing the complexity of
a puzzle based on the total power of the network
• i.e., it maintains the avg block formation to 10 minutes.
Disadvantages of PoW
• PoW consensus algorithm has several drawbacks
• Useless Puzzle or mathematical problem (Miners do a lot of
work to generate blocks and consume a lot of power.)
• Huge expenditures. Mining requires highly specialized
computer hardware to run the complicated algorithms.
• 51% Attack: A 51 percent attack, or majority attack, is a case
when a user or a group of users control the majority of mining
power.
– The attackers get enough power to control most events in the
network.
– They can monopolize generating new blocks and receive rewards
since they’re able to prevent other miners from completing
blocks.