0% found this document useful (0 votes)
8 views9 pages

Notes 1165 UNIT3

The document explains the concept of double spending in blockchain, particularly in digital currencies like Bitcoin, where the same digital cash can potentially be spent multiple times. It details how Bitcoin mitigates this risk through a confirmation mechanism and the use of a blockchain ledger, ensuring that only one transaction is validated when double spending attempts occur. Additionally, the document covers the process of Bitcoin transactions, hashing, and the role of miners in confirming and adding transactions to the blockchain.
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)
8 views9 pages

Notes 1165 UNIT3

The document explains the concept of double spending in blockchain, particularly in digital currencies like Bitcoin, where the same digital cash can potentially be spent multiple times. It details how Bitcoin mitigates this risk through a confirmation mechanism and the use of a blockchain ledger, ensuring that only one transaction is validated when double spending attempts occur. Additionally, the document covers the process of Bitcoin transactions, hashing, and the role of miners in confirming and adding transactions to the blockchain.
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
You are on page 1/ 9

Blockchain Double Spending(UNIT-3)

Double spending means spending the same money twice. As we know, any transaction
can be processed only in two ways. One is offline, and another is online.

Offline: A transaction which involves physical currency or cash is known as an offline


transaction.

Online: A transaction which involves digital cash is known as an online transaction.

Let us consider this example:

You go to Restaurants and order a cappuccino worth $5. You pay in cash. The service
provider at Restaurants instantly confirmed that you have paid, and you received your
coffee in exchange for the money. Now is it possible to spend the same $5 somewhere
else to make another purchase? The answer is NO. But what if the answer is YES? It
means the same person can use the same cash more than one times. This type of
problem is known as Double Spending Problem.

In a physical currency, the double-spending problem can never arise. But in digital
cash-like bitcoin, the double-spending problem can arise. Hence, bitcoin transactions
have a possibility of being copied and rebroadcasted. It opens up the possibility that the
same BTC could be spent twice by its owner.

How Bitcoin handles the Double Spending Prob


Bitcoin handles the double-spending problem by implementing a confirmation
mechanism and maintaining a universal ledger called blockchain.

Let us suppose you have 1 BTC and try to spend it twice. You made the 1 BTC
transaction to Alice. Again, you sign and send the same 1 BTC transaction to Bob. Both
transactions go into the pool of unconfirmed transactions where many unconfirmed
transactions are stored already. The unconfirmed transactions are transactions which
do not pick by anyone. Now, whichever transaction first got confirmations and was
verified by miners, will be valid. Another transaction which could not get enough
confirmations will be pulled out from the network. In this example, transaction T1 is
valid, and Alice will receive the bitcoin.

What happened if both the transactions are taken


simultaneously by the miners?
Suppose two different miners will pick both transactions at the same time and start
creating a block. Now, when the block is confirmed, both Alice and Bob will wait for
confirmation on their transaction. Whichever transaction first got confirmations will be
validated first, and another transaction will be pulled out from the network.

Now suppose if both Alice and Bob received the first confirmation at the same time,
then there is a race will be started between Alice and Bob. So, whichever transaction
gets the maximum number of confirmations from the network will be included in the
blockchain, and the other one will be discarded.

Hashing in Blockchain
Hashing or hash is a common term when discussing blockchain technology. Hashing
refers to the transformation and generation of input data of any length into a
string of a fixed size, which is performed by a specific algorithm. In particular, the
Bitcoin hash algorithm is SHA-256 or Secure Hashing Algorithm 256 bits. This
algorithm is a one-way cryptographic function as the original data cannot be retrieved
via decryption.
The implementation of a cryptographic hash function is beneficial to prevent fraudulent
transactions, double spending in blockchain, and store passwords. But, what is Bitcoin
hash, and what does it have to do when put in this context? In short, this is a unique
number that is not duplicable according to the algorithm. Therefore, it is frequently used
to verify a file’s authenticity. To put it in context, when there’s a change in a hashed file,
its hash will automatically change as well. And each subsequent hash is tied to the
previous hash, thus ensuring the consistency of all blocks.

How Hashing Works in Blockchain


So what is a hashing algorithm in blockchain, and how does it work? In a nutshell, a
hashing algorithm takes an infinite number of bits, performs calculations on them, and
outputs a fixed number of bits. Regardless of the input data’s length, the output will
always be rectified. As a result, the original data is called input, and the
finaltransformation is called a hash. Today, many hashing algorithms differ only in the
way information is processed.
To fully comprehend what hashing is about, it’s essential first to understand the data
structure. A data structure is a specific way of storing data that consists of two key
elements: pointers and linked lists. Pointers are variables referring to other variables,
so they act as indicators that show the way to the right location. Besides, it provides the
address of the next block in the chain. Linked lists, on the other hand, make up a
sequence of the nodes that are connected with the help of pointers.
Thanks to hashing in the blockchain, each block is assigned an original identifier, which
will entail the irreversible consequences of changing the blockchain. The block is
identified by information included in the header of the block. It consists of such details
as:

 the version number of the blockchain

 UNIX timestamp

 hash pointers

 nonce, which is the value the miners need to create a block

 a hash of a Merkle root


All these elements are needed to create the block. So when a hash happens to the
blockchain, the data will be converted into a unique string within a block.
How to Solve a Hash?
To solve a hash, it begins with solving complex mathematical problems containing data
in the block header. But before a miner initiates the process, they’ll need to carry out a
trial-and-error process to decide which string to use as a nonce. When a nonce is
identified, miners will focus on the nonce (a string number) that is related to the previous
block’s hashed content. In order for a hash to be considered successful, the new hash
needs to be less than or equal to the target hash. And in exchange, the miner will get a
reward to add the block into the blockchain.
The Relationship of Proof of Work in Hashing
Proof of Work (PoW) algorithm is correlated to the blockchain hash as this algorithm is
useful to confirm transactions and produce new blocks to the chain.
How Does PoW Work?
Decentralization is a crucial property of the blockchain, but it is potentially vulnerable. If
a participant wants to download a copy of the blockchain, how can another user know
that the blockchain is correct? Let’s say there are thousands of computers on the
network; what prevents them from conspiring with a new user with the data they forged
together?
That’s when the PoW algorithm comes in. It allows the blockchain network participants
to know if the information is indeed for free or otherwise.
History is everything on the web, where you need to know who spends the money and
who receives it. It was impossible to reach full consensus in a decentralized network
without control by the third party in the past. The hash function made it possible as it
provides a unique digital fingerprint of a piece of data.

Proof of Transactions
When sending cryptocurrency, users have to confirm their wallets’ action, which
broadcast the transactions to the blockchain. Afterward, the transactions get into the
transactions pool awaiting processing, where they remain until being picked up by a
miner.
The transactions of this kind can be accumulated in a vast pool or small separated local
pools. Miners choose transactions from the mining pools and process them into new
blocks. This block includes transactions awaiting confirmation with additional metadata.
In the end, each miner forms a separate block. And the same transactions can enter the
blocks of different miners.
A miner must make sure that every given transaction answers the execution
requirements. In case a sender has enough resources on balance, the transaction
becomes valid and can be added to the block. For faster processing, the sender can
increase the mining fee. Typically, miners take advantage of a higher value of
transactions selecting the most profitable deals; therefore, processing time becomes
lower.
Each transaction has its hash that is stored in a tree-like structure. These hashes are
also hashed to form the Merkle root. This technology contains information about all
transactions.
What Are the Cryptographic Hash Functions?
Cryptographic hash functions are characterized by several properties making them very
useful when employed in the cryptographic sphere.

1. The result of a hash function is always identical. This characteristic is


called deterministic. Regardless of how many times you enter the same message, the
output will be the same after the hash function is applied. However, the slightest change
in the input data (‘Article’ instead of ‘article’) changes the result completely.

2. It features fast computation as low speed would make the system inefficient.

3. Preimage resistance feature in hash functions makes it computationally infeasible to


determine the input from the hash value. Therefore, miners can only compare the result
until a match is found.

BITCOIN NETWORK AND TRANSACTION

Bitcoin is basically a digital currency that is currently used as a form of


payment. Bitcoin is a cryptocurrency and the transactions related to bitcoins
take place in the blockchain network. Every bitcoin is stored in a virtual wallet
and transaction involves the transfer of bitcoin from one wallet to another.
Bitcoins can be sent from peer to peer irrespective of geographical location
without any intermediator in between(for example bank per se). it works in a
decentralized way, meaning nobody can interfere with your digital money, only
you are responsible for your bitcoins.

Bitcoin Transaction

Bitcoin transaction means sending bitcoin from one person to the other in the
secured blockchain network. These are messages that are digitally signed
using cryptography and are verified by the miners that are present in the
blockchain network. The miner is the person who solves mathematical
puzzles(also called proof of work) to validate the transaction. Anyone with
mining hardware and high processing power can take part in this. Numerous
miners take part simultaneously to solve the complex mathematical puzzle, the
one who solves it first, wins 12.5 bitcoin as a reward. miner verifies the
transactions(after solving the puzzle) and then adds the block to the blockchain
when confirmed. The transaction input is the bitcoin address from which the
money was sent, and the transaction output is the bitcoin address to which the
money was sent. Generally, a bitcoin transaction takes 10 to 20 minutes to
confirm any transactions. if network congestion takes place, then time might
take even 60 minutes.
Example: Suppose Hari wants to send 5 BTC(bitcoins) to Senorita.
Input- It consists of the bitcoin address from which hari got his bitcoins previously.
Amount- This deals the specific amount of money that hari wishes to send to
senorita,
in this case, its 5BTC.

Output- This is the bitcoin address of senorita which hari needs to know in order to
transfer the bitcoins to her wallet. Bitcoin address of senorita is also known
as public key.

Transaction Fees

The transaction rate or speed is dependent on the amount the user pays for it. If
a user pays a small amount, the transaction rate will be slow, the transaction
will take more time to happen, vice versa is applicable here. Due to limited
space, only a limited number of transactions are possible at one point in time.
Consider a case where heavy network traffic occurs, then the miners prioritize
those transactions that have the highest fees so that even in the hectic
congestion, the highest-paid transaction gets executed.
Many bitcoin wallets allow users to set transaction fees manually. The fees are
directly sent to the miners. When the bitcoin hits a bull run, the transaction fees
shoot up to an all-time high. there is no such minimum transaction fee a user
must pay, but the highest transaction fees mainly lie between $24 to $31. as the
highest-paid transaction gets confirmed first, therefore the fees tend to fluctuate
based on the demand of the user.

Why Do Some Bitcoin Transaction Confirmations Take So Long?

Time is taken for transaction confirmation mainly depends on two factors:


 Transaction fees: As discussed above, if the user pays minimal transaction
fees, then the time taken for confirmation of a particular transaction would
take a longer time. the mining process needs significant technology and
efforts, therefore the importance of transaction fees comes into play.
 Network load: Every transaction gets stored temporarily in the memory pool
till the miners confirm it. When the transaction activities reach a certain high
threshold, the memory pool gets jammed thereby slowing the confirmation
time of the transaction even more. Due to this, all the subsequent
transactions become susceptible to delay.
How Bitcoin Transaction Works?

Sending or exchanging bitcoins undergoes lots of procedures underneath. The


bitcoin wallet and the network ensures that the digital currency reaches the
receiver properly. There are two basic terminologies related to this-
 Public key: Also known as a bitcoin address, these are publicly known to all
like your username in social media handles. In order to receive bitcoins, the
user must share his public key with the other user.
 Private key: These are kept secret and must not be shared with anyone,
similar to the user’s password of social media accounts. Private keys are the
most important thing in the whole cryptocurrency concept. The private key
allows the user to have access to bitcoins, if the user forgets the private
keys, there’s no way to recover the bitcoins or the private key. Therefore, it
is advised to make a proper backup of the private key in a safe place.
Transaction input is nothing but the address of the sender which gets registered
in the network and remains in an encrypted and inaccessible state. Transaction
output is the receiver’s address which is registered on the bitcoin network.
In the previous example, Hari opens his bitcoin account and signs a transaction
detail with his private key, and then broadcasted to a bitcoin network called
blockchain, where miners compete with each other to find a hash value called
nonce which solves the mathematical puzzle thereby verifying the transaction.
The miners create new blocks by abiding by the fact that the transaction volume
must be less than 21 million. 21 million is the total number of bitcoins that can
be generated. The verified transaction gets a unique identification code and is
linked with the previous verified transaction.
In the bitcoin network, every transaction is traceable via linked blocks. Anyone
can understand who sent it to who at any point in time. thus, bitcoin works in a
transparent manner

Different Types of Bitcoin Address

There are mainly three types of bitcoin addresses:


1. P2PKH addresses: These addresses start with number 1. For example
1WX23.
2. P2SH addresses: These addresses start with number 2. For example
2WX23.
3. Bech32 addresses: These addresses start with bc1. For example
bc12WX23.
Internal Vs External Transactions

 An internal transaction is a transaction that doesn’t come under any external


third party.it works inside the internal function of business thereby doesn’t
exchange any sort of resources. Internal transaction doesn’t have any
impact on the cash flow as it deals only with interdepartmental transactions.
 An External transaction is a transaction that comes under any external third
party.it basically is an exchange medium between an internal organization
and a third party. Since it involves exchange with third parties, it has a huge
impact on the cash flow.

How To Send Bitcoin

In order to send or receive bitcoins, one must possess a bitcoin wallet


application.
 After installing the bitcoin wallet app, select the type of currency you want to
send. For example ethereum, bitcoin, etc.
 Write in the receiver’s address.
 Type the amount of bitcoin you wish to send.
 Pay the required transaction fee.
 Press the “send bitcoin” button and the cryptocurrency will be transferred.

How to Receive Bitcoin?

In order to receive bitcoins, do the following steps:


 Open the wallet and click receive.
 Share the public key address. It can be a QR code or a combination of
numbers and letters.
 Anyone with a public address can send the cryptocurrency.

REFERENCES:
 https://www.javatpoint.com/blockchain-double-spending
 https://learn.bybit.com/blockchain/what-is-hashing-in-blockchain/
 https://www.geeksforgeeks.org/how-bitcoin-transaction-works/
 https://crypto.com/university/how-do-bitcoin-transactions-work

You might also like