UNIT-IV
UNIT-IV
WHAT IS BITCOIN
• Bitcoin achieves elimination of intermediaries with the help of its underlying technology, blockchain.
• Currently if you have to transfer funds to someone, one of the possible ways is by giving cash or
alternatively use a trusted intermediary (example, a bank). Both the mechanisms, whether it be
physical cash or electronic transfer, involve an intermediary .When intermediaries are involved, there
are transaction costs.
• How the blockchain technology helps achieve elimination of intermediaries is by replacing trust that
intermediaries bring to the table with cryptographic proof by the use of CPU computing power.
• This cryptographic trust is built into Bitcoin through a wallet, a public key and a private key in the
program.
• Anyone can create a Bitcoin wallet for free by downloading the Bitcoin program. Each wallet contains
a public key and a private key.
• The public key is like an address or an account number via which any person can receive Bitcoins.
HOW DOES BITCOIN WORK [CONT.. ]
• A private key is like a digital signature via which a person can send Bitcoins. The name
suggests that private keys should be only held and known by the owner and public keys can be
shared with anyone for receiving Bitcoins. That is where you would have heard in the news
about Bitcoins being lost either due to a private key not being accessible or stolen by hackers.
• Owners of Bitcoin addresses are not explicitly identified, but all transactions on the blockchain
are public.
• Since the inception of Bitcoin in 2009, each and every transaction that has occurred is stored in
a ledger, which is considered immutable, non-tamperable and irreversible.
• Bitcoin transactions are verified via telecommunication network nodes through cryptography
and are then recorded in a decentralized distributed ledger called blockchain. This is one of the
distinguishing aspects of Bitcoin from some other crypto assets
DIGITAL KEYS AND ADDRESS
• On the Bitcoin network, possession of bitcoins and the transfer of value via transactions are reliant upon
private keys, public keys, and addresses.
• Elliptic Curve Cryptography (ECC) is used to generate public and private key pairs in the Bitcoin network.
• Private keys in Bitcoin:
• Private keys are required to be kept safe and normally reside only on the owner’s side. Private keys are used to
digitally sign transactions, proving ownership of bitcoins.
• Private keys are fundamentally 256-bit numbers randomly chosen in the range specified by the SECP256K1
ECDSA curve recommendation. Any randomly chosen 256-bit number from 0x1 (1) to 0xFFFF FFFF FFFF
FFFF FFFF FFFF FFFF FFFE BAAE DCE6 AF48 A03B BFD2 5E8C D036 4140 is a valid private key..
• Private keys are usually encoded using Wallet Import Format (WIF) in order to make them easier to copy
and use. It is a way to represent the full-size private key in a different format. WIF can be converted into a
private key and vice versa
• For example, consider the following private key:
• A3ED7EC8A03667180D01FB4251A546C2B9F2FE33507C68B7D9D4E1FA5714195201
• When converted into WIF format, it looks as shown here:
• L2iN7umV7kbr6LuCmgM27rBnptGbDVc8g4ZBm6EbgTPQXnj1RCZP
DIGITAL KEYS [CONT..]
• mini private key format is sometimes used to create a private key with a maximum of 30
characters to allow storage where physical space is limited.
• A private key encoded using mini private key format is also sometimes called a minikey. The
first character of the mini private key is always the uppercase letter S. A mini private key can
be converted into a normal-sized private key, but an existing normal-sized private key cannot
be converted into a mini private key. This format was used in Casascius physical bitcoins. The
Bitcoin core client also allows the encryption of the wallet that contains the private keys.
• Public keys in Bitcoin :
• All network participants can see public keys on the blockchain. Public keys are derived from private
keys due to their special mathematical relationship.
• Once a transaction signed with the private key is broadcast 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.
DIGITAL KEYS [CONT..]
• Bitcoin uses ECC based on the SECP256K1 standard. More specifically, it makes use
of an Elliptic Curve Digital Signature Algorithm (ECDSA) to ensure that funds remain
secure and can only be spent by the legitimate owner.
• Public keys can be represented in uncompressed or compressed format and are
fundamentally x and y coordinates on an elliptic curve.
• The compressed version of public keys includes only the x part since the y part can
be derived from it.
• Initially, the Bitcoin client used uncompressed keys, but starting from Bitcoin Core
client 0.6, compressed keys are used as standard. This resulted in an almost 50%
reduction of space used to store public keys in the blockchain.
DIGITAL KEYS [CONT..]
• Bitcoin addresses are 26-35 characters long and begin with the digits 1 or 3. A typical Bitcoin
address looks like the string shown here:
• 15ccPQG3PQXcj7fhgmWAHN7SQ7JBvfNFGb
• the commonly used P2PKH and the P2SH type ,starting with numbers 1 and 3, respectively.
In the early days, Bitcoin used direct Pay-to-Pubkey, which has now been superseded by
P2PKH.
• However, direct Pay-to-Pubkey is still used in Bitcoin for coinbase addresses. Addresses
should not be used more than once; otherwise, privacy and security issues can arise.
WHAT IS BITCOIN , EXPLAIN PEER-TO-PEER
TRANSACTIONS , TRANSPARENCY,
IMMUTABILITY
• Bitcoin is a cryptocurrency, a form of electronic money.
• It operates as a decentralized digital currency, independent of traditional
banks.
• Users can send Bitcoin directly to each other without intermediaries, thanks
to the peer-to-peer (P2P) nature of the Bitcoin blockchain network.
• Key Features of Bitcoin:
• Peer-to-Peer Transactions
• Transparency
• Immutability
FEATURES [CONT..]
• The lifecycle of a Bitcoin transaction. The steps of the process are as follows:
• A user/sender sends a transaction using wallet software or some other interface.
• The wallet software signs the transaction using the sender’s private key.
• The transaction is broadcast to the Bitcoin network using a flooding algorithm, which is an
algorithm to distribute data to every node in the network.
• Mining nodes (miners) who are listening for the transactions verify and include this transaction in
the next block to be mined. Just before the transactions are placed in the block, they are placed in
a special memory buffer called the transaction pool.
• Next, the mining starts, which is the process through 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 Proof of Work (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
TRANSFER MONEY USING THE BITCOIN
NETWORK FROM ONE USER TO ANOTHER.
• Sending Bitcoin starts with a Bitcoin wallet for sending, receiving, and securing BTC.
• The wallet’s primary function is allowing you to generate and store your private keys,
the keys that give you control over your Bitcoin accounts.
• Initiating the Transaction:
• Initiating a transaction with your Bitcoin wallet usually means specifying the amount of
BTC you would like to send, and specifying the address you’d like to send it to.
• From there, it will present you with the intent; a sort of digital proposal.
• The proposal will include all of the proposed transaction’s details, although some wallets
will display more detailed information than others.
• At this point, you’ll have the chance to reject or confirm the transaction.
CONT..
• Sending Bitcoin :
• It’s important to note that the Bitcoin network uses the UTXO (unspent transaction
outputs) model to handle transactions.
• When you send BTC, you send the intended recipient an entire UTXO and then receive
a smaller UTXO back as change.
• When you want to buy something else, you can send the previous smaller UTXO and
receive your change back in a new even smaller UTXO.
• Essentially, you can’t transact on the Bitcoin network without sending the entire UTXO.
• This solves the “double-spending” challenge cryptocurrencies face. Every time a
transaction is executed, the input is deleted and a new output (or UTXO) is created.
• UTXOs are much like banknotes you use in everyday life.
CONT..
• Example :
• Imagine you want to buy some bread that costs $1 but you only have a $20 note
in your pocket. You must hand over the full $20 note to the shopkeeper.
• In return, the shopkeeper will need to give you your change.
• In this example, you receive your $19 change as a single banknote.
• To explain, since Bitcoin is a digital currency it doesn’t require physical
denominations for people to carry around. As such, you receive your change back
in one sum; in the form of a UTXO.
HOW PUBLIC KEYS AND PRIVATE KEYS ARE
USED TO GENERATE BITCOIN ADDRESSES?
• The digital keys are not actually stored in the network, but are instead
created and stored by users in a file, or simple database, called a wallet.
• The digital keys in a user’s wallet are completely independent of the bitcoin
protocol and can be generated and managed by the user’s wallet software
without reference to the blockchain or access to the Internet.
• Every bitcoin transaction requires a valid signature to be included in the
blockchain, which can only be generated with valid digital keys; therefore,
anyone with a copy of those keys has control of the bitcoin in that account.
• Keys come in pairs consisting of a private (secret) key and a public key.
PRIVATE AND PUBLIC KEYS
• A bitcoin wallet contains a collection of key pairs, each consisting of a private key
and a public key.
• The private key (k) is a number, usually picked at random.
• From the private key, we use elliptic curve multiplication, a one-way cryptographic
function, to generate a public key (K).
• From the public key (K), we use a one-way cryptographic hash function to generate
a bitcoin address (A).
• we will start with generating the private key, elliptic curve math that is used to turn
that into a public key, and finally, generate a bitcoin address from the public key.
GENERATING A PRIVATE KEY
• where k is the private key, G is the generator point, and K is the resulting public key, a point on
the curve. Because the generator point is always the same for all bitcoin users, a private key k
multiplied with G will always result in the same public key K. The relationship between k and K
is fixed, but can only be calculated in one direction, from k to K. That’s why a bitcoin address
(derived from K) can be shared with anyone and does not reveal the user’s private key (k).
BLOCKCHAIN ROLE IN BITCOIN
• Transaction validation:
• Transactions broadcast 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 the
verification of the nonce value.
• 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.