Notes 1165 UNIT3
Notes 1165 UNIT3
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.
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.
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.
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.
UNIX timestamp
hash pointers
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.
2. It features fast computation as low speed would make the system inefficient.
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.
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