Industry Use Cases
Using Blockchain
BT-CSE-VIII-I-MINOR
What is Blockchain?
• Layman’s definition: Blockchain is an ever-growing,
secure, shared recordkeeping system in which each
user of the data holds a copy of the records, which can
only be updated if a majority of parties involved in a
transaction agree to update.
• Technical definition: Blockchain is a peer-to-peer,
distributed ledger that is cryptographically secure,
append-only, immutable (extremely hard to change),
and updateable only via consensus among peers.
What is Blockchain?
• In simple terms, blockchain is a distributed digital
ledger; each transaction in the ledger is
cryptographically signed and grouped as a block.
• When a new transaction happens, the new block is
cryptographically connected to the previous block after
proper validation, and it will be replicated to all nodes
within the network.
• Once the new block is appended, we cannot modify the
previous block
Blockchain
• Since each block is cryptographically connected, it is
tamper-evident, and it creates tamper resistance
because we cannot modify the previous block once a
new block is added.
• Moreover, the blockchain technology transaction
happens without a central repository and a central
authority or trusted third party such as a company,
bank, government, etc.
Major Benefits of Blockchain
• As the blockchain uses only an appending ledger
format, therefore easily tracks the entire transactions,
and cannot be modified like traditional databases.
• Blocks in the blockchain are cryptographically secured;
this ensures that the blockchain data cannot be
tampered with.
• Since the ledger is shared with all nodes within the
network, it ensures transparency, and it avoids a single
point of failure.
• Blockchain technology works without intermediates;
therefore, the transaction happens fast without charge
or with a very nominal charge.
• Peer-to-peer: The first keyword in the technical definition is
peer-to-peer, or P2P. This means that there is no central
controller in the network, and all participants (nodes) talk to
each other directly. This property allows transactions to be
conducted directly among the peers without third-party
involvement, such as by a bank.
• Distributed ledger: Dissecting the technical definition further
reveals that blockchain is a “distributed ledger,” which means
that a ledger is spread across the network among all peers in
the network, and each peer holds a copy of the complete ledger.
• Cryptographically secure: Next, we see that this ledger is
“cryptographically secure,” which means that cryptography has
been used to provide security services that make this ledger
secure against tampering and misuse. These services include
non-repudiation, data integrity, and data origin authentication.
• Append-only: Another property that we encounter is that blockchain
is “append-only,” which means that data can only be added to the
blockchain in time-sequential order. This property implies that once
data is added to the blockchain, it is almost impossible to change that
data and it can be considered practically immutable. In other words,
blocks added to the blockchain cannot be changed, which allows the
blockchain to become an immutable and tamper-proof ledger of
transactions.
• Updatable via consensus: The most critical attribute of a blockchain
is that it is updateable only via consensus. This is what gives it the
power of decentralization. In this scenario, no central authority is in
control of updating the ledger. Instead, any update made to the
blockchain is validated against strict criteria defined by the blockchain
protocol and added to the blockchain only after consensus has been
reached among a majority of participating peers/nodes on the
network. To achieve consensus, there are various consensus
algorithms that ensure all parties agree on the final state of the data
on the blockchain network and resolutely agree upon it to be true.
Blockchain Architecture (Blockchain
By Layer)
• Blockchain can be thought of as a layer of a distributed
peer-to-peer network running on top of the internet, as
can be seen in the following diagram. It is analogous to
SMTP, HTTP, or FTP running on top of TCP/IP:
• The lowest layer is the Network layer, which is usually the
internet and provides a base communication layer for any
blockchain.
• A P2P (peer-to-peer) network runs on top of the Network
layer, which consists of information propagation protocols
such as gossip or flooding protocols.
• After this comes the Cryptography layer, which contains
crucial cryptographic protocols that ensure the security of the
blockchain. These cryptographic protocols play a vital role in
the integrity of blockchain processes, secure information
dissemination, and blockchain consensus mechanisms. This
layer consists of public key cryptography and relevant
components such as digital signatures and cryptographic hash
functions. Sometimes, this layer is abstracted away, but it has
been included in the diagram because it plays a fundamental
role in blockchain operations
• Next comes the Consensus layer, which is concerned with the usage
of various consensus mechanisms to ensure agreement among
different participants of the blockchain. This is another crucial part of
the blockchain architecture, which consists of various techniques such
as SMR, proof-based consensus mechanisms, or traditional Byzantine
fault-tolerant consensus protocols.
• We then have the Execution layer, which can consist of virtual
machines, blocks, transactions, and smart contracts. This layer, as the
name suggests, provides execution services on the blockchain, and
performs operations such as value transfer, smart contract execution,
and block generation. Virtual machines such as Ethereum Virtual
Machine (EVM), Ethereum WebAssembly (ewasm), and Zinc VM provide
an execution environment for smart contracts to execute.
• Finally, we have the Applications layer, which is composed of smart
contracts, decentralized applications, DAOs, and autonomous agents.
This layer can effectively contain all sorts of various user-level agents
and programs that operate on the blockchain. Users interact with the
blockchain via decentralized applications.
Blockchain in Business
• From a business standpoint, a blockchain can be defined as a
platform where peers can exchange value using transactions
without the need for a centrally trusted arbitrator (a trusted
third party).
• This disintermediation allows blockchain to be a decentralized
mechanism where no single authority controls the network.
Immediately, we can see a significant benefit of
decentralization here, because if no banks or central clearing
houses are required, then it naturally leads to cost savings,
faster transaction speeds, transparency, and more trust.
• Moreover, in the payment business, blockchain can be used to
facilitate cross-border and local payments in a decentralized
and secure manner.
Generic Structure of a Blockchain
Generic Elements of a Blockchain
• Address: Addresses are unique identifiers used in a blockchain
transaction to denote senders and recipients. An address is usually a
public key or derived from a public key.
• Transaction: A transaction is the fundamental unit of a blockchain. A
transaction represents a transfer of value from one address to another.
• Block: A block is composed of multiple transactions and other
elements, such as the previous block hash (hash pointer), timestamp,
and nonce. A block is composed of a block header and a selection of
transactions bundled together and organized logically. A block contains
several elements, as:
A reference to a previous block is also included in the block unless it is a
genesis block. This reference is the hash of the header of the previous
block. A genesis block is the first block in the blockchain that is
hardcoded at the time the blockchain was first started. The structure of
a block is also dependent on the type and design of a blockchain.
Generic Elements of a Blockchain
A nonce is a number that is generated and used only once. A nonce is
used extensively in many cryptographic operations to provide replay
protection, authentication, and encryption. In blockchain, it’s used in PoW
consensus algorithms and for transaction replay protection. A block also
includes the nonce value.
A timestamp is the creation time of the block.
Merkle root is a hash of all the nodes of a Merkle tree. In a blockchain
block, it is the combined hash of the transactions in the block. Merkle trees
are widely used to validate large data structures securely and efficiently. In
the blockchain world, Merkle trees are commonly used to allow the efficient
verification of transactions. Merkle root in a blockchain is present in the
block header section of a block, which is the hash of all transactions in a
block. This means that verifying only the Merkle root is required to verify all
transactions present in the Merkle tree instead of verifying all transactions
one by one.
Generic Elements of a Blockchain
In addition to the block header, the block contains
transactions that make up the block body. A transaction is a
record of an event, for example, the event of transferring
cash from a sender’s account to a beneficiary’s account. A
block contains transactions, and its size varies depending on
the type and design of the blockchain. For example, the
Bitcoin block size is limited to one megabyte, which includes
the block header of 80 bytes and transactions.
Structure of a Generic Block
Digital transactions – the problem of
double spend
• One of the most promising applications of the World Wide Web has
been e-commerce – allowing buyers and sellers to transact business
easily over long distances.
• The use of credit cards and third-party payment processing services
has been essential to allow the transfer of money from buyer to seller
in return for the goods and services received, but there has always
been some friction and significant overhead associated with the
transaction as these require that both end points have in common a
trusted, centralized third party.
• Another challenge faced by today’s systems is that the maintaining of
personal financial data about customers, including credit card numbers
at merchant servers, introduces security vulnerabilities, with many
reports of data breaches over the years resulting in credit card theft.
Digital transactions – the problem of
double spend
• Therefore, the technologists came with a solution and developed a
form of electronic cash that can be truly distributed, not requiring a
centralized third party to validate and complete the transaction.
• Some early efforts in this direction include Digicash from David
Chaum and HashCash from Adam Back. The main hurdle to
implementing such a form of truly distributed digital currency has been
the problem of double spend.
• Unlike traditional paper cash or metal coins, which represent value in
the form of uniquely designed, counterfeit-resistant material objects, if
naively implemented digitally as any unique sequence of bits,
electronic cash or digital coins can always be copied.
• The problem of double spend that remained open and unsolved for a
long time is how to ensure that a buyer doesn’t make two or more
copies of the same digital coin to pay multiple vendors, rendering it an
ineffective currency.
The Bitcoin Protocol
• The Bitcoin Algorithm not only provided a solution to
double-spend, to enable decentralized electronic cash, it
also introduced the development of powerful related
ideas that have other applications, including the
creation of a distributed, ordered, add-only
ledger/database that is nearly impossible to change
(immutable), the notion of ‘smart contracts’ which
allow agreements between users to be implemented in
code in a distributed way, as well as the creation and
scalable maintenance of business networks.
The Bitcoin Protocol
• At the core of the Bitcoin protocol is a simple but elegant idea: if
all monetary transaction records (by who sent how much to
whom) are replicate widely, then there is no concern about
double-spend.
• Whenever someone gets money (Bitcoins) from a sender, they
can look through the commonly available record for themselves
to decide whether this is a valid or invalid (double-spend)
transaction, in particular by simply verifying if someone is trying
to send more Bitcoins than they have (Figure).
• Bitcoin is composed of a set of building blocks put together in a
careful manner to achieve decentralized trust.
Bitcoin Architecture
• Bitcoin can be defined in various ways; it’s a protocol, a
digital currency, and a platform.
• It is a combination of a P2P network, protocols, and
software that facilitates the creation and usage of the
digital currency.
• Nodes in this P2P network talk to each other using the
Bitcoin protocol.
• Bitcoin solves several historically difficult problems
related to electronic cash and distributed systems,
including: • The Byzantine generals' problem • Sybil
attacks • The double-spending problem
There various actors and components of the Bitcoin
network, and how they interact to form it:
• Cryptographic keys
• Addresses
• Transactions
• Blockchain
• Miners
• Network
• Wallets
Cryptographic keys
• 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 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:
A3ED7EC8A03667180D01FB4251A546C2B9F2FE33507C6
8B7D9D4E1FA5714195201
• When converted into WIF format, it looks like:
L2iN7umV7kbr6LuCmgM27rBnptGbDVc8g4ZBm6EbgTPQ
Xnj1RCZP
• Also, 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.
• For example, etching on physical coins or encoding in damage
resistant QR codes.
• The QR code is more damage resistant because more dots can be
used for error correction and fewer for encoding the private key.
• QR codes use Reed-Solomon error correction.
• 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.
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.
• 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.
• The reason why the compressed version of public keys works is that if
the ECC graph is visualized, it reveals that the y coordinate can be
either below the x axis or above the x axis, and as the curve is
symmetric, only the location in the prime field is required to be
stored. If y is even, then its value lies above the x axis, and if it is odd,
then it is below the x axis.
• This means that instead of storing both x and y as the public key, only
x needs to be stored with the information about whether y is even or
odd.
• 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.
Keys are identified by various prefixes
as follows:
• Uncompressed public keys use 0x04 as the prefix.
Uncompressed public keys are 65 bytes long. They are
encoded as 256-bit unsigned big-endian integers (32
bytes), which are concatenated together and finally
prefixed with a byte 0x04. This means 1 byte for the 0x04
prefix, 32 bytes for the x integer, and 32 bytes for the y
integer, which makes it 65 bytes in total.
• Uncompressed Public Keys (65 bytes)
• Prefix: 0x04
• Structure: [0x04] + [x coordinate (32 bytes)] + [y
coordinate (32 bytes)]
• Example: 04abcdef... (32 bytes) ...123456... (32 bytes)
• Compressed public keys start with 0x03 if the y 32-byte
(256-bit) part of the public key is odd. It is 33 bytes in length
as 1 byte is used by the 0x03 prefix (depicting an odd y) and
32 bytes are used for storing the x coordinate.
• [0x02 or 0x03] + [x coordinate (32 bytes)]
• Compressed public keys start with 0x02 if the y 32-byte
(256-bit) part of the public key is even. It is 33 bytes in
length as 1 byte is used by the 0x02 prefix (depicting an
even y) and 32 bytes are used for storing the x coordinate.
• Example:
• 02abcdef... (32 bytes) # Even y
• 03abcdef... (32 bytes) # Odd y
Address Generation in Bitcoin
1. In the first step, we have a randomly generated ECDSA private key.
2. The public key is derived from the ECDSA private key.
3. The public key is hashed using the SHA-256 cryptographic hash function.
4. The hash generated in step 3 is hashed using the RIPEMD-160 hash
function.
5. The version number is prefixed to the RIPEMD-160 hash generated in
step 4.
6. The result produced in step 5 is hashed using the SHA-256 cryptographic
hash function.
7. SHA-256 is applied again.
8. The first 4 bytes of the result produced from step 7 are the address
checksum.
9. This checksum is appended to the RIPEMD-160 (RACE Integrity
Primitives Evaluation Message Digest) hash generated in step 4.
10.The resultant byte string is encoded into a Base58-encoded string by
applying the Base58 encoding function.
RIPEMD-160 (RACE Integrity Primitives Evaluation Message Digest) is a 160-
bit cryptographic hash function developed by the open academic
community in Europe. It is commonly used in blockchain and
cryptocurrency applications, particularly in Bitcoin addresses.
Key Features of RIPEMD-160:
• Digest Size: 160 bits (20 bytes)
• Input Size: Arbitrary length
• Speed: Slower than SHA-1 but considered secure in certain applications
• Collision Resistance: No known practical collisions, but not as secure as
SHA-256
• Common Use: Used in Bitcoin to generate addresses (after hashing a SHA-
256 result)
How RIPEMD-160 is Used in Bitcoin
• Bitcoin addresses are derived using RIPEMD-160 in the following way:
1.Compute SHA-256 of the public key.
2.Compute RIPEMD-160 of the SHA-256 hash.
3.Add a network byte and checksum to form a valid Bitcoin address.
Typical Bitcoin addresses
• 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
• Addresses are also commonly encoded in a QR code for
easy distribution. The QR code of the preceding Bitcoin
address is shown in the following image: