Skip to main content
Mastering Bitcoins
Khushboo Chitre (MT17020)
Urvashi Choudhary (MT17062)
Contents
➔ Introduction.
➔ Keys, Addresses and Wallets.
➔ Transactions.
➔ The Blockchain.
➔ The Bitcoin Network.
➔ Mining and Consensus.
➔ Miscellaneous Topics.
➔ Bitcoin Weakness.
➔ Bitcoin Security.
➔ Hyperledger.
INTRODUCTION TOPICS COVERED
➔ Blockchain.
➔ Cryptocurrency.
➔ Bitcoin.
➔ Bitcoin Elements, functioning
and cryptography.
Blockchain
● It is a continuously growing list of records known as “blocks”.
● Each block is linked to the other by storing the hash of the other block.
● Linked and secured using cryptography.
● First described by Stuart Haber and W. Scott Stornetta in 1991.
● Conceptualised by Satoshi Nakamoto in 2008.
● Bitcoin cryptocurrency was the first implementation of the blockchain technology.
● Other applications: Smart Contracts, Identity Records of people etc...
Contains the Hash of previous block
H( )
Block
n
H( )
Block
n-1
……
…..
H(
)
Block
1
Properties of Blockchain
● Immutable Data.
● Decentralized.
● Accessible.
● Time Stamping.
● Tamper Resistance.
● Cryptography.
Cryptocurrency
● Digital asset
● Medium of exchange
● Uses cryptography
● Subset of digital currencies
● Uses decentralized control
Introduction to Bitcoin
● Bitcoin is the first decentralized cryptocurrency.
● It was developed by Satoshi Nakamoto in 2009.
● It holds some specific value and therefore allows us to perform transactions.
● Its protocol stack is available as an open source software and can run on a
number of devices.
● They are completely virtual with no physical existence.
Continued….
● Bitcoin consists of:
○ A decentralized peer-to-peer network (bitcoin protocol).
○ Public Transaction ledger (the blockchain).
○ Set of rules for currency issuance (consensus rules).
○ Mechanism for reaching global decentralized consensus (Proof-of-work).
History of Bitcoin.
2008
In November 2008, a paper
named ”Bitcoin: A Peer-to-Peer
Electronic Cash System” was
published by Satoshi Nakamoto.
2010
Nakamoto handed the
responsibility of the Bitcoin
Core to a group of volunteers.
2008
In August 2008, domain name
“bitcoin.org” was registered.
2009
First implementation by Satoshi
Nakamoto was released.
2017
In August 2017, first
hard-forked version named as
Bitcoin Cash was created.
2017
In November 2017, another
hard-forked version named as
Bitcoin Gold was created.
Bitcoin elements
Peer-to-peer network. Miners
Mining Consensus
Transaction
Mining Reward Keys
1bwhw2b1kj2jk1howb1fkjwbu2bsjkbjei3 rfjrn..
Addresses Digital Public Ledger
How does Bitcoin Function
A digital wallet generates transactions and broadcasts it to the
network
Nodes in the network verify a transaction
1
2
H(
)
Block
Miner creates a candidate block by including all the valid
transactions, adds the hash of the recent block to this block.
Solves a hard mathematical problem known as proof of work to
prove that enough resources have been used in verifying these
transactions.
The miner who computes this mathematical problem first wins
this global election and gets the miner reward.
3
4
5
The block is added to the blockchain where it can be verified by
other nodes. As the number of blocks are added on top of it, the
trust on that block increases.
When a miner wins, he gets a reward and new coins are
generated.
When a block is mined, the block is broadcasted into the network
and this indicates that this block has been mined and the miners
start mining another block.
6
7
8
Cryptography in Bitcoin
Properties of an Ideal Hash function:
1. Collision resistance: Given two inputs a and b, then H(a)!=H(b).
2. Preimage resistance: Given hash h(x), then it should be difficult to find out x.
3. Second Preimage resistance: Given a message ‘a’, then it should be hard to
find out another message b with h(a)=h(b) and a!=b.
Examples of Hash functions: MD-4, MD-5, SHA-1, SHA-2 etc.
Variable size input message Hash Function Fixed Size output
HASH FUNCTIONS
HASH FUNCTIONS CONTINUED...
The two main hash functions used by Bitcoin are:
● SHA-256 (returns 256 bit unsigned integers)
● RIPEMD-160 (returns 160 bit unsigned integers)
● Cryptographic system which uses pair of keys:
○ Public key, which is disclosed to everyone and ensures the authenticity of the
receiver.
○ Private key, which is a secret key which is known only to the owner and ensures that
only the owner can decrypt the message.
● Private and public keys are mathematically related.
● Computationally infeasible to guess private key given a public key.
● Bitcoin uses “Elliptic Curve Multiplication” as the basis for public key cryptography.
Public key for encryptionPrivate key for decryption
PUBLIC KEY CRYPTOGRAPHY
Elliptic Curve Cryptography
● It is a public key cryptography based on elliptic curves.
● Bitcoin uses a specific elliptic curve and set of mathematical constants, as
defined in a standard called secp256k1.
● y 2
= (x 3
+ 7)over(Fp), Where Fp is a very large prime number.
● If P and Q are two points on the curve, R= P+Q is also on the curve.
○ The ‘+’ operation is different from the mathematical operation and its
graphical representation is shown in the image.
○ In case P=Q, the line becomes a tangent and intersects the curve at exactly
only more position.
Img source: https://www.google.co.in/search?q=elliptic+curve+cryptography+picture&source=lnms&tbm=isch&sa=X&ved=0ahUKEwi7ovXR5tPaAhWLgI8KHdH5CL4Q_AUICygC&biw=1476&bih=756#imgrc=z2Qpr_i9-1PkJM:
Generating private Keys
● ‘k’ is the private key.
● ‘G’ is the generator.
● The public key is generated by repeatedly
finding points on the curve that satisfy K = k *
G.
● The point ‘G’ is specified in the secp256k1.
● It is extremely difficult to get ‘k’ from ‘K’.
Image source: Reprinted from “Mastering Bitcoin: Unlocking Digital Cryptocurrencies”
DIGITAL SIGNATURES
● Mathematical technique which is used to validate the authenticity and integrity of
the message.
● Developed by Whitfield Diffie and Martin Hellman in 1976.
● Unique to each signer.
● These are based on Public key cryptography as it uses public/private key pair.
● Digital signature provides authenticity, integrity and non-repudiation of the
communication.
● Before digitally signing the document, it is first hashed using a hashing algorithm.
● Hash converts the message to a fixed length hash which saves the time while
encrypting the message.
Alice
Computes hash
AH78….0000….
Sign using Alice’s Private key
AH78….0000….
AH78….0000
….
Digitally signed by Alice
AH78….0000
….
Sent to Bob
Decrypt using Alice's public key
Compute hash of the document
AH78….0000….
AH78….0000….
If they are same BOB can verify that
the document was digitally signed
by Alice.
KEYS, ADDRESSES
AND WALLETS
TOPICS COVERED
➔ Bitcoin Addresses.
➔ Advanced Keys and Addresses.
➔ Wallets.
Establishing Ownership
BitcoinWallets
Digital Keys
Bitcoin
Addresses
Ownership
Ownership is established through:
● Digital Keys
○ Keys represents the private keys associated
with the user.
● Bitcoin Address
○ Addresses provide a unique pseudonymous
identity.
● Bitcoin Wallet
○ Wallets store the keys and are like a small
database or file.
Bitcoin Private and Public Keys
● In case of Bitcoin, the public key is the Bitcoin address.
● But, not all bitcoin addresses are public keys, they also represent other
beneficiaries.
● Private key is used to generate the public key.
Private Key
A Number Picked at random
Public Key
Derived from Private key
Bitcoin Address
Lorem ipsum dolor sit amet,
consectetur adipiscing.
One way cryptographic function One way hash function
Private Keys
● It is simply a number picked at random.
● Private key is used to create signatures that are used to spend the coins, by proving their ownership.
● Private key must be secure at all times and must be backed up.
● The bitcoin software depends on the operating systems random number generator and produces
256 bit key.
Public Key
● The public key is calculated from the private key using elliptic curve
multiplication, which is irreversible: K = k * G where k is the private key, G is a
constant point called the Generator Point and K is the resulting public key.
Bitcoin Addresses
● A bitcoin address is a string of alphanumeric characters.
● It is derived from the public key.
● It begins with ‘1’.
● A bitcoin address can represensent a person, a company or even a script.
● The bitcoin address is presented in a base 58 number system to the user
which helps in the representation of larger numbers in a very compact way.
Wallets
● Wallets act as a container for private keys.
● It can be stored in the form of simple database or structured files.
● There are two ways of generating a wallet:
○ Deterministic
■ New private key is generated from the hash of previously generated private key.
■ All the keys are sequentially linked together.
■ The first key is known as the seed or master key.
○ Non-deterministic
■ Private key is a number which is randomly generated.
■ It is simply a collection of randomly generated private keys.
Type of Bitcoin wallets (Based on Platform).
● Desktop wallet.
○ Wallets which runs on desktop.
● Mobile wallet.
○ Wallet which can be used on an Android or Apple iOS phone.
○ Simple and easy to use.
● Web wallet.
○ Accessed through web browser.
○ Stores the user’s wallet in a server owned by a third party.
● Hardware wallet.
○ Special type of bitcoin wallet which stores the private keys of the user in secure hardware
device.
● Paper wallet.
○ Also known as cold storage, can be stored in printed form for long term storage.
TRANSACTIONS TOPICS COVERED
➔ Bitcoin transaction.
➔ Types of Transactions.
➔ Input and output.
➔ Locking and unlocking scripts.
➔ Adding transaction to the ledger.
➔ Verification and consensus.
Bitcoin Transaction
● A Transaction has one or more inputs.
● Can have multiple outputs.
● The inputs and outputs do not necessarily add up.
A Transaction is like an entry in the double entry book keeping ledger.
It basically tells the network that the owner of the bitcoin has authorised the transfer of these bitcoins
to another owner.
Input
Amount
Input
Amount
Transaction
Transaction fee
Output
Amount
Output
Amount
Bitcoin Transaction
Input
An input is where the coin value is
coming from, usually a previous
transaction output.
Output
A transaction output assigns a new owner
to the value by associating it with a key.
It imposes a requirement for a signature
for the funds to be redeemed.
This forms a chain of ownership
Alice Pays to Bob
Previous Transaction
Locked against
Alice’s key
Alice signs and
uses the
bitcoins she
owned.
Transaction
Now, Bob needs to
provide the
signature to be able
to use it.
Types of Transactions
Input signed by
Alice
Transaction
Output Amount to
Alice
Output Amount to
Bob
MOST COMMON TYPE OF TRANSACTION
● Payment is made from one address to another.
● Some amount given to new address, change goes back to the owner.
● Has one input and two outputs.
Types of Transactions
Input 1
Transaction Output
AGGREGATING TRANSACTIONS
● Aggregate several inputs to one single input.
● Just like getting a pile of notes exchanged for a single larger note.
● Has multiple inputs and one output.
Input 2
Input 3
Types of Transactions
Output 1
TransactionInput
DISTRIBUTIVE TRANSACTIONS
● Distributes input into many outputs.
● Depicts a scenario of distributing funds in commercial entities.
● Has single input and multiple outputs.
Input 1
Output 1
Output 1
Constructing a Transaction
● Transactions are constructed by the bitcoin wallets.
● The construction can be done offline, even when not connected to the bitcoin
network.
GETTING THE CORRECT INPUT
● The wallet has to find the unspent bitcoin transactions that are locked
with wallets own key.
● A full index client has all the transaction, but its too heavy.
● Wallets usually use lightweight clients which query the bitcoin network to
get the output.
● The response is reference to an unspent transaction.
CREATING OUTPUTS
● The transaction is created in the form of a
script which is locked by the key.
● When Alice pays Bob, the script creates an
encumbrance on the value and can only be
used by Bob, if her provides the key to
unlock it.
● Since, only Bob has the key corresponding
to the address, only he can unlock it and
spend it.
Transaction Visualization
0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2
The resulting transactions is sent to the neighbouring
nodes.
Bitcoin Script
● Not Turing-complete language used to perform bitcoin transactions.
● A script is attached to every transaction.
● The script consists of instructions of how the bitcoins can be used by the
user receiving them.
● A transaction is valid if the value present on the top of the stack is True
(non-zero) when the script ends.
Concept of Locking and Unlocking script
Locking Script Unlocking Script
● Locking Script is present in
the output.
● Locking script consists of
the Public/Bitcoin key which
will generate the destination
address.
● ScriptPub key
● Unlocking script is embedded in
the input which consists of the
digital signature generated by
the sender to prove his/her
identity.
● Also known as scriptSig.
Continued….
● Unlocking script is executed first using the stack.
● If the script is executed without error i.e. no leftovers in the stack, then the
main stack is copied.
● The locking script is executed.
● If the result of the locking script along with the data of the unlocking script
which was copied on the stack is True, then the bitcoins are valid and can be
spent.
Why Script is not Turing-Complete?
● No loops or complex flow control capabilities ensures that the language is
not Turing-Complete.
● In case of Bitcoin, the program needs to be terminated quickly with an
answer that whether the coins can be moved or not.
● Quick termination of program guarantees that DoS (Denial of Service) attack
cannot be performed.
Adding Transaction to the Ledger
TRANSACTION PROPAGATION
● In the bitcoin network, nodes are connected to each other.
● A new unseen transaction is immediately forwarded to other nodes in the network.
● Within a few seconds, a transaction reaches major part of the network.
BLOCK CREATION
● New transactions get added to the temporary pool of unverified transaction.
● Miners add unverified transactions to the pool and calculate a mathematical
problem.
SOLVING THE MATHEMATICAL PROBLEM
● Once a block is ready, miners solve a mathematical problem known as the proof of
work to prove the validity of the new block.
AS MORE BLOCKS ARE ADDED
● New blocks added on top of the mined block add more trust on the block.
1
2
3
4
The decentralized consensus emerges from the
following four processes.
● Independent verification of transactions by the full nodes.
● Independent aggregation of new blocks, by mining nodes couples with
demonstration of proof of work algorithm.
● Independent verification of each block before assembly into the chain.
● Independent selection of the chain with the most cumulative computation
by the miner.
Independent Verification of Transactions
● Each nodes verifies a transaction against a long list of criteria.
○ Transaction syntax and data structures are checked.
○ Input output lists must not be empty.
○ Size of the transaction should be correct.
○ Matching transaction must exist in the pool.
○ Sum of input values must be greater than the output values.
○ And many more …
● These rules can be modified to defend against attacks or to include more
transactions.
Aggregation of Transactions and Mining
● After verification of the transaction, transactions are added to the memory pool or
the mining pool.
● Transactions are added according to new block on the basis of priority, this
ensures old transactions are favoured after some duration.
● The first transaction added to the block is known as generation or coinbase
transaction which contains the reward for mining effort.
100djnd2nx3e3bdhbewkfjbewkjfbxljbfjrbkjxe
Xv3hjev32kxedxjbwkjbwkjbkjbkjcbkwjbq w3
Vx3hjrv23hxkr2brebqjwgrqixhk2nroi3hxriq3
Xvj3rv2j3rxh2dnjqxkbkj3xnriuh croi4cr3rh2
Vxr2k3rx33rjknc v 4iru4voijccbjbjbxjkbrkqxh
Create a new block
Verified Transaction Transaction Pool Candidate Block Mining the block
Validating a new block
● The newly created block is propagated to the network.
● The nodes validates the block by performing some checks, such as:
○ Block data structure is a valid one.
○ The hash of the block header is less than the target value of the difficulty.
○ The block size is less than the acceptable size of the blocks.
○ The first transaction is the coinbase transaction.
● As soon as all the nodes validates the block, it gets added to the blockchain.
THE BLOCKCHAIN TOPICS COVERED
➔ Blockchain.
➔ Structure of Blockchain.
➔ Block Header.
➔ The Genesis Block.
➔ Merkle Trees.
Blockchain
● It is an ordered block of transactions.
● Each block points to its previous block, as it contains the SHA256 hash of its
previous block.
● The previous block is also referred to as the parent block.
● A block can have only one parent block.
● But a parent block can have multiple children block.
● The very first block of the blockchain is known as Genesis block.
Structure of a Block
Table 7-1, The Structure of a Block.
Source: Chapter 7, Mastering Bitcoin.
Block Header
- Version
- Parent’s hash
- Merkle Root
- Timestamp
- Difficulty target
- Nonce
Block Header
Table 7-2, The Structure of the block header.
Source: Chapter 7, Mastering Bitcoin.
Block Identifiers
- Block header hash
- Unique SHA-256 hash generated for every block.
- Block height
- Position of a block in the blockchain.
The Genesis Block
● The first block in every blockchain is fixed.
● This block is known as the genesis block.
● Genesis block is statically encoded in the bitcoin client software.
● The hash of this block is the following :
“000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
”.
Merkle Trees
● Also known as Binary Hash tree.
● It is used in the blocks to store the summary of all the transactions present in the blocks.
● The block header stores the root of the Merkle tree.
Continued…..
● The transactions are present in the leaf
nodes of the Merkle tree.
● These transactions are stored in the
hashed form.
● SHA256 is used to hash the nodes and the
hashing is performed twice.
● The parent node consists of the hash of
its child nodes.
● If there are odd number of transactions in
the block, then the last transaction is
duplicated in order to make the number of
transactions even.
● To search for a specific transaction, only
log2
N hashes needs to be produced where
N is the number of transactions in a block. Fig. 7.2, Calculating the nodes in a Merkle Tree.
Source: Chapter 7, Mastering Bitcoin.
How Merkle Tree ensures the Integrity of a block?
● Only the merkle root is stored in the header.
● It makes sure that the transactions are not modified.
● If any transaction is modified, the root will be modified which changes the block
header and ultimately changes the block hash.
The Bitcoin
Network
➔ Peer-to-Peer Network
Architecture.
➔ Bitcoin Network.
➔ Bitcoin Node.
➔ Full Node.
➔ Simple Payment
Verification Nodes.
➔ Simple Payment
Verification .
➔ Bloom Filters.
Peer-to-Peer Network Architecture
● Bitcoin follows Peer-to-Peer Network Architecture.
● Peer-to-Peer Network Architecture is also known as P2P.
● In P2P architecture, all the participating nodes in the network are treated
equally.
● All the nodes are peers to each other.
● All the nodes are responsible in providing the same amount of services to the
network.
● These nodes are connected in the form of mesh topology.
● The network is not centralized.
The Bitcoin network represents the collection of nodes which are using the P2P
Network Architecture.
The Bitcoin Network
Bitcoin Node
● The Bitcoin nodes are treated equally in the Network.
● But the nodes can play different roles in the Bitcoin Network.
● The Bitcoin node is a collection of:
○ Routing (Network node).
○ The Blockchain database.
○ Miner.
○ Wallet services.
Full Node
● Full node consists of all the four functions which are mentioned in the
previous slide.
● It also consists of the complete copy of the blockchain with all the
transactions.
● Full nodes can perform the independent verification of the transactions.
● It waits for the updates from the network about the new transactions, verifies
them and adds it to the local copy of the blockchain maintained by the full
nodes.
● Bitcoin Core is the most popular implementation of the Full node clients.
Simple Payment Verification (SPV) Nodes
● A node which only consists of the Wallet and the Network node.
● It maintains only a subset of the blockchain.
● These nodes uses a method for the verification of the transactions known as
Simple Payment Verification.
● These are also known as Light-weight Clients.
● These nodes does not hold the entire block instead it holds only the header of
each block.
Simple Payment Verification
● It is used by some lightweight power-space constrained devices, which
cannot download the entire blockchain.
● SPV nodes verify transactions by relying on the peers to provide partial views
of relevant parts of the blockchain ondemand.
What is it?
This technique verifies whether a transaction has been included in the blockchain or not,
without actually downloading the entire blockchain.
Continued….
● An SPV node needs to download the copy of the block header of the longest
proof of work chain.
● Then the transactions are verified by referencing to their depth in the
blockchain instead of their height.
● SPV nodes establish a link between the transaction and the block that
contains it using a merkle path.
Some important points:
- SPV cannot be persuaded that a transaction exists when it does not.
- An SPV node can definitely prove that a transaction exists but cannot verify that
transaction, such as a double-spend of the same UTXO, doesn’t exist because it
doesn’t have a record of all transactions. This type of attack can be used as a
Denial-of-Service attack or as a double-spending attack against SPV nodes.
- To defend against this, an SPV node needs to connect randomly to several nodes, to
increase the probability that it is in contact with at least one honest node.
Risk involved in SPV
● SPV nodes checks whether a transaction is present in the blockchain or not
by querying about the specific transaction to all of its peers.
● This involves privacy issue, as this can reveal the address of its wallet.
To overcome the Privacy issue, a feature known as Bloom Filters was
introduced.
Bloom Filters
● Probabilistic data structure because it definitely tells that the element is not
present or may be present in the set.
● False positive results are possible due to collision property of the hashing
function.
● It is possible that two values may generate the same hash and one of the
value may not be present in the set but the filter gives the result that the
element may be present in the set.
What is it?
Bloom filter is a space efficient probabilistic data structure, that is
used to test whether an element is a member of a set.
How are bloom filters used by SPV nodes?
● SPV nodes ask their peers about a specific pattern which matches the
needed transaction without actually disclosing the entire public address.
● SPV node initializes the bloom filter as empty and it does not matches any
pattern in this state.
● SPV node will then make a list of all the address present in its wallet.
● Creates search pattern matching of the transactions to each address.
Continued….
● To check whether a transaction is present in the blockchain or not following
steps takes place:
○ Generate hash of the transaction.
○ Check the pattern of the block headers which are created after the wallet has been generated.
○ If the pattern of the transaction matches any of the pattern of the block headers, then the filter
says that the transaction may be present in the block.
○ Else it returns a result saying the transaction is not present in the block.
Example of Bloom Filter
● Let the bit vector be as the following:
● To add an element to the Bloom filter, the
value is hashed few times and the value of
the bit vector is set to 1 depending on the
hashed value.
● When the input string is “hello”, the bit
vector changes to the following:
● To test the membership of the value, hash
the value using same hash function and
check whether the pattern matches the bit
vector or not.
Mathematics of Bloom Filter
● Let k be the number of hash functions, m be the total number of bits in the
vector and n be the number of items in the set.
● Probability that certain bit will still be 0 after 1 insertion= (1-1/m)k
.
● Then, after n insertions the probability will be (1-1/m)kn
.
● So, the probability of false positives= (1-(1-1/m)kn
)k
.
MINING AND
CONSENSUS
TOPICS COVERED
➔ Mining.
➔ Proof-of-Work.
➔ Difficulty.
So Far
● Wallets
● Transactions
● Propagated to network
● Candidate block created by miner
Let’s start mining!
What is mining?
● Hash pattern generated cannot be determined in advance.
● A pattern cannot be created that will create a particular hash value.
● This ensures that the hash can be generated only by modifying the value in
the block and try again and again, until the hash matches the target value by
chance.
The process of hashing the block repeatedly, after changing a parameter in the block so
that the hash obtained matches a specific pattern or a target value.
Bitcoin Mining
Mining serves two purposes:
● New coins are created. It is like printing of new notes. The amount of coins
created per block are fixed and diminish over time.
● Ensures a block is confirmed only when enough computational power has
been devoted to it.
Proof of Work
Mining is the process of creating a new block, and solving a computationally intensive mathematical problem.
This mathematical problem is known as the “Proof of Work”.
Mining Diagrammatically
Block Data
Transaction Header Compute Hash of the block header
Matches target
hash pattern
Block Mined
Yes
No
Modify the content of the block
Nonce
How is block modified to get different hash values?
● The block header contains a file called nonce.
● This nonce is like a counter and after every iteration of the block is not mined,
it is incremented.
● Even a small change creates a completely different hash, therefore while
mining only the nonce value is modified.
Hashing while mining
● The hash function used is SHA-256.
● Only the header of the block is hashed.
● Since the merkle root is included in the hash it is not necessary to calculate
hash of the entire block.
Proof of Work
Block
------------------------------------
------------------------------------
------------------------------------
------------------------------------
Nonce String
Choose a Nonce String Compute Hash
If Hash <Target Add block to block
chain
If Hash > Target
● The probability of a miner of finding the correct solution/hash depends on the computational power of the
resources he/she has.
● More the computational power, more strings can be generated and hence the probability of finding the
solution increases.
● When the Miner finds valid solution, the solution is broadcasted to the entire network.
● The other nodes validates the solution and the block is added to the blockchain.
● The Miner gets the reward and transaction fee.
Mining Difficulty
● Bitcoin difficulty is adjusted every 2 weeks i.e. after generation of 2016 blocks.
next_difficulty = previous_difficulty * 2-weeks /time to mine last 2016 blocks
● Difficulty depends on the number of nodes present in the Bitcoin network, as the number of nodes
increases the difficulty increase i.e. the target value becomes much smaller.
MISCELLANEOUS
TOPICS
TOPICS COVERED
➔ CAP Theorem.
➔ Multi-Signatures.
➔ Hardware Wallets.
➔ Ethereum.
➔ Ethereum vs Bitcoin.
➔ Litecoin.
➔ Litecoin vs Bitcoin.
➔ Hard-forking.
CAP Theorem
● Proposed by Eric Brewer, (Symposium on Principles of Distributed Computing, 2000).
● Proven by Seth Gilbert and Nancy Lynch in 2002.
Theorem
It is impossible for a distributed data store to achieve more than two of the following
properties simultaneously: Availability, Consistency and Partition Tolerance.
Availability Consistency Partition Tolerance
Every request receives a
(non-error) response- without
guarantee that it contains the
most recent write.
Every read receives the most
recent write or an error.
The system continues to operate
despite an arbitrary number of
messages being dropped(or
delayed) by network between
nodes.
Fig(1): Pictorial representation of CAP theorem
Source:https://www.google.co.in/search?client=ubuntu&channel=fs&dcr=0&biw=1853&bih=928&tbm=isch&sa=1&ei=zfCQWpLRO4mP8wX8hLaA
Dw&q=cap+theorem&oq=cap+theorem&gs_l=psy-ab.3...48402.48402.0.48604.1.1.0.0.0.0.0.0..0.0....0...1c..64.psy-ab..1.0.0....0.Elq3o2_Ld-E#img
rc=cUR_a47RWUvYtM
CAP Theorem and Blockchain
● In case of distributed ledger, the CAP properties mean:
○ Availability
■ Network accepts transactions at any time.
○ Consistency
■ All nodes have the same ledger at the same time.
○ Partition Tolerance
■ Network is resistant to the node failure.
Continued…..
● Only two properties can be picked.
● C A System:
○ Partition Tolerance sacrificed.
○ Bitcoin can only run on networks that can reliably deliver messages.
● C P System:
○ Availability sacrificed.
○ If there is a problem in connectivity, Bitcoin read write operations cannot be performed.
● A P System:
○ Consistency sacrifice.
○ We can send a transaction but it may or may not be received by other parties.
Which CAP property is sacrificed by blockchain?
● Consistency is sacrificed.
● Because:
○ Availability and Partition tolerance are revenue generating properties.
○ Eventual consistency can be achieved by fixing transactions, in the case
of blockchain with the help of consensus.
Difference between strong consistency and eventual consistency.
A Transaction
Application
Always consistent with the database.
A Transaction
Application
Transactions are not guaranteed to be written
onto the database.
Queued, not written on
to database right away.
May or may not be
consistent at this point.
Consistently written on
the database.
Always
Consistent.
How is Eventual Consistency achieved in Bitcoin System?
● Eventual consistency states that the system eventually gets consistent after a
specific amount of time.
● In the bitcoin system, whenever a new block is generated by the miner, miner
adds the block into his/her copy of the blockchain and sends the block to
other miners for the validation purpose.
● As soon as the miner gets some confirmations, the block is added to the
global ledger after a specific amount of time.
● The average time taken by the bitcoin system to add a block to the blockchain
is 10 minutes.
● So, in this way the Bitcoin system eventually becomes consistent.
Consistency and Bitcoin system
● The Bitcoin system achieves eventual consistency and not the strong
consistency.
● We can conclude that at a specific point of time, the bitcoin system becomes
consistent, available and partition tolerant.
Introduction to Multi Signatures
● Multi Signature refers to the requirement for a transaction to have two or
more signatures before it can be executed.
● Also referred to as M-of-N transactions (Multisig).
● Some of the applications of Multisignature are:
○ 2-of-2: Husband and wife savings account, requires the signatures of both the account holders
to perform the transactions.
○ 2-of-3: Parent’s saving account for the child, requires the signature of one of the parent along
with the signature of the child.
● It is more secure as compared to the single signature transaction.
Multi Signatures in Cryptocurrencies
● The first multisignature wallet was launched in August 2013 by BitGo.
● In 2011 and 2012, Bitcoin 1.5 protocol was introduced which uses
multisignature transactions.
● Bitcoin uses 2-of-3 addresses which means that to perform a transaction 2
out of 3 signatures are enough.
● It requires multiple users to sign a transaction before it is broadcasted to the
bitcoin network.
● The above point implies that it requires multiple private keys to authorize the
transaction.
Continued….
● The required number of signatures is agreed at the start, once people agree to
create the address.
● In layman terms, we can say that the wallet is now being shared with the
multiple users.
● Multisignature in bitcoin is just a tuple of distinct user’s signatures.
Additional Points
- Standard transactions on bitcoin network are single signature transactions, however
complex multisig transactions can be supported.
- Some multisig bitcoin wallets are: Armory (Desktop Wallet), Electrum (Mobile/Desktop
wallet), Copay (Mobile and Desktop wallet).
Advantages of using Multi Signatures
● Adds additional layer of security for cryptocurrency transactions.
○ With 2-of-2 address, the two private keys can be kept on two different machines.
○ An attacker will now need two private keys in order to perform identity theft.
○ As the keys are kept on two different machines, it becomes difficult for an attacker to steal
both the private keys.
● More flexible.
○ With 2-of-3 address, any two out of three keys are sufficient to authorize a transaction.
○ If the user losses any one of the three keys, then it is still possible for the user to use two keys
and authorize the transaction.
Hardware Wallets
● It is a special type of bitcoin wallet which stores the private keys of the user in
secure hardware device.
● Major advantages are:
○ Stored in protected area of microcontrollers and are never sent out of the device in the form of
plaintext.
○ Immune to computer viruses which steals information from the software wallets.
○ Generally, the software is open source which allows the user to validate the entire operation of
the device.
○ The hardware device will confirm every transaction by the user before performing it.
TREZOR- The Bitcoin safe
● It is a secure bitcoin storage.
● It generates private keys and stores them as well in a secure manner.
● As the keys are stored in a hardware device, it cannot be attacked by a
malware.
● It can store unlimited keys.
● When the device is initialized, it generates a recovery seed.
● This recovery seed can be used if the device gets lost.
● All the data stored in the device can be retrieved in the another device using
the seed.
● It prevents keylogging when a PIN or any sensitive information is entered.
Ledger Nano- S
● Secure bitcoin hardware wallet.
● Can be connected to the computer through the USB.
● Consists of open source embedded bitcoin App.
● Built-in 4 digit security pin.
● USB connectivity.
● Generates a seed (12/18/24 words) to ensure easy recovery.
● Consists of small OLED display.
● Some other Hardware wallets such as Keep Key, Bitlox, Digital Bitbox etc.
Ethereum
● Initially described by Vitalik Buterin in a white paper(2013).
● Ethereum is:
○ an open source,
○ public,
○ blockchain based distributed computing platform,
○ Operating system featuring smart contract (scripting) functionality.
● Formal development of the Ethereum software project began in early 2014
through a Swiss Company, Ethereum Switzerland GmbH (EthSuisse).
● Development was funded by an online public crowdsale during July–August
2014, with the participants buying the Ethereum value token (ether) with
another digital currency, bitcoin.
Continued….
● Ethereum enables developers to build and deploy decentralized applications.
● Ether is the cryptocurrency which generated on Ethereum platform.
● Miners work to earn Ether.
● The transaction fees are also paid in the form of Ether.
● Ethereum is a whole network, and has its own:
○ Internet Browser.
○ Coding language.
○ Payment system.
Bitcoin vrs. Ethereum
Bitcoin
● Peer-to-peer electronic cash system which
enables online bitcoin payments.
● Block time is 10 minutes.
● Rate of generation of new bitcoins halves
every 4 years.
● Transaction fees is higher.
● It uses Proof-of-work technique.
● It works on UTXO scheme.
● The language used for Bitcoins is not
Turing-complete.
Ethereum
● Focuses on running the programming
code of any decentralized system.
● Block time is 14 to 15 seconds.
● Rate of generation of new Ether remain
constant except during hard-forking.
● Transaction fee are generally lower.
● Wants to shift to Proof-of-Stake technique.
● It does not rely on UTXO scheme.
● The language used for Ethereum is
Turing-complete.
Hard-Forking
● Change to the protocol which makes the previously invalid transaction/blocks valid or vice versa.
● Permanent divergence from the previous version of the blockchain.
● Blocks generated from the previous version will no longer be treated as valid.
● All the nodes/users need to update their version of blockchain.
● Hard forking is helpful to overcome the limitations of the previous versions.
Bitcoin Gold
● Created by Jack Liao.
● Hard forked version of bitcoin.
● Purpose is to allow everyone having the GPU graphic cards to become the member of bitcoin
network and participate in bitcoin mining.
● But the problem with Bitcoin Gold is:
○ Still in the development stages.
○ Does not provide enough resources to the users.