Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
41 views6 pages

Important

Uploaded by

Kashmeera R
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views6 pages

Important

Uploaded by

Kashmeera R
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

BITCOIN TRANSACTION-types principles use cases

BLOCK CHAIN -longest chain rule blockchain branching security issues


Bitcoin address:
Allows to send receive bitcoin
Steps Overview:
1. Generate a Private Key: A random 256-bit number, usually represented
as a 64-character hexadecimal string.
2. Generate a Public Key: Derived from the private key using elliptic curve
multiplication with the secp256k1 curve.
3. Compress the Public Key: Bitcoin uses compressed public keys for
efficiency. The compressed key only includes the x coordinate (32 bytes)
with a prefix (0x02 or 0x03), depending on the parity of the y coordinate.
4. Generate Public Key Hash: Hash the public key using SHA-256
followed by RIPEMD-160 to generate a 160-bit public key hash. This is
used in Bitcoin addresses.
This diagram explains a Bitcoin transaction example, showing how inputs and
outputs are used, and how the transaction fee is calculated.
Key Points:
1. Inputs:
o Transactions T1 and T2 serve as the inputs to the current
transaction.
o Input amounts:

 From T1: 2 BTC.


 From T2: 1.5 BTC.
o Total input = 2 BTC + 1.5 BTC = 3.5 BTC.

2. Outputs:
o The current transaction specifies multiple outputs:

 2.5 BTC sent to Bob.


 0.5 BTC sent to Charlie.
 0.49997 BTC is returned to the sender (Alice) as change.
o Total output = 2.5 BTC + 0.5 BTC + 0.49997 BTC = 3.49997
BTC.
3. Transaction Fee:
o The difference between the total inputs and total outputs is the
transaction fee.
o Transaction fee = Input - Output.

 3.5 BTC (input)−3.49997 BTC (output)=0.00003 BTC (fee)3.5 \


, \text{BTC (input)} - 3.49997 \, \text{BTC (output)} =
0.00003 \, \text{BTC (fee)}.
Explanation:
 Bitcoin transactions consume inputs from previous transactions and create
outputs for recipients or change back to the sender.
 Any difference between the input and output becomes the transaction fee,
which incentivizes miners to include the transaction in a block.
 The diagram visually connects the inputs (T1 and T2) to the outputs,
showing how the BTC is distributed and how the small remaining amount
(the fee) is calculated.

Types of transactions

Standard Transaction (P2PKH)


 Pay-to-PubKey-Hash (P2PKH) is the most common type of Bitcoin
transaction, typically used for regular transactions.
 Description: This transaction sends Bitcoin to a specific Bitcoin address.
The address is a hash of a public key, which must be unlocked using the
corresponding private key to spend the Bitcoin.
 Structure:
o The sender provides a digital signature to prove ownership of the
Bitcoin being spent.
o The recipient’s address (public key hash) is included in the
transaction output.
Example: Alice sends Bitcoin to Bob using Bob's Bitcoin address (a P2PKH
address)
Pay-to-Script-Hash (P2SH)
 P2SH allows complex scripts (conditions for spending the Bitcoin) to be
encoded in a way that makes them look like regular addresses.
 Description: Instead of sending Bitcoin to a public key hash, Bitcoin is
sent to a script hash, meaning that the recipient must provide a script (a
set of conditions) that can unlock the funds.
Example: Used for multi-signature addresses where multiple private keys are
required to authorize a transaction.
Multi-Signature (MultiSig) Transactions
 MultiSig is a type of Bitcoin transaction where multiple signatures are
required to authorize a transaction.
 Description: This allows Bitcoin to be secured by requiring signatures
from multiple parties, instead of just one. It's often used for added
security, where several people or entities must sign off on a transaction.
o Common configurations are 2-of-3 (two out of three signatures are
required), 3-of-5, etc.
Example: A company wallet may require the signatures of the CEO, CFO, and
Treasurer to authorize any Bitcoin spending.

The longest chain rule is a principle used in blockchain systems to determine


the "valid" version of the blockchain when there are competing chains or forks. It
ensures consensus among all participants in a decentralized network. Here's how
it works:
Explanation:
1. Chains in a Blockchain:
o Each block in a blockchain contains a reference to the previous
block, forming a chain. However, due to the decentralized nature of
the network, temporary forks can occur if two or more miners
create a block simultaneously.
2. Longest Chain Rule:
o The longest chain rule states that the chain with the most
accumulated computational work (typically the longest chain) is
considered the valid blockchain.
o In Proof-of-Work (PoW) systems, this translates to the chain that
required the most energy and computational resources to produce.
3. Resolving Forks:
o When a fork occurs, all network participants (nodes) will initially
accept both chains.
o As new blocks are added, one of the chains will eventually become
longer (or have more proof-of-work).
o Nodes then discard the shorter chain and adopt the longest chain as
the valid blockchain.
4. Why This Works:
o The longest chain rule ensures that consensus is maintained
because the majority of computational power supports the valid
chain.
o Attackers would need to outpace the honest miners (control more
than 50% of the network's hash rate in PoW systems) to create a
longer chain, which is extremely resource-intensive and impractical.
Key Features:
 Decentralization: Prevents a single entity from controlling the
blockchain.
 Consensus: Ensures all nodes agree on a single chain.
 Security: The rule makes attacks like double-spending very difficult, as it
would require enormous resources to alter the blockchain.
Limitations:
 Temporary Forks: Minor delays in propagating new blocks can cause
short-lived forks.
 51% Attack: If an attacker controls more than half of the network's
computational power, they can exploit the rule to rewrite the blockchain.
 Energy-Intensive: In PoW systems, maintaining the longest chain can
consume significant energy.
The longest chain rule is primarily used in blockchains like Bitcoin and Ethereum
(prior to its switch to Proof-of-Stake), where consensus is based on computational
work.

Public key cryptography plays a crucial role in securing transactions and the
overall functionality of Bitcoin. It enables users to prove ownership of their
bitcoins, ensure the privacy and integrity of transactions, and prevent
unauthorized access. Here's how it works in the context of Bitcoin:
1. Public and Private Key Pair
In Bitcoin, each user has a public key and a private key:
 Private Key: A secret key known only to the owner. It is used to sign
transactions and prove ownership of the Bitcoin associated with that key.
The private key must be kept secure and confidential.
 Public Key: A public key is derived from the private key using a
mathematical algorithm. This key is shared openly with others and is used
to receive Bitcoin. It is a long string of alphanumeric characters.
The relationship between the private and public keys is based on elliptic curve
cryptography (ECC). Specifically, Bitcoin uses the secp256k1 curve, a widely
used elliptic curve in cryptography.
2. How Public Key Cryptography Works in Bitcoin
Creating a Bitcoin Address:
 A Bitcoin address is derived from the public key. This address is what
other users send bitcoins to. The process involves applying a series of
cryptographic functions:
o First, the public key is hashed using SHA-256 (Secure Hash
Algorithm) and then RIPEMD-160 (a hash function) to produce a
shorter, more manageable address.
o This address is what others use to send Bitcoin to the user.

Signing a Transaction:
When you want to send Bitcoin, you need to sign the transaction with your
private key:
 A transaction consists of inputs (where the Bitcoin is coming from) and
outputs (where the Bitcoin is going).
 To sign a transaction, Bitcoin uses the Elliptic Curve Digital Signature
Algorithm (ECDSA), which is based on the private key.
 The signature is a mathematical proof that you own the private key
associated with the address and have the right to spend the Bitcoin.
Verifying a Transaction:
When someone else wants to verify your transaction, they use your public key
to check the signature:
 The public key is used to validate that the signature matches the
transaction data, proving that it was signed by the rightful owner (without
needing access to the private key).
 If the signature is valid, the network knows the transaction is legitimate.
3. Security and Anonymity:
 Confidentiality: The private key ensures that only the owner can
authorize transactions from their wallet, thus protecting the assets.
 Integrity: The signature ensures that the transaction hasn't been altered
after it was signed.
 Anonymity: Bitcoin uses the public key as an identifier (and not directly
linking it to a person’s identity). However, since all transactions are
recorded on the blockchain, public addresses can be traced, potentially
revealing spending patterns.
4. Why It Matters for Bitcoin’s Security:
 Non-repudiation: Once a transaction is signed and broadcast to the
network, the sender cannot deny making the transaction because the
private key proves ownership.
 Resistance to Forgery: Without the private key, it's computationally
infeasible to forge a valid signature, thus preventing unauthorized
transactions.
 Decentralization: Public key cryptography ensures that control of Bitcoin
is decentralized. Only the holder of the private key can spend their Bitcoin.
5. Public Key Cryptography in Bitcoin vs. Traditional Cryptocurrencies:
While Bitcoin’s public key cryptography provides secure, private transactions,
other cryptocurrencies may use different cryptographic algorithms or features
(like Ring Signatures in Monero for enhanced privacy).
In summary, public key cryptography in Bitcoin is a cornerstone of its security
model, enabling secure transactions without the need for a central authority. The
public-private key pair ensures ownership, integrity, and confidentiality while
allowing users to maintain anonymity on the blockchain.

You might also like