0% found this document useful (0 votes)
15 views64 pages

Bit Coin Platform

Bitcoin is a decentralized digital currency system that operates without a central authority, using a peer-to-peer network for transactions. It involves a mining process to create new bitcoins and maintains a public ledger known as the blockchain to record all transactions. Bitcoin transactions are structured as inputs and outputs, allowing for the transfer of value between users while incorporating security features like digital signatures and transaction fees.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views64 pages

Bit Coin Platform

Bitcoin is a decentralized digital currency system that operates without a central authority, using a peer-to-peer network for transactions. It involves a mining process to create new bitcoins and maintains a public ledger known as the blockchain to record all transactions. Bitcoin transactions are structured as inputs and outputs, allowing for the transfer of value between users while incorporating security features like digital signatures and transaction fees.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Bitcoin

Dr. Javed Ahmed


▪ Bitcoin is a collection of concepts and technologies that form the basis of a
digital money ecosystem
▪ Bitcoin is a distributed, peer-to-peer system. As such there is no “central” server
or point of control.
▪ Bitcoin are created through a process called “mining,”
▪ Essentially, bitcoin mining decentralizes the currency-issuance and clearing functions
of a central bank and replaces the need for any central bank
▪ Every 10 minutes, on average, a bitcoin miner is able to validate the transactions of
the past 10 minutes and is rewarded with brand new bitcoin
▪ The protocol also halves the rate at which new bitcoin are created every 4 years
▪ Limits the total number of bitcoin that will be created to a fixed total just below 21
million coins (21 million by the year 2140).
▪ Units of currency called bitcoin are used to store and transmit value among
participants in the bitcoin network
▪ Bitcoin in a sense is the perfect form of money for the internet because it is
fast, secure, and borderless
▪ Unlike traditional currencies, bitcoin are entirely virtual. There are no physical
coins or even digital coins per se. The coins are implied in transactions that
transfer value from sender to recipient
▪ Users of bitcoin own keys that allow them to prove ownership of bitcoin in the
bitcoin network
▪ Keys are often stored in a digital wallet on each user’s computer
or smartphone
▪ Behind the scenes, bitcoin is also the name of the protocol, a
peer-to-peer network, and distributed computing innovation
▪ Bitcoin consists of:
▪ A decentralized peer-to-peer network (the bitcoin protocol)
▪ A public transaction ledger (the blockchain)
▪ A set of rules for independent transaction validation and
currency issuance (consensus rules)
▪ A mechanism for reaching global decentralized consensus on the
valid blockchain (Proof-of-Work algorithm)
▪ To spend or receive bitcoin, you also need a way to
exchange an address with the other party
▪ There are two main ways in which addresses are encoded
▪ Text string
▪ 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa
▪ QR code
▪ a simple kind of 2-dimensional barcode
▪ 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 bitcoin’s blockchain
▪ Alice wants to buy cup of coffee at Bob’s shop
▪ Bob’s Cafe recently started accepting bitcoin payments
▪ Bob’s point-of-sale system will also automatically create a special
QR code containing a payment request

▪ Bob sees the transaction on the register, completing the


transaction
▪ bitcoin:1GdK9UzpHBzqzX2
A9JFP3Di4weBwqgmoQA
amount=0.015&
label=Bob%27s%20Cafe&
message=Purchase%20at%
20Bob%27s%20Cafe
▪ You can examine Alice’s transaction to Bob’s Cafe on the
blockchain using a block explorer sites:
▪ Tx Id:
0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57
286c345c2f2
▪ Bitcoin Block Explorer
▪ BlockCypher Explorer
▪ [Link]
▪ BitPay Insight
▪ Transactions are like lines in a double-entry bookkeeping ledger.
▪ Each transaction contains one or more “inputs,” which are
like debits against a bitcoin account
▪ There are one or more “outputs,” which are like credits added to
a bitcoin account
▪ Outputs add up to slightly less than inputs and the
difference represents an implied transaction fee, which is a small
payment collected by the miner who includes the transaction
in the ledger
▪ The transaction also contains proof of ownership for
each amount of bitcoin (inputs) whose value is being
spent, in the form of a digital signature from the owner,
which can be independently validated by anyone
▪ Many bitcoin transactions will include outputs that reference both an address of the
new owner and an address of the current owner, called the change address
▪ This is because transaction inputs, like currency notes, cannot be divided. If
you purchase a $5 US dollar item in a store but use a $20 US dollar bill to pay for
the item, you expect to receive $15 US dollars in change
▪ The same concept applies with bitcoin transaction inputs. If you purchased an
item that costs 5 bitcoin but only had a 20 bitcoin input to use, you would send
one output of 5 bitcoin to the store owner and one output of 15 bitcoin back
to yourself as change
▪ Importantly, the change address does not have to be the same address as that of the
input and for privacy reasons is often a new address from the owner’s wallet
▪ Transactions move value from transaction inputs to transaction outputs
▪ An input is a reference to a previous transaction’s output, showing
where the value is coming from
▪ A transaction output directs a specific value to a new owner’s bitcoin
address and can include a change output back to the original owner.
▪ Outputs from one transaction can be used as inputs in a new
transaction, thus creating a chain of ownership as the value is moved
from owner to owner





▪ A transaction consumes previously recorded unspent transaction
outputs and creates new transaction outputs that can be consumed by
a future transaction
▪ The exception to the output and input chain is a special type of
transaction called the coinbase transaction
▪ which is the first transaction in each block
▪ This transaction is placed there by the “winning” miner and creates
brand-new bitcoin payable to that miner as a reward for mining
▪ This special coinbase transaction does not consume UTXO
▪ Transaction outputs consist of two parts
▪ An amount of bitcoin, denominated in satoshis
▪ A cryptographic puzzle that determines the conditions required to
spend the output

▪ Transaction inputs identify (by reference) which UTXO will be
consumed and provide proof of ownership through an
unlocking script

▪ The input contains four elements:
▪ A transaction ID
▪ referencing the transaction that contains the UTXO being spent
▪ An output index (vout)
▪ identifying which UTXO from that transaction is refer‐ enced
▪ A scriptSig
▪ which satisfies the conditions placed on the UTXO, unlocking it for spending
▪ A sequence number
▪ Most transactions include transaction fees
▪ which compensate the bitcoin miners for securing the
network
▪ Fees also serve as a security mechanism themselves, by
making it economically infeasible for attackers to flood the
network with transactions
▪ Timelocks are restrictions on transactions or outputs that
only allow spending after a point in time
▪ Bitcoin has had a transaction-level timelock feature from the
beginning. It is implemented by the nLocktime field in a
transaction

▪ Also, a hash chain of blocks is much shorter than a hash


chain of transactions would be, since a large number of
transactions can be put into each block



▪ Which means that it doesn’t have the ability to compute arbitrarily powerful functions

▪ There are special-purpose instructions to compute hash functions and to compute and
verify signatures

▪ This means that every instruction is executed exactly once, in a linear manner


▪ To execute a script in a stack-based programming language, all we’ll need is a
stack that we can push data to and pop data from. We won’t need any other
memory or variables
▪ There are two types of instructions:
▪ Data instructions
▪ When a data instruction appears in a script, that data is simply pushed onto
the top of the stack
▪ Data instructions are denoted with surrounding angle brackets

▪ Opcodes Instructions
▪ Opcodes perform some function, often taking as input data that is on
top of the stack
▪ opcodes begin with “OP_”.
▪ The first two instructions in this script are data instructions —
the signature and the public key used to verify that signature
▪ Next, we have the duplicate instruction, OP_DUP, so we just
push a copy of the public key onto the top of the stack.
▪ The next instruction is OP_HASH160, which tells us to pop
the top value, compute its cryptographic hash, and push the
result onto the top of the stack

▪ Next, we’re going to do one more push of data onto
the stack
▪ At this point, there are two values at the top of the stack.
There is the hash of the public key, as specified by
the sender, and the hash of the public key that was used by
the recipient when trying to claim the coins

▪ “OP_CHECKSIG” instruction pops those two values off of the


stack and does the entire signature verification in one go.
▪ A locking script is a spending condition placed on an output: it
specifies the conditions that must be met to spend the output in the
future. Historically, the locking script was called a scriptPubKey
▪ Locking script referred to as a witness script
▪ Historically, the unlocking script was called scriptSig, because it usually
contained a digital signature
▪ An unlocking script is a script that “solves,” or satisfies, the conditions
placed on an output by a locking script and allows the output to be
spent. Unlocking scripts are part of every transaction input
▪ Unlocking script referred to as a witness
▪ Both the locking script placed on a UTXO and the unlocking
script are written in this scripting language. When a transaction is
validated, the unlocking script in each input is executed
alongside the corresponding locking script to see if it satisfies the
spending condition.
▪ Today, most transactions processed through the bitcoin network
have the form “Payment to Bob’s bitcoin address” and are based
on a script called a Pay-to-Public-Key-Hash script
▪ There are no loops or complex flow control capabilities other
than conditional flow control. This ensures that the language
is not Turing Complete
▪ These limitations ensure that the language cannot be used
to create an infinite loop or other form of “logic bomb” that
could be embedded in a transaction in a way that causes a
denial-of-service attack against the bitcoin network
▪ Multisignature scripts set a condition where N public keys
are recorded in the script and at least M of those must
provide signatures to unlock the funds
▪ This is 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
▪ OP_CHECKMULTSIG
▪ The vast majority of transactions processed on the bitcoin
network spend outputs locked with a Pay-to-Public-Key-Hash or
“P2PKH” script
▪ These outputs contain a locking script that locks the output to a
public key hash, more commonly known as a bitcoin address
▪ An output locked by a P2PKH script can be unlocked (spent) by
presenting a public key and a digital signature created by the
corresponding private key
▪ Pay-to-Script-Hash (P2SH) was introduced in 2012 as a
powerful new type of transaction that greatly simplifies the
use of complex transaction scripts
▪ P2SH shifts the burden of constructing the script to the
recipient, not the sender
▪ P2SH shifts the transaction fee cost of a long script from the
sender to the recipient, who has to include the long redeem
script to spend it.

You might also like