Blockchain TIC
Blockchain TIC
Source: Blockchain.com
Bitcoin Hash Rate
Considered as
Digital Gold by
market experts.
Token
pegged to
US dollar
ETH staked
in LIDO
liquidity
Token protocol
pegged to
US dollar
Token on
Binance
blockchain
Token on
Cardano
blockchain
Ripple Currency
Token on used as a
XRP ledger tipping
system
Cryptography in Bitcoin
■ p = 2256 – 232 – 29 – 28 – 27 – 26 – 24 – 1
■ Security of Bitcoin is guaranteed by the inefficiency of
Elliptic Curve Discrete Logarithm Problem (ECDLP) solution
for large enough private keys.
i.e. finding the integer k such that P = k * G
Cryptography in Bitcoin
■ Ownership of Bitcoins is established through:
– Digital keys
– Digital signature
■ Use of Asymmetric cryptography in which a pair of keys
(public/private) is used.
■ Public key is used to receive funds and Private key is used to
sign txns to spend funds.
■ Private key, k is a 256 bit random number within 1 and 2256.
■ Public key, P is a point on elliptic curve generated from
private key:
P=k*G
where, G is the generator for the elliptic curve
It is a one-way function and calculating P from k is not possible.
Cryptography in Bitcoin
Public key and Address generation:
Digital Signatures
Amount of Bitcoin
Txn fees = Output bitcoins - Input transferred
bitcoins
Blockchain Transaction
In a Bitcoin txn, each input spends the bitcoins paid to a
previous output.
Receiver’s address
Blockchain Databases
Other than blockchain, each bitcoin client stores these
databases as well:
UTXO set -
■ file that contains all the spendable o/p that are available to
be spent in a txn.
Mempool -
■ file that contains txns which are received by peer nodes but
are yet to be included in any block i.e. unconfirmed txns.
Hashing
Cryptographic hash function used: SHA256
■ In an army, the
generals have to
agree on either
Attack or Retreat.
■ In case of 2 generals,
even if both are
honest, due to
unreliable nature of
communication, the
consensus cannot be
achieved in an
assured manner.
Three Generals’ Problem
■ In case of 3 generals, 1
commander and 2
lieutenants, if 1 is faulty
(Byzantine) and others are
loyal:
– Consensus cannot be
achieved as Lieutenant1
has received conflicting
msgs- Retreat, Attack.
Four Generals’ Problem
■ In case of 4 generals, 1
commander (Byzantine) and
3 lieutenants (honest).
Consensus can be achieved
as the received msgs are:
– Lieutenant1- R, R, A
– Lieutenant2- R, R, A
– Lieutenant3- R, R, A
■ Final decision- Retreat.
Consensus achieved
n Generals’ Problem
It confirms the
transactions in a trustful
manner when enough
computational power is
devoted to block.
Proof of Work
Centralization in Mining:
Due to the costs and logistical issues, ASICs inevitably leads to
powerful mining farms taking over huge % of the hash rate.
So, ASIC resistant mining algorithms (memory-hard
algorithms) are developed:
■ HashCash (BitCoin) : https://github.com/bitcoin/bitcoin
■ Proof of Stake ( Upcoming Ethereum Mining Algo) :
https://github.com/ethereum/casper
CPU, GPU, ASIC Mining
More stake a user has in the system, the more likely it will want
the system to succeed thus expecting honest behavior.
Delegated Proof Of Stake
A blockchain
network is
considered
anonymous as:
each user is
identified by its
address only and
can generate as
many addresses
as required.
Privacy Attacks on Blockchain
Txn 1
Txn 2
Input Outputs
Bitcoin Locking Script
● Locking script is a spending condition placed on a Bitcoin
transaction output.
○ Specifies the conditions that must be met to spend the
output in the future.
○ Also called scriptPubKey, as it usually contains a public
key or bitcoin address (public key hash).
Locking script for Output 1: Locking script for Output 2:
Bitcoin Unlocking Script
● Unlocking script is a script that:
○ Satisfies the conditions placed on an output by a locking
script.
○ Allows the output to be spent.
○ Part of every transaction input.
○ Mostly contains a digital signature produced by the user’s
wallet using its private key.
○ Also called scriptSig as it usually contained a digital
signature.
Bitcoin Unlocking Script
● A script is valid if the top and only element left on the stack
is a 1 (or greater).
Unlocking Locking
Script Script
Executing a Script
■ Sets a condition where N public keys are recorded in the script and
at least M of those must provide signatures to unlock the funds.
■ Also known as an M-of-N scheme, where N is the total number of
keys and M is the threshold of signatures required for validation.
■ General form of a locking script setting an M-of-N multisignature
condition is:
M <Public Key 1> <Public Key 2> ... <Public Key N> N
CHECKMULTISIG
Issues with Multisignature Script
2
04C16B8698A9ABF84250A7C3EA7EEDEF9897D1C8C6ADF47F06CF73370D74DCCA01CDCA79DCC5C39
5
D7EEC6984D83F1F50C900A24DD47F569FD4193AF5DE762C58704A2192968D8655D6A935BEAF2CA23
E3FB87A3495E7AF308EDF08DAC3C1FCBFC2C75B4B0F4D0B1B70CD2423657738C0C2B1D5CE65C97D7
8D0E34224858008E8B49047E63248B75DB7379BE9CDA8CE5751D16485F431E46117B9D0C1837C9D5
737812F393DA7D4420D7E1A9162F0279CFC10F1E8E8F3020DECDBC3C0DD389D99779650421D65CBD
7149B255382ED7F78E946580657EE6FDA162A187543A9D85BAAA93A4AB3A8F044DADA618D0872274
40645ABE8A35DA8C5B73997AD343BE5C2AFD94A5043752580AFA1ECED3C68D446BCAB69AC0BA7D
F5
0D56231BE0AABF1FDEEC78A6A45E394BA29A1EDF518C022DD618DA774D207D137AAB59E0B000EB7E
D238F4D800 5 CHECKMULTISIG
P2SH Script
Documentation: https://solidity.readthedocs.io/en/v0.7.0/
Editors:
Remix- https://remix.ethereum.org/
Visual Studio Code- extensions available for solidity
Ethereum Development Framework
Ethereum Development Framework
Coin.sol
A simple smart contract to
mint and send coins of a
cryptocurrency.
Attacks in Smart Contracts
■ Reentrancy Attacks:
– Less than 3 months after its launch, DAO was hacked and
$60M of ether was stolen.
Attacks in Smart Contracts
Contract code with DAO vulnerability: Contract code exploiting DAO vulnerability:
withdrawBalance() calls itself again and again:
Types of Txns:
■ Funds transfer between EOA.
■ Deploy contract on Ethereum blockchain.
■ Execute a function on a contract account.
Ethereum Txn
From: Txn sender
who initiates this
txn.
Eth Account 1
Eth Account 2
Eth Account 3
Eth Account 4
Ethereum Txn
Client interacts with
DApp deployed on application on
Ethereum blockchain. blockchain.
Cost Ethers. Cost Ethers.
A txn results in change of
Ethereum state.
Validated by miners.
Permissioned Blockchain
■ Hyperledger is an open
source, enterprise-grade
suite of tools and
frameworks for a
permissioned blockchain
solution development.
■ Hyperledger Fabric:
Framework for
developing blockchain
apps with a modular
architecture.
Hyperledger
Both output
addresses belong to
Charlie, but unlinkable
to network.
Monero provides
untraceability by
using Ring
signatures.
Monero- Ring Signatures
Inputs in a txn-
■ Atleast one real participant and other mixins.
■ Mixins are outputs from some previous txns.
■ Ring signature created to sign the txn.
For a verifier, no way to tell who is the real participant, all appears valid
Monero- Ring Signatures
Mixin 1
Real Input
Mixin 2
Mixin 3