Double Spending in Digital Currency!

Arpan Srivastava
Coinmonks
4 min readNov 17, 2018

--

Digital currency has been around the corner since a very long time and with the emergence of bitcoin blockchain, it has managed to get into the spotlight. But, what is a digital currency? Well, it is a type of currency available in digital form, in value, it is similar to physical money but with properties like instantaneous transaction and borderless transfer of ownership.

So, with every new currency arises some problems and in this case, it is the double spending problem. Double spending is the act of making a copy of the digital currency and sending it to the merchant while keeping the original one with yourself. So, let’s understand this problem with a cool example.

Goofy Coins

So, suppose our friend Goofy decides to publish some digital currency with the following set of rules:

  • Only Goofy has the right to create coins and each coin will have a unique CoinId and it will be digitally signed by him.
  • Every transaction that is made will have the digital signature of the person making it and the address of the person receiving it.
Goofy Coins
  • Goofy creates a coin with unique CoinId and sign it with its public key.
  • Now, Goofy decides to give the coin to Alice so he makes a transaction(Pay to pK(Alice): H()) with its digital signature and now Alice owns the coin with a hash pointer pointing to goofy’s transaction.
  • Now, Alice turns out to be mischievous and decides to double spend the coin. So, she signs the transaction and gives the coin to Bob and again sign it and give it to Chuck. Chuck doesn’t know or have any way to figure out that the coin has already been sent to Bob. This turns out to be a double spending problem and the main concern while developing any digital currency.

Scrooge to rescue

Now, our billionaire friend finds out about the problem and tries to solve it in his own way. So, he developed his own Scrooge Coin.

The Scrooge coin has some set of rules which everyone needs to follow:

  • The coin can only be created by Scrooge.
  • He will publish a history of all the transactions made and will digitally sign it if the transaction is valid.
Scrooge Coin
  • Now, every transaction a person makes is assigned a transId which is unique and it is pushed into the blockchain. So, anybody can come and check whether the transaction was made in the past or not and Scrooge verifies that there is no tampering in the blockchain by signing the hash pointer of the last block. For optimization, we put multiple transactions in the same block.
  • There are two types of transactions in a Scrooge:
  1. Create Coin Transaction
Create Coin Transaction

There are multiple transactions in a block and each transaction has namely three fields: a CoinId(e.g. 73(0) or 73(1)), the value of the transaction made and the receipt address(public key of the receiver). Transactions are considered valid because “Scrooge said so”.

2. Pay Coins Transaction

Pay Coins Transaction

These are the transactions made by other people, with the following information: the transId of the coin, Value of coin being transacted and recipient address. It also contains the digital signature of all those people who are making the transaction in that block.

The coins or the transaction will be considered valid if:

  • It is a consumed coin i.e. it is earlier being transacted by Scrooge.
  • It is not already consumed or used.
  • Total value out = Total value in i.e. the amount sent by the sender and amount received by recipient should be same.
  • Signed by all the previous owners of the coin.

Is the problem really solved?

Well, with the Scrooge coin we figured out the solution to double spending but what if:

  • Scrooge stops verifying or maintaining the blockchain.
  • He, himself gets corrupt and starts validating invalid transactions.
  • People stop believing in the rules set up by Scrooge.

If you think for a moment, you can easily figure out that those problems arose because of the centralization of Scrooge coins and the solution to that is Decentralization where people can trust each other and have a consensus mechanism. Well, that’s a large discussion topic in itself.

Get Best Software Deals Directly In Your Inbox

--

--

Arpan Srivastava
Coinmonks

A tiny speck in the universe, looking to make a better life