2016-10-03

Problems with big numbers in crypto - how Bitcoin dodged a bullet

Recently, the infamous OneCoin made news once more in the Bitcoin circles after their OneLife mastermind stream. One of the more interesting things mentioned was the previously announced blockchain reset, coin doubling and increase in coin generation speed. This is supposed to mean that OneCoin is getting more valuable, but once again, that's not how blockchain works - big numbers don't mean big money. But let's start from the beginning.

Bitcoin coin cap


As everyone knows by now, Bitcoin has a coin cap of around 21'000'000 coins. Each coin can be broken down into 100'000'000 satoshis, and that number can be further sub-divided in the future should the need arise. So for practical needs, Bitcoin has a final supply, and a nigh-infinite divisibility, as opposed to fiat currencies that are often nigh-infinite in supply, but finitely divisible.

The hidden genius of Bitcoin is very subtle when it comes to its coin cap and its precision that a lot of coin developers often miss entirely.

Sure, Bitcoin might not have a mathematically beautiful block reward (say, a power of 2 that halves every four years so that we can get a beautifully round number in the end), but it's still easy for programmers to work with. In financial computer science, precision is everything. A balance of $3.50 would not be represented in a database as a floating point number - those are imprecise. It would be an integer number, like 350 cents, or 35'000 hundredth of a cent if you need to get more precise. This makes sure that you can add, subtract and multiply those numbers all day long and you will always be right down to a penny.

Same goes for Bitcoin. Every transaction specifies exactly how many satoshis to transfer and to whom. The number is encoded in a 64 bit unsigned integer, meaning it can precisely express numbers between 0 and 2^64 (18'446'744'073'709'551'615). Even if you take all of the bitcoins that will ever exist and subdivide them into satoshis, you will get a number smaller than 2^51, meaning no matter how many coins you move back and forth, you will never lose precision or overflow the system. Moreover, the numbers can also be represented precisely with double-precision floating points (which has a precision of 2^52 for a fraction).

Other coins and their supply


Other coins have often toyed with different block reward schedules and thus different amount of coins.

Ripple is perhaps the most popular coin with a high coin supply, capping off at 100B XRP even. Their coins subdivide into 6 decimal places rather than 8 - this gives them an upper bound of under 2^57 units (if they instead went for 8 decimal places, they would be under 2^64 and wouldn't fit into signed integers). So they are fine in that regard, but they start to run into a problem when trying to express the units as floating points - they are only precise up to 2^52, or about 15 significant digits.

Same story with Dogecoin - currently sitting at 106B units with 8 decimal place precision, which is enough to start breaking the JSON API developers use. Bytecoin, sitting at 181B coins barely fits into 64 bit integers and FedoraCoin, the coin with the highest listed coin supply on CoinMarketCap breaks that limit with 438B coin supply, needing at least 66 bits to be fully represented.

OneCoin


So where does OneCoin sit in all of this? Lets assume they are like Bitcoin with 8 decimal places (and not just some made-up numbers in a spreadsheet...). They currently boast having 2B coins and mining 2.19B coins per month, giving us less than 2^58 - too big for doubles, but still manageable for ints. In about 85 months of mining, their coin supply will reach 185B and cross over 2^64. That is a long after they plan on "going public with their coin" in Q2 2018, whatever that would mean.

Conclusions


When designing a cryptocurrency, there are many hidden pitfals one has to keep in mind and try to avoid. One might be tempted to create a currency with large numbers to give off an illusion of value where there is none. However, for practical reasons, you want to keep the numbers in your system within a reasonable range so the developers working with your coin won't have to deal with numbers too big to represent.

OneCoin might still be in the clear, at least as clear as Dogecoin is, but one more "blockchain restart" coupled with increased mining speed and they will be soon crossing the computer science boundary, at least assuming the system is legitimate to begin with.

Next up - why big numbers don't mean big money...

No comments:

Post a Comment