# Double Spending

2019-08-27

Digital cash systems are prone to double-spending which is a flaw that allows the same digital token to be spend more then once. Digital tokens exist as a digital file (a string of bits) that can be duplicated. Double-spending leads to inflation which devalues the currency.

There are two forms of digital currencies, centralized which involves trusted 3rd party institutions and decentralized which is generally peer-to-peer.

It is easier to prevent double-spending attacks in a centralized system because all the state of the network (who has what coin) is stored in one place (the trusted 3rd party) and this is one of the reasons traditional commerce on the internet is centralized.

It is much more difficult to prevent double-spending attacks in decentralized systems, due to the nature of distributed systems, for example if we a have a naive system that has three peers A, B and C. Let's assume peer A has a single token x and wants to send it to B:

    A[x] -> B


after this everyone in our decentralized network should have the same state, in other words all peers should be able to verify that A no longer has the x token because he transferred it to B. But in our naive network allot can go wrong maybe C was offline when the transaction (A[x] -> B) took place or maybe C has a slower internet connection this causes the state of the network to be unsynchronized between the peers in our network (C has old state while A and B have updated state) this means that A can transfer the same token (x) to peer C and this is a double-spend.

The above example illustrates how difficult it is to prevent double-spending in decentralized system, they have to include a consensus mechanism to prevent double spending.

cy6erlion