Module 3
Module 3
CSE 2019
Module - 3
Topics
• Bitcoin definition
• Digital keys and addresses
• Transactions, mining
• Bitcoin network wallets
• Bitcoin payments [10Hrs]
[Understand]
• Bitcoin was created by Satoshi Nakamoto, a pseudonymous person
or team who outlined the technology in a 2008 white paper.
• It’s an appealingly simple concept: bitcoin is digital money that
allows for secure peer-to-peer transactions on the internet.
What is BTC?
• BTC is the abbreviation for bitcoin.
Is Bitcoin cryptocurrency?
• Yes, bitcoin is the first widely adopted cryptocurrency, which is just another way
of saying digital money.
Is there a simple bitcoin definition?
• Bitcoin is digital money that allows secure and seamless peer-to-peer
transactions on the internet.
CSE2019 FBT
https://www.slideshare.net/vishavpreet/bitcoin-78160251
5
BitCoin Mechanics
Introduction
• In 2008, Bitcoin was introduced through a paper called, Bitcoin: A Peer-to-Peer Electronic Cash system.
• Bitcoin is a peer-to-peer electronic cash system based on blockchain technology.
• Bitcoin is a protocol maintaining the blockchain data structure and ensuring consensus between
different network parties (sender, recipient, miners, etc.).
• This protocol defines the ruleset for validating the transactions, bitcoin minting, and to avoid
counterfeiting or double spending.
• Bitcoin is referenced as a cryptocurrency, because it uses cryptography to control the creation and
transfer of money. Specifically, it uses digital signatures (based on ECDSA public key encryption) to
process and verify the transactions and cryptographic hash functions (SHA-256) to secure the
blockchain (integrity, mining process, etc.).
• Bitcoin can be defined in various ways; it's a protocol, a digital currency, and a platform. It is a
combination of peer-to-peer network, protocols, software that facilitate the creation and usage of the
digital currency named bitcoin.
• Nodes in this peer-to-peer network talk to each other using the Bitcoin protocol.
7
DEFINITION
• Bitcoin is a decentralized cryptocurrency.
• A bitcoin is a type of digital assets which can be bought, sold, and transfer between the two parties
securely over the internet.
• Bitcoin can be used to store values much like fine gold, silver, and some other types of investments.
• We can also use Bitcoin to buy products and services as well as make payments and exchange values
electronically.
• Bitcoin is digital money that allows for secure and seamless peer-to-peer transactions on the internet.
8
• Nakamoto set the network up so that the number of
bitcoin will never exceed 21 million, ensuring
scarcity.
9
10
Puzz words
• Digital keys
• Addresses
• Transactions
• Blockchain
• Miners
• The Bitcoin network
• Wallets (client software)
11
What is a private key, a public key, and an address?
12
Example
13
Digital Keys and Addresses
• Elliptic Curve Cryptography (ECC) is used to generate public and private key pairs in the Bitcoin network.
Private Keys: Private keys are required to be kept safe and normally resides only on the owner's side. Private keys
are used to digitally sign the transactions proving the ownership of the bitcoins.
• Private keys are fundamentally 256-bit numbers randomly chosen in the range.
• Private keys are usually encoded using Wallet Import Format (WIF) in order to make them easier to copy and use.
Public Keys : Public keys exist on the blockchain, and all network participants can see it.
• Public keys are derived from private keys due to their special mathematical relationship with the private keys.
• Once a transaction signed with the private key is broadcasted on the Bitcoin network, public keys are used by the
nodes to verify that the transaction has indeed been signed with the corresponding private key.
• This process of verification proves the ownership of the bitcoin.
• A public key is 256-bits in length. Public keys can be represented in an uncompressed or compressed format.
• Public keys are fundamentally x and y coordinates on an elliptic curve.
Ref : https://en.bitcoin.it/wiki/Wallet_import_format
14
Addresses
• A bitcoin address is created by taking the corresponding public key of a private key and hashing it twice, first
with the SHA-256 algorithm, and then with RIPEMD-160. (RIPEMD = RACE Integrity Primitives Evaluation Message Digest)
• The resultant 160-bit hash is then prefixed with a version number, and finally encoded with a Base58Check
encoding scheme.
• The bitcoin addresses are 26-35 characters long, and begin with digit 1 or 3.
15
What makes Bitcoin a new kind of money?
• Bitcoin is global.
• Bitcoin is irreversible.
• Bitcoin is private.
• Bitcoin is secure.
• Bitcoin is open.
• Bitcoin is safe.
16
Bitcoin Transaction
• Transactions are at the core of the bitcoin ( BTC) ecosystem.
• Transactions can be as simple as just sending some Bitcoins to a bitcoin address, or it can be quite complex
depending on the requirements.
• Inputs can be thought of as coins being spent that have been created in a previous transaction and outputs
as coins being created.
17
• Coinbase transactions are structured as the first transaction in a block, where the miner includes
a newly minted amount of BTC as a reward for their effort in solving a complex mathematical
problem to validate transactions and create a new block on the blockchain.
• A coinbase transaction is the first transaction in a block. It is a unique type of bitcoin transaction that can be created by a
miner.
• If a transaction is to send coins to some other user (a bitcoin address), then it needs to be signed by the Sender with their
private key, and a reference is also required to the previous transaction in order to show the origin of the coins.
• Transactions are not encrypted and are publicly visible in the blockchain.
• Blocks are made up of transactions, and these can be viewed using any online blockchain explorer.
• The miners use it to collect the block reward for their work and any other transaction fees collected by the miner are also
sent in this transaction.
18
Account-Based ledger Transaction-Based Ledger
Create 25 coins and credit to Inputs : 0
AliceASSERTED BY MINERS Outputs: 25.0 to Alice
Inputs:1[0]
Transfer 17 coins from Alice to Outputs: 17.0 to Bob 8.0 to Alice (signed
BobSIGNED( Alice by Alice)
Transfer 8 coins from Bob to Inputs : 2[0]
CarolSIGNED(Bob) Outputs: 8.0 to Carol 9.0 to Bob (Signed
by Bob)
Transfer 6 coins from Alice to DavidSIGNED( Alice) Inputs : 2[1]
Outputs : 6.0 to David 2.0 to Alice
(Signed By Alice)
19
20
21
Generating a Transaction
Encryption
Decryption
https://www.oreilly.com/library/view/mastering-bitcoin/9781491902639/ch05.html
Transaction Life Cycle
• A user/sender sends a transaction, using wallet software or some other
interface.
• A Blockchain Wallet Is a software that enables sending and receiving
cryptocurrencies such as Bitcoin, Ethereum, etc. It stores the record of transactions
and also public and private keys which are used to perform transactions.
• The wallet software signs the transaction using the sender's private key.
• The transaction is broadcasted to the Bitcoin network using a flooding algorithm.
• Mining nodes (miners) who are listening for the transactions verify and include this
transaction in the next block to be mined. Just before the transaction are placed in the
block they are placed in a special memory buffer called transaction pool.
• Mining starts, which is a process by which the blockchain is secured and new coins are
generated as a reward for the miners who spend appropriate computational resources.
• Once a miner solves the PoW problem, it broadcasts the newly mined block to the
network. The nodes verify the block and propagate the block further, and confirmations
start to generate.
• Finally, the confirmations start to appear in the receiver's wallet and after approximately
three confirmations, the transaction is considered finalized and confirmed
https://www.geeksforgeeks.org/blockchain-transaction-life-cycle/
23
Example:
Transaction Fee
• Transaction fees are charged by the miners.
• The fee charged is dependent upon the size and weight of the transaction.
• Transaction fees are calculated by subtracting the sum of the inputs and the sum
of the outputs. A simple formula can be used: fee = sum(inputs) - sum(outputs)
• The fees are used as an incentive for miners to encourage them to include a user
transaction in the block the miners are creating.
• All transactions end up in the memory pool, from where miners pick up
transactions based on their priority to include them in the proposed block.
• Transaction pools Also known as memory pools, these pools are basically created
in local memory (computer RAM) by nodes in order to maintain a temporary list
of transactions that are not yet confirmed in a block. Transactions are included in
a block after passing verification and based on their priority.
• There are different rules based on which fee is calculated for various types of
actions, such as sending transactions, inclusion in blocks, and relaying by nodes.
• Transaction time is dependent on transaction fees and network activity.
24
Quarterly Chart
25
Transaction Data Structure
Meta
Data
Input
Output
26
Transaction Data Structure
• Meta Data : Size of the Transaction, Number of inputs, Number of outputs, Hash of the transaction
serves as uniqueID for the transaction.
• Inputs: Inputs forms an array, and each input has the same form. An input specifies the previous
transaction, so it contains the hash of the previous transaction which acts a hash pointer to it. It also
contains the index of the previous transaction outputs and signature also.
• Outputs : Again, forms an array. Each output has two fields. Each have a value. The sum of all output
values has to be less than or equal to input values. If sum is less than the input values, the difference is
transaction fee.
27
Transaction Data Structure
• A transaction at a high level contains metadata, inputs, and outputs. Transactions are combined to
create a block. The transaction data structure is shown in the following table :
28
Inputs Structure
Generally, each input spends a previous output. Each output is considered as Unspent Transaction
Output (UTXO) until an input consumes it. UTXO is an unspent transaction output that can be spent
as an input to a new transaction.
Field Size Description
Transaction hash 32 bytes This is the hash of the previous transaction with UTXO.
Output index 4 bytes This is the previous transactions output index, that is, UTXO to be spent.
Script length 1-9 bytes This is the size of the unlocking script.
Unlocking script Variable Input script (ScriptSig) which satisfies the requirements of the locking
script.
Sequence number 4 bytes Usually disabled or contains lock time. Disabled is represented by
'0xFFFFFFFF'.
29
Outputs Structure
30
Inputs : …
1 Inputs : …
Outputs: 17.0→Bob, 8.0→Alice (Signed by Alice) 1
Outputs: 17.0→Bob, 8.0→Alice (Signed by Alice)
Inputs: 1[1] 2
Outputs: 6.0→Carol, Inputs: 1[1] 2
2.0→Bob (Signed by Alice) Outputs: 6.0→Carol,
Inputs: 1[0], 2[1] 3 2.0→Bob (Signed by Alice)
Outputs: 19.0→Bob (Signed by Bob)
Inputs: 2[0], 2[1] 3
Merging Outputs: 8.0→DavidJoint Payments
(Signed by Bob,Carol)
31
Bitcoin Storage and Use Bitcoin
• Storing bitcoins is really all about storing and managing Bitcoin secret keys.
• Three Goals
Availability : Able to actually spend your coins when you want to
Security : Sure that nobody else can spend your coins
Convenience : Key management should be relatively easy to do.
• Different approaches to key management offer different trade-offs between availability, security, and convenience.
• Simple Local Storage
• Store key in a file, on your computer or phone.
Very Convenient, Available, Convenience
• Wallet Software
Software that keeps track of all your coins, manages all the details of your keys, and makes things convenient with a nice
user interface
Software wallets enable crypto holders to securely store their digital currencies and tokens in one place.
Ex : Guarda Wallet, Electrum
To spend or receive bitcoins, you also need a way to exchange an address with the other party — the address to which
bitcoins are to be sent. There are two main ways in which addresses are encoded so that they can be communicated from
receiver to spender: as a text string or as a QR code
32
Hot and Cold Storage
Hot Storage : Hot storage refers to an application or platform that is connected to the internet, and allows you to manage your
cryptocurrency holdings. MetaMask, Exodus
Hot wallets are suited for quick transactions. Storing frequently handling keys.
Cold Storage : It is an offline digital wallet, and is stored on a platform that is not connected to the internet.
Protecting the wallet from unauthorized acesss, cyber hacks etc..
• Need to have separate secret keys for each.
• Can move coins back and forth between the hot side and the cold side.
• Cold storage is not online, and so the hot storage and the cold storage won't be able to connect to each other across any network.
• Cold storage doesn’t have to be online to receive coins — since the hot storage knows the cold storage addresses, it can send coins
to cold storage at any time.
• When a key stored in the cold storage sis required to sign a transaction, the user needs to connect the cold wallet device to
a computer and copy-paste the key in the relevant field
33
34
• Amount in hot storage becomes large, we can transfer that to cold storage without compromising
security.
• Next time the cold storage connects it will be able to receive from the blockchain information about
those transfers to it and then the cold storage will be able to do what it wants with those coins.
• Managing cold storage addresses is difficult.
• So, whenever we transfer a coin from the hot side to the cold side, fresh cold address for that
purpose is used.
• Cold side to generate a big batch of addresses all at once and send those over for the hot side to use
them up one by one.
• The drawback is that we have to periodically reconnect the cold side in order to transfer more
addresses.
35
• Hierarchical wallets
A more effective solution is to use a hierarchical wallet. It allows the cold side to use an essentially unbounded number of
addresses, and the hot side to know about these addresses, but with only a short, one-time communication between the two sides.
• Brain wallet
The second method we can use is called a brain wallet. This is a way to control access to bitcoins using nothing but a secret
passphrase. This avoids the need for hard drives, paper, or any other long-term storage mechanism, The key trick behind a brain
wallet is to have a predictable algorithm for turning a passphrase into a public and private key.
• Paper wallet
The third option is what's called a paper wallet. We can print the key material to paper and then put that paper into a safe or
secure place.
• Tamper-resistant device
The fourth way that we can store offline information is to put it in some kind of tamper-resistant device. Either we put the key into
the devices, or the device generates the key.
Combination of four of these methods in order to secure their keys is the best Solution
36
Hot wallets
Pros: These wallets are online and easy to use and they require no physical storage and no transition between
offline to online for the transaction.
• Hot wallets are accessible as they can be traded from hands-on devices.
• These wallets can accept the various types of tokens and are ideal for traders and users with a good portfolio.
• These wallets are available for free and can be created within a minutes.
Cons: Security is an issue
• Another issue is the security of the private key, which is stored on the internet and the wallet browser .
Cold Wallets
Pros : Cold wallets have a large storage capacity.
• Cold wallets are encrypted with pin protection thus providing an extra layer of security .
Cons: Cold wallets are less convenient than hot wallets because they require power and then to be connected to
the internet. These wallets do not accept as many cryptocurrencies as most hot wallets do.
37
Online Wallet and Exchanges
• An online wallet is kind of like a local wallet that you might manage yourself, except the information is
stored in the cloud.
• Can be accessed using a web interface on your computer or using an app on your smartphone.
• This will help you to access your keys.
• In order to use online wallet in the browser, no special software is required for the access.
• If you are accessing from the phone, you have to install the app once but blockchain is not needed.
• Online wallet works in multiple devices also since the wallet is in cloud.
• Security is a major concern in these type of wallets.
• Site delivers the code also stores the data in browser. Have ability to store the keys.
• Convenience is the big advantage.
• Single wallet can be accessed in both computer and mobile phone.
• https://bitcoin.org/
38
Bitcoin exchanges
• A Bitcoin wallet is basically a software program in which you store Bitcoin. An exchange lets you convert
“real money” like US dollars to Bitcoin.
• A cryptocurrency exchange refers to a website or service where one can sell or buy digital currency or
convert fiat/agreement currency into digital currency.
• They accept deposits of bitcoins and will, just like a bank, promise to give them back on demand later.
• You can also transfer fiat/approval currency — traditional currency like Dollars and Euros — into an
exchange by doing a transfer from your bank account.
• You can direct the exchange to pay out some bitcoins to a particular party, or you can ask someone else
to deposit funds into the particular exchange on your behalf — put into your account.
39
580 X 2 = 1,160
40
Payment Services
Let us discuss how online or local merchant accept payments in bitcoin:
• They can collect bitcoin as a payment from the customer, but they want to convert that into their currency with
low risk.(new technology, exchange rate, security)
• These services act as a bridge between customer and retailer.
• Merchant can create an interface for accepting the payment.
• Merchant goes to payment service and fills the form describing the item, price and so on..
• Payment service creates a HTML code for that, and merchant can drop that in his site.
• When the customer clicks on payment button, customer gets the confirmation for the payment.
• When the customer selects the item to be purchased from the merchant site, merchant will deliver the payment
page with Bitcoin payment button.
• Page will contain the transaction id for the identification of the transaction.
41
Payment Process
42
• User wants to pay with Bitcoin, they will click on that button.
• That will trigger the HTTPs service request to the payment service with the details of the merchant’s
identity, transaction id and amount.
• Now the payment service knows the customer who wants to pay , so that initiates the interaction with the
user.
• It provides user information about how to pay, and then the user can initiate bitcoin transfer to the
payment service from their preferable wallet.
• Once the user has created the payment, payment service will redirect the browser to the merchant with
the confirmation message.
• This will broadcast into peer-to-peer network, but the transaction has not received enough confirmations.
• From the user side, payment process is completed, but shipment of goods from merchant’s side is pending
for the final confirmation from payment service.
• Payment service later directly sends the confirmation to the merchant containing transaction id and
amount.
43
• Then the merchant ships the goods to the user. Finally, payment service sends the amount to the
merchant’s bank account.
• Payment service has to be an active participant in the exchange markets that link together currency
and bitcoin economy
• Constant need to exchange bitcoins and dollars so that it can be cycling.
• Service needs to think about what exchange rate, but also how to exchange currency in large
volumes.
44
0
45
Transaction Fees
• Transaction is put into the Bitcoin BCT, it includes transaction fees.
Transaction fees is difference between Total coins spend into the transaction minus the Total value of coins
that come out.
• The inputs always have to be atleast as big as the outputs, because regular transaction cannot create coins.
• If inputs are bigger than the outputs, the difference is transaction fee.
• This fee goes to the miner who makes the block that includes this transaction.
Why do we need this fee?
• Cost is involved to relay your transaction. Bitcoin nodes need to relay your transaction and miner need to
build your transaction into a block.
• Idea of transaction fee is to compensate miners for those cost incur to process your transaction.
46
Bitcoin Scripts
• Verification is performed using Bitcoin's scripting language. Bitcoin's scripting language is called a stack-
based language because it uses a data structure called a stack. A stack is a very simple data structure that can be
visualized as a stack of cards. A stack allows two operations: push and pop. Push adds an item on top of the stack.
• Bitcoin uses a simple stack-based language called script to describe how bitcoins can be spent and transferred.
• This scripting language is based on a Forth programming language.
• Bitcoin Script is a simple programming language used to interact with the Bitcoin software.
• Script gives the Bitcoin software instructions on how coins in a UTXO (Unspent Transaction Output) can be spent.
• It is evaluated from the left to the right using a Last In, First Out (LIFO) stack.
• Scripts use various opcodes or instructions to define their operation.
• Opcodes are also known as words, commands, or functions.
• A transaction script is evaluated by combining ScriptSig and ScriptPubKey.
• ScriptSig is the unlocking script, whereas ScriptPubKey is the locking script.
• This is how a transaction to be spent is evaluated: 1. First, it is unlocked and then it is spent 2. ScriptSig is
provided by the user who wishes to unlock the transaction 3. ScriptPubkey is part of the transaction output and
specifies the conditions that need to be fulfilled in order to spend the output 4. In other words, outputs are
locked by ScriptPubKey that contains the conditions, when met will unlock the output, and coins can then be
redeemed
47
Bitcoin blocks
• Transactions can be grouped together for optimization.
• If miners had to come to consensus individually, the rate at which new transactions are accepted
by the system would be much lower.
• Hash chain of blocks is much shorter than chain of transactions, since the large number of
transactions can be put in each block.
• This is the efficient way of verifying the blockchain structure.
• Bitcoin block consists of two different structures: First is hash chain of blocks that links with one
another, Second is internal to each block that is Merkle transactions within a block.
48
Simplified Payment
Verification (SPV)
49
Block Header
Transaction data
50
Coinbase Transaction
• A coinbase transaction is the first transaction in a block.
• It is a unique type of bitcoin transaction that can be created by a
miner.
• The miners use it to collect the block reward for their work and any
other transaction fees collected by the miner are also sent in this
transaction.
51
52
What is the disadvantage of Coinbase?
Coinbase is a popular cryptocurrency exchange that allows anyone with an
account to buy, sell, and exchange cryptocurrency. It makes buying crypto
straightforward but is known for high fees and poor customer service.
53
The Bitcoin network
• The blockchain is a distributed, public ledger that contains the history of every bitcoin
transaction.
• Anyone can download a copy of the blockchain, and it can be inspected to trace the path of
bitcoins from one bitcoin transaction to another.
• The Bitcoin network is a peer-to-peer network where nodes exchange transactions and blocks.
• All nodes are equal: No special node or master node.
• There are different types of nodes on the network. There are two main types of nodes, full nodes and SPV nodes.
• Full nodes are implementations of Bitcoin core clients performing the wallet, miner, full blockchain Storage, and
network routing functions.
• Simple Payment Verification (SPV) nodes or lightweight clients perform only wallet and network routing functionality.
• There are a few nonstandard but heavily used nodes that are called pool protocol servers.
• These nodes make use of alternative protocols, such as the stratum protocol. These nodes are used in mining pools.
Nodes that only compute hashes use the stratum protocol to submit their solutions to the mining pool .
• The Bitcoin network is identified by its different magic values. Magic values are used to indicate the message origin
network.
54
Protocol messages
• Version: This is the first message that a node sends out to the network, advertising its version and block count. The
remote node then replies with the same information and the connection is then established.
• Verack: This is the response of the version message accepting the connection request.
• inv: This is used by nodes to advertise their knowledge of blocks and transactions.
• getdata: This is a response to inv, requesting a single block or transaction identified by its hash.
• getblocks: This returns an inv packet containing the list of all blocks starting after the last known hash or 500 blocks.
• getheaders: This is used to request block headers in a specified range.
• tx: This is used to send a transaction as a response to the getdata protocol message.
• block: This sends a block in response to the getdata protocol message.
• headers: This packet returns up to 2,000 block headers as a reply to the getheaders request.
• getaddr: This is sent as a request to get information about known peers. addr: This provides information about
nodes on the network. It contains the number of addresses and address list in the form of IP address and port
number
55
Limitations and improvements
• Hard Coded
• Average time per block
• Size of block
• Number of signature operations in a block(two algorithms)
• Divisibility of the currency
• Total number of bitcoins
• Block reward structure
• Changing the protocol :Hard Forks --Blockchain split,(Old and New)
Soft Forks – Old version accept, new version reject some
Ex : Pay to script hash
• A soft fork is an upgrade to the software that is backward-compatible and has validators in an older version of
the chain see the new version as valid. Effectively, a hard fork, more often than not, leads to a permanent chain
separation, as the old version is no longer compatible with the new version.
56
Innovation in Bitcoin
• Various proposals have been made to improve Bitcoin performance resulting in greater transaction speed,
increased security, payment standardization and overall performance improvement at the protocol level.
• These improvement proposals are usually made in the form of BIPs or fundamentally new versions of Bitcoin
protocols resulting in a new network altogether.
• Bitcoin Improvement Proposals (BIP) : There are three types of Bitcoin improvement proposals.
• Standard BIP: Used to describe the major changes that have a major impact on the Bitcoin system.
Example: block size changes, network protocol changes, or transaction verification changes .
• Process BIP: A major difference between standard and process BIPs is that standard BIPs cover protocol changes,
whereas process BIPs cover usually deal with proposing a change in a process that is outside the core Bitcoin
protocol. These are implemented only after a consensus among bitcoin users .
• Informational BIP: These are usually used to just advise or record some information about the Bitcoin ecosystem,
such as design issues.
57
• Bitcoin Protocol: Bitcoin is the most well-known crypto protocol. It lets people conduct financial transactions
with one another without trusted third parties, such as financial institutions. It enables transactions that
are not reversible and also stops double-spending
• Segregated Witness : Segregated Witness (SegWit) refers to a change in Bitcoin's transaction format, where
the witness information was removed from the input field of the block. The stated purpose of Segregated
Witness is to prevent non-intentional Bitcoin transaction flexibility and allow for more transactions
to be stored within a block.
58
• Bitcoin Cash : Bitcoin Cash (BCH) is an altcoin version of the popular Bitcoin cryptocurrency. Bitcoin Cash is the
result of a hard fork in blockchain technology. One of the most significant changes from Bitcoin to Bitcoin
Cash is the size of the coin.
• Bitcoin Unlimited: Bitcoin Unlimited was intended to improve transaction speed through scale.
It proposed that the size of blocks should be increased and that miners would step up to increase capacity.
Bitcoin Unlimited exists as a client for BitcoinABC, which uses the cryptocurrency eCash.
• Bitcoin Gold : Bitcoin Gold (BTG) is a cryptocurrency. It is a hard fork of Bitcoin, the open-source cryptocurrency. It is an open source,
decentralized digital currency without a central bank or intermediary that can be sent from user to user on the peer-to-peer Bitcoin Gold
network.
59
Bitcoin Core
• Bitcoin Core is open-source software, meaning anyone can view, copy and propose upgrades.
• Bitcoin Core is the most popular software used to connect to the Bitcoin network and run a node.
• Bitcoin Core is the reference implementation for the Bitcoin source code, provides software for both a node
and a wallet.
• Changes to Bitcoin Core only occur with consensus from the network.
• Bitcoin Core is the original implementation of Bitcoin, and it was created by Satoshi Nakamoto in late 2008.
• Bitcoin Core consists of both “full-node” software for fully validating the blockchain as well as a bitcoin wallet.
• It is a direct descendant of the original Bitcoin software client released by Satoshi Nakamoto.
• Bitcoin Core is programmed to decide which block chain contains valid transactions. The
users of Bitcoin Core only accept transactions for that block chain, making it the Bitcoin
block chain that everyone else wants to use.
60
Mining
• Bitcoin mining is the process of discovering new blocks, verifying transactions and adding them to the
Bitcoin blockchain.
• Blocks contain transactions that are validated via the mining process by mining nodes on the Bitcoin
network.
• Blocks, once mined and verified are added to the blockchain which keeps the blockchain growing. This
process is resource-intensive due to the requirements of PoW where miners compete in order to find a
number which is less than the difficulty target of the network.
• This difficulty in finding the correct value (also called sometimes the mathematical puzzle) is there to
ensure that the required resources have been spent by miners before a new proposed block can be
accepted.
• Bitcoin mining is the process of validating the information in a blockchain block by generating a cryptographic
solution that matches specific criteria. When a correct solution is reached, a reward in the form of bitcoin and fees for
the work done is given to the miner(s) who reached the solution first.
61
• To solve the hash puzzle, miners will try to calculate the hash of a block by adding a nonce to the block
header repeatedly until the hash value yielded is less than the target.
• New coins are minted by the miners by solving the PoW problem, also known as partial hash inversion
problem.
• This process consumes a high number of resources including computing power and electricity.
• One new block is created (mined) every 10 minutes to control the frequency of generation of bitcoins.
• This frequency needs to be maintained by the Bitcoin network and is encoded in the bitcoin core clients
in order to control the money supply.
• Miners are rewarded with new coins if and when they discover new blocks by solving PoW.
• Miners are paid transaction fees in return for including transactions in their proposed blocks.
• New blocks are created at an approximate fixed rate of every 10 minutes.
62
Java Practice-Mr. R C Ravindranath, Asst. Prof., SOE-
63
CSE
Tasks of the miners
The role of the miners is to process and confirm transactions to chain together the blocks
of transactions.
• Listen for transaction : Listen for transactions and validate them by checking the signatures are correct and
output being spent haven’t been spent.
• Synching up with the network: Once a new node joins the bitcoin network, it downloads the blockchain by
requesting historical blocks from other nodes.
• Transaction validation: Transactions broadcasted on the network are validated by full nodes by verifying and
validating signatures and outputs.
• Block validation: Miners and full nodes can start validating blocks received by them by evaluating them
against certain rules. This includes the verification of each transaction in the block along with verification of
the nonce value.
• Create a new block: Miners propose a new block by combining transactions broadcasted on the network
after validating them. To do this, group the transactions thar you hear that extends from the latest block.
64
• Perform Proof of Work: This task is the core of the mining process and this is where miners find a valid
block by solving a computational puzzle.
• The block header contains a 32-bit nonce field and miners are required to repeatedly vary the nonce
until the resultant hash is less than a predetermined target
• Fetch reward: Once a node solves the hash puzzle (PoW), it immediately broadcasts the results, and
other nodes verify it and accept the block. There is a slight chance that the newly minted block will not
be accepted by other miners on the network due to a clash with another block found at roughly the
same time, but once accepted, the miner is rewarded with bitcoins and any associated transaction fees.
(50,25,12.5,6.25 bitcoins)
65
Mining Algorithm
• Mining algorithms are the backbone of Bockchain-based networks like Bitcoin and other
protocols.
• In blockchain technology, mining algorithms are necessary for transaction verification and
network security. A mining algorithm instructs miners' computers to follow a set of rules to
generate a valid block.
• A mining algorithm is the set of rules and mathematical operations used by miners on the hashing
process of Proof of Work cryptocurrencies. In order to achieve this, the miner continuously tries
random nonces (number only used once) on the hash function in hopes of finding a valid solution.
What are mining techniques in blockchain?
• The Mining Process. Mining is a complex process, but in a nutshell, transactions are entered into
blocks on the blockchain. The block is assigned some information, and all of the data in the block
is put through a cryptographic algorithm (called "hashing").
66
What are the algorithms used in Bitcoin mining?
• The Bitcoin blockchain uses the SHA256 algorithm, which produces a 32-byte hash.
• Dogecoin and Litecoin both use Scrypt, which is one of the faster and lighter
cryptography algorithms.
69
Mining Hardware
70
• GPU mining, however, has some limitations, such as overheating and the requirement for specialized
motherboards and extra hardware to house multiple graphics cards.
• FPGA Mining : Field Programmable Gate Array (FPGA) is basically an integrated circuit that can be
programmed to perform specific operations.
• FPGAs are usually programmed in Hardware Description Languages (HDLs), such as Verilog and VHDL.
Double SHA-256 quickly became an attractive programming task for FPGA programmers and several
open-source projects started too.
• FPGA offered much better performance as compared to GPUs; however, issues such as accessibility,
programming difficulty, and the requirement for specialized knowledge to program and configure
FPGAs resulted in a short life of the FPGA era for bitcoin mining.
• ASICs: Application Specific Integrated Circuit (ASIC) was designed to perform the SHA-256 operation.
• These special chips were sold by various manufacturers and offered a very high hashing rate.
• Professional Mining: From individuals to professional mining centers.
71
Mining Pools
• A mining pool forms when group of miners work together to mine a block.
• The pool manager receives the coinbase transaction if the block is successfully mined, which is then
responsible for distributing the reward to the group of miners who invested resources to mine the
block.
• This is profitable as compared to solo mining, where only one sole miner is trying to solve the partial
hash inversion function (hash puzzle) because, in mining pools, the reward is paid to each member of
the pool regardless of whether they (more specifically, their individual node) solved the puzzle or not.
• There are various models that a mining pool manager can use to pay to the miners, such as the Pay
Per Share (PPS) model and the proportional model.
• In the PPS model, the mining pool manager pays a flat fee to all miners who participated in the mining
exercise, whereas in the proportional model, the share is calculated based on the amount of
computing resources spent to solve the hash puzzle.
72
Energy Consumption
• Thermodynamic Limits:
Landauer’s Principle: Any non-reversible computation must consume a minimum amount of energy.
SHA-256 is not reversible, so Energy consumption is inevitable!
• Embodied Energy:
Used to manufacture mining chips & other equipment. Raw materials and turning these materials into
Bitcoin Mining ASIC
Should decrease over time – returns to scale
• Electricity: – AISC is powered on and mining, it consumes electricity. Mining rig gets efficient, the
electrical energy will go down.
• Cooling : Energy used to cool off the mining equipment also requires energy.
• Estimating Energy usage :Top down , Bottom Up
73
Mining Incentives and Strategies
• Which transactions to include in a block – Default: any above minimum transaction fee
• Which block to mine on top of – Default: longest valid chain
• How to choose between colliding blocks – Default: first block heard
• When to announce new blocks – Default: immediately after finding the block
74
REFERENCES
75