Understanding of Bitcoin Part 2: Cryptographic Principles of Bitcoin, Transactions, and the Double-Spending Problem

Understanding of Bitcoin Series 

1. Understanding of Bitcoin: Need for Decentralization and Paradigm Shift to Web 3.0 

2. Understanding of Bitcoin: Cryptographic Principles of Bitcoin, Transactions, and the Double-Spending Problem

3. Understanding of  Bitcoin: Explaining PBFT Algorithm and Its Applicability in Bitcoin Network

4. Understanding of Bitcoin: Nakamoto Consensus, Proof of Work Mechanism

Understanding of Bitcoin Part 2: Cryptographic Principles of Bitcoin, Transactions, and the Double-Spending Problem
Understanding of Bitcoin Part 2: Cryptographic Principles of Bitcoin, Transactions, and the Double-Spending Problem. Image by starline on Freepik

Short Summary

  1. An overview of the Blockchain, focusing on the cryptographic principles of Bitcoin, transactions, and the double-spending problem.
  2. The concept of currency and its necessary conditions for it to function as currency. This includes the characteristics of gold as a ubiquitous example of currency.
  3. The emergence of Bitcoin as a form of digital gold on top of the blockchain system. How it has created an ideal and completely open electronic network financial system without a trustworthy centralized institution, through the P2P approach.

1.0 Introduction 

What is currency? It is a means of exchange with payment capabilities that represents the value of goods.

From an economic perspective, there is no clear, agreed-upon definition of the term “currency”. However, let’s examine some of the conditions necessary for a currency to function as a currency.

Conditions for Currency

  1. It must have sufficient universal value to be the object of exchange.
  2. There must be an adequate quantity of currency for it to be widely used.
  3. It must be stable and not easily subject to value erosion when used as a means of storing value.

Characteristics of Gold

Gold is one of the most ubiquitous examples of currency and has the following characteristics:

  1. Gold does not fluctuate or easily change in value.
  2. The amount of gold is limited and not easily mined, ensuring scarcity.
  3. Gold has a unique appearance that has worldwide intrinsic value.
  4. It can be transformed into various forms and is highly portable.

However, there are problems with the digitization of traditional financial assets (currency) from a traditional finance perspective, including the following:

  1. Characteristics of digital data: There is a threat of replication, editing, and manipulation from centralized institutions or parties with access.
  2. The necessity of currency and securities: Currency and securities assets must be difficult to tamper with.

The digitization of assets in the structure of electronic financial transactions can only occur through the supervision of qualified financial institutions or trustworthy financial supervisory agencies.

The virtual currency Bitcoin emerge as the first form of digital gold on top of the blockchain system. Furthermore, it succeeded in creating an ideal and completely open electronic network financial system without a trustworthy centralized institution. This came through the P2P (Peer to Peer) approach, which makes tampering impossible. Satoshi Nakamoto’s white paper, “Bitcoin: A Peer-to-Peer Electronic Cash System,” emphasizes two key technologies. The first is transaction and electronic signature technology. There is also the double-spending problem and consensus algorithm that arises from electronic signature technology.

Bitcoin as Currency

“A purely peer-to-peer version of electronic cash would allow direct online payments from one party to another without going through a financial institution. Digital signatures provide part of the solution. However, the main benefits are missing if we still require a trusted third party to prevent double-spending” (Abstract)

When conducting financial transactions in traditional finance, if a user’s assets are digital, they must go through various forms of identity verification (public certification, card identification, etc.) to prove that the assets they own are their own when it comes to the right to change them (transfer, payment). To verify their identity, the user must entrust, provide, and register their authentication information to a third-party institution. Then, they can participate in e-commerce. However, the electronic commerce format of third-party authentication participation for identity verification poses many risks and constraints on the user’s e-commerce freedom due to the digital data management of centralized institutions.

To solve this problem, Satoshi developed an e-commerce system that does not require the participation of a third-party authentication institution. It uses the digital signature method and built an open network system. Here, anyone with a wallet inside the Bitcoin network can make transactions. The existence of a trustworthy third-party institution was essential to solve the double-spending problem occurring in traditional financial transactions. Meanwhile, Bitcoin uses a system based on the blockchain. The whitepaper explains cleverly that the system structure can accommodate digitally distributed transactions without a central operator. It can also solve the double-spending problem through a different approach.

2.0 Bitcoin Transaction and Digital Signature

A transaction refers to a logical unit of work necessary for implementing a service. However, within the Bitcoin system, transactions can also be understood as concepts of financial transactions in the digital realm. In the context of database concepts, a transaction is a unit of work that changes the state of data. The concept of a transaction introduced in Bitcoin has the same meaning as the origin of the term “transaction”. It refers to financial asset transactions among nodes participating in the Bitcoin network. Meaning, a unit of work changes the state of transaction data. Sending and paying financial transactions, between one node and another participating node is the prime example.

When trading digital assets, only the person who owns the asset has the authority to initiate a transaction. Instead of the participation of a third-party authentication institution within Bitcoin, a method for verifying transactions by introducing electronic signature technology based on asymmetric cryptography between distributed networks is explained.

What are public key (asymmetric key) encryption and electronic signature technology?

An asymmetric key encryption algorithm refers to a form of encryption algorithm that obtains another pair of public keys (public key) using a secret key (Private key) as a seed.

Nodes participating in the Bitcoin network obtain their own electronic signatures using a secret key. They then verify the validity of the electronic signature through a process of matching with the public key corresponding to another pair of secret keys. Before explaining the asymmetric key encryption method in more detail, let’s explain the basic concepts of cryptography.

3.0 Concept of Cryptography

Encryption is a technique of converting plaintext into ciphertext or vice versa. For example, plaintext is a text that is decryptable, such as “12345674”. Meanwhile, the ciphertext is a text that cannot be decrypted, such as “SAJDNJKASNFKRQ.”

The concept of encryption involves two processes: encryption and decryption. Encryption is the process of converting plaintext into ciphertext, while decryption is the process of converting ciphertext into plaintext.

There are two types of encryption: one-way encryption and two-way encryption. One-way encryption is a type of encryption that cannot be decrypted after encryption. Furthermore, it is typically implemented using hash functions with one-way properties. Two-way encryption, on the other hand, is a type of encryption that allows both encryption and decryption. It is commonly implemented using symmetric and asymmetric key methods.

Public key encryption is a popular encryption technique in blockchain, including Bitcoin, Ethereum 2.0, Solana, and many others. Unlike symmetric key encryption, public key encryption is a two-way encryption technique that uses different keys for encryption and decryption. Symmetric key encryption uses a single key for both encryption and decryption. However, public key encryption uses a pair of keys for encryption and decryption. This makes it a two-way encryption algorithm that allows the decryption of encrypted data.

This encryption method aims to address the vulnerability of key exchange in symmetric key encryption. In the traditional symmetric key encryption method, we will only need to exchange one key to enable the decryption of the message. However, in the case of asymmetric key encryption, a pair of keys consisting of a private key and a public key exist within the network.

Cryptographic Technique

Image from Public-key Cryptography Wikipedia

The cryptographic technique above aims to solve vulnerabilities in key transmission in symmetric key cryptography. In conventional symmetric key cryptography, if one key is provided for decrypting the encrypted data, in asymmetric key cryptography, a pair of keys consisting of a private key and a public key exists within the network. The private key (or secret key) is a unique encryption key that the user must protect securely. Anyone who may access the user’s data should not compromise it. It mainly functions as the data electronic signature in Bitcoin transactions. Another public key is a key that is available to anyone, primarily used as the form of each user’s account number in Bitcoin.

In a Bitcoin transaction, a user obtains an electronic signature through the encryption process of the original data using the private key. The user then undergoes a validation process of the electronic signature’s validity by the corresponding public key to the original data. If the validation result is true, the electronic signature will receive validity. If not, the system can obtain a result that the electronic signature of the corresponding private key of the public key is invalid.

4.0 Hash Function

Let’s take a closer look at how the introduction of public-key encryption works in Bitcoin to create electronic signatures for transactions and how transactions are verified.

To understand this public-key encryption, one must first understand the concept of cryptographic hash functions. A hash function is an obtainable value by mapping arbitrary data of varying lengths (message) to a fixed-length string of data. This can either store or find the value in a specific array index or location using the data value. In other words, this is a value with the characteristic of a one-way function.

A one-way function is a function that easily derives an output through input, but it is difficult to find input through output. Let’s look at an example of a hash function.

Hash Function Example

The hash function aims to output a fixed-length hash value when given a message of variable length as input. For example, when introducing the hash function SU903 with the property of a one-way function to the input value “Dog,” the resulting output is the string shown above (1).

Similarly, when introducing a hash function to the input value “The Blue Dog runs over the tree,” a fixed-length string (2) is also produced. The hash function SU903 produces a fixed-length string output for any input value.

However, even slight changes to the input value can result in a complete change in the output value, known as the Avalanche effect. Therefore, the value of the input always produces the output value.

In the case of data input, if there is a change in the value, it is not necessary to modify all of the data. Instead, by modifying only one value, it is possible to determine whether all of the data has been modified.

Therefore, this hash function can be used to provide the integrity of data used in the network. The function of blockchain hash function plays a significant role in creating electronic signatures within Bitcoin.

When a user executes an electronic transaction, they obtain a hash value by inputting this hash function of the transaction. At this time, by encrypting the output value obtained from this hash value with the private key of the aforementioned electronic signature, the user can obtain the electronic signature.

Hash Function Within Bitcoin

Within the Bitcoin network, users transmit the electronic signature that is output from the hash function. At this time, according to the characteristic of the hash function (a one-way function that produces the same output value for the same input), they use the same hash function to obtain the hash value. They then create an electronic signature by encrypting the obtained hash value with the private key and transmitting it along with the transaction.

When the user’s transmitted transaction and electronic signature have been completed within the Bitcoin network, the network uses the same hash function to obtain the hash value of the transaction and undergoes a verification process for the validity of the electronic signature contained within the corresponding private key using the public key. 

At this time, if the verification value matches the hash value, the validity of the data is confirmed, and the ownership of digital assets on the network changes, resulting in a transaction.

Summary of Bitcoin Network Transactions

When summarizing the principles of Bitcoin network transactions, the following can be observed:

  1. A transaction is a unit that alters the state of an asset.
  2. It can contain ledger information regarding the transfer and payment of digital asset data.
  3. Only the participant who owns the asset’s ownership can initiate the transaction during digital asset trading.
  4. The digital signature is required and is performed through the public-key asymmetric encryption method.
  5. The digital signature of the original data can be obtained by using a private key, and its validity can be verified with the original data and public key.
  6. The transaction’s hash value is obtained using a hash function.
  7. The hash value of the transaction is encrypted with the private key using the asymmetric encryption method, and the electronic signature is sent to the Bitcoin network along with the transaction.
  8. The Bitcoin network uses the same hash function to calculate the transaction value and verify the validity of the electronic signature with another public key (account), determining the transaction’s validity.
  9. When the data’s validity in the transaction is verified through the hash value, the Bitcoin network changes the ownership of the digital asset.

5.0 Double Spending Problem 

However, there is a problem that cannot be solved solely by using digital signatures. To utilize digital signatures, only the owner of the digital asset can initiate transactions for trading that asset. However, it is still possible for one person to create multiple conflicting transactions. This problem is known as the double spending problem.

Image from Bitpanda

To learn more, let’s refer to the above picture. Alice wants to send Bitcoin to both Katie and Bob simultaneously by creating a transaction.

Alice currently owns 1 BTC in her wallet, but she created a transaction for both Katie and Bob simultaneously.

As Bitcoin is a decentralized, distributed network based on a P2P (peer-to-peer) architecture, all the participating peers in the network need to consider the issue of consensus on who the asset will be transferred to.

An algorithm that solves this problem in a distributed network is called a consensus algorithm. The double-spending problem in the Bitcoin network can be explained by the Byzantine Generals’ Problem, which was formulated by Leslie Lamport.

6.0 Byzantine Generals Problem

The Byzantine Generals Problem, introduced in a joint paper by Leslie Lamport and Marshall Pease in 1982, is a classic problem in computer science and goes beyond the Two Generals’ Problem by assuming the presence of multiple generals.

The problem is as follows: The Byzantine Empire army is trying to attack an enemy city. It is assumed that generals of various units govern vast territory areas. However, in order to conquer the enemy’s castle, all generals must attack simultaneously at the same time on the same day, and if there is an error in message delivery and there is a dispersion of troops, the attack strategy of the Byzantine generals against the enemy will fail. Furthermore, some of the generals leading these troops may be traitors and may obstruct the agreement of loyal generals on the attack strategy. The problem of the Byzantine Generals is exactly how to reach an agreement on how to conquer the enemy’s castle using a consensus method under these circumstances.

This problem can be seen in the same context as the double-spending problem in the Bitcoin network.

For example, suppose a transaction initiated by Alice occurs simultaneously for Bob and Kate. If the transaction that Alice intended to send was originally intended for Bob, each dispersed general becomes a node participating in the network, and the nodes must overcome the interference of the traitor general nodes on the network in order to reach a consensus to ensure that the original purpose of the transaction initiated by Alice to Bob is successfully delivered to Kate.

Therefore, what are the conditions under which honest general nodes can reach a consensus in a distributed system?

Byzantine Fault Tolerance

Image from Byzantine Generals Problem paper

In order to capture the enemy’s castle, there are two loyal generals and one traitorous general. The loyal generals issue attack orders to each other to capture the castle, but if the general is a traitor, they will issue a retreat order. Another general who receives these two different orders faces the dilemma of what choice to make. Therefore, in a situation where the number of traitorous generals in the message-passing system is one-third of the total Byzantine generals, it is difficult for them to reach a consensus.

However, if there is one more loyal general, the two loyal generals will issue attack orders to another general, and the traitorous general will issue a retreat order alone. Because the number of oral message passing of loyal generals’ commands is greater than the number of traitors, the consensus is reachable.

In the Bitcoin network, we call such traitorous generals Byzantine nodes. Detecting these traitorous generals and using the message-passing system to allow traditional consensus algorithms is a Byzantine Fault Tolerance (BFT). However, it now has a more practical form: Practical Byzantine Fault Tolerance (PBFT).

When the number of traitorous nodes (t) is one-third of the total nodes (N) (N > 3t), a consensus is possible with PBFT.

However, there is a major drawback to this consensus algorithm system. It is an expensive price for communication. In other words, when we assume the number of traitors (t), we need to reach a consensus in proportion to the number of total nodes (n). Therefore, the necessary number of messages for consensus increases exponentially, and the communication cost to maintain such a system also increases.

Conclusion

This consensus algorithm system can only increase to a certain number of nodes. Meanwhile, the overload problem of the geometrically increasing number of nodes in the process of continuously passing messages to each other in the network can occur. If more than half of the nodes leave or join the system, the network system may fail or faces interruption. Such problems still receive criticism for being closed as a consensus method that does not conform to the open network philosophy that Bitcoin wants to pursue.

To solve these problems, Satoshi Nakamoto introduced Nakamoto’s Consensus method.

Reference

  1. Public-key cryptography — Wikipedia
  2. What is double-spending? — Bitpanda Academy
  3. The Byzantine Generals’ Problem. The problem can be described with one… | by Ashwin Kumar R | Good Audience
  4. Bitcoin and The Byzantine Generals Problem — The Wolf of All Streets
  5. There’s No ‘Currency’ in Your Cryptocurrency Wallet: Part 1 (pentasecurity.com)

Personal Note From MEXC Team

Check out our MEXC trading page and find out what we have to offer! You can learn more about cryptocurrency industry news. There are also a ton of interesting articles to get you up to speed with the crypto world. Lastly, join our MEXC Creators project and share your opinion about everything crypto! Happy trading!

Join MEXC and Start Trading Today!