In our previous blog post we focused on the developments and ongoings around Team Nimiq, so now we feel it’s time to provide a more detailed technical update of the most exciting features of the upcoming Testnet release called Luna.

Overview

Two new client types: light and nano

Schnorr signatures

Memory-hard PoW algorithm

Smooth difficulty calculation

Significant performance improvements

Upcoming Testnet launch

Light Clients and Nano Clients

It takes hours to sync to a conventional Blockchain network such as Bitcoin. We address this problem by using the Mini-Blockchain Scheme to significantly compress the amount of data you need to download. Our Betanet was a basic prototype which wasn’t particularly efficient because it didn’t leverage the full capabilities of the scheme yet. Luna introduces a way more sophisticated implementation, which is optimized for three client types: Full Nodes, Light Clients and Nano Clients.

Full Nodes simply download the full Blockchain just like in conventional protocols. Professional miners will probably favor this client.

Light Clients fully verify the complete state by syncing just a fraction of the total Blockchain data. Even with a billion users that would be less than a gigabyte. Hobby-Miners, block explorers or merchants will probably favor this client.

Nano Clients verify their own balances and transactions by syncing just about a megabyte of Blockchain data. This is the most light-weight way to use the network without trusting a third party. Most users will use wallet apps based on such Nano Clients.

Sublinear Header Chain

The Mini-Blockchain Scheme enables us to compress the current state of accounts’ balances, but it still has to download the full headers chain which grows linear in time. That means a naive Nano-Client implementation would need to download 10 MB per year since launch, which would become unusable for low-end devices quite quickly. To solve this we’ve first implemented the ideas behind Proofs of Proofs of Work with Sublinear Complexity and then the enhanced version Non-Interactive Proofs of Proof-of-Work which compresses the headers chain to almost constant size. This was the final protocol ingredient for Nano Clients to truly sync by downloading less than a megabyte.

Schnorr Signatures

Most Blockchains use secp256k1 for signatures. We are excited to be one of the first protocols to leverage the benefits of the more modern Ed25519 Schnorr signatures. Our benchmarks have shown that Ed25519 compiled to WebAssembly is 30% faster than the native WebCrypto secp256r1 implementation. Additionally the public keys are just 32 bytes long which enables more compact transactions and therefore a higher Tx/s rate.

Another great feature of Schnorr signatures are Multiparty Signatures of constant size which allow even better on-chain scalability of the Nimiq protocol.

PoW Algorithm

Being the active community members you are, you may have already read in our Telegram or Discord about Cuckoo Cycle and our initial intents to use it as the PoW algorithm for the Nimiq Blockchain. If you paid attention you might even recall that some news discouraged us to use cuckoo cycle after all, and we have now finally made the decision to dismiss it altogether. While its asymmetric nature allows for ultra-quick verification, it’s just too slow for mining in Nimiq’s specific case, since a single run can take up to 90 seconds. Furthermore, we underestimated the difference between GPU / CPU mining in regards to browser mining and had to accept that mining via CPU is the more productive and reasonable approach if we want to achieve our goal of having a full, and efficient, mining node in the browser.

For Luna, we considered the CryptoNight algorithm next. We evaluated CryptoNight and came to the conclusion that it is too slow for verification as well (WebAssembly, single thread: ~17 H/s on a desktop browser, ~3 H/s on a mobile browser).

The final decision is to base our PoW on Argon2, which is significantly quicker than CryptoNight (about 20x-40x according to our tests), while also being symmetric. As of this post, we’re still considering customizing the Argon2 algorithm, though, to make it more fitting for our purpose. there’s no definitive decision on the customization specifics but we’ll keep you updated about the progress.

Smooth Difficulty Adjustment

As always we appreciate miners who continue to support our Betanet (shout out to the Miner Pioneers who received a commemorative T-Shirt). We’ve received feedback from miners about problems with the current difficulty calculation algorithm.

To fix this we’ve made some changes: instead of updating the difficulty every k blocks, we now update the difficulty every block according to the time it took to mine the last 100 blocks. This should result in a more fluid validation process.

Core Performance Improvements

Pascal’s JungleDB which we detailed in our last development update and in VLOG 30, is now finished, completely tested and integrated into the Nimiq core. One of the main reasons for creating JungleDB was that other databases couldn’t handle transactions the way we were imagining it. Now that it’s finished, anyone using both LevelDB (NodeJS) and IndexedDB (Browsers) will be able to use and benefit from it.

Regarding the use of JungleDB in Nimiq’s Blockchain, we got rid of lots of old and unused code and finally finished integrating JungleDB within Nimiq’s core. We also added additional features that were meeting new requirements that had come up during development (e.g. concerning how transactions were processed).

Furthermore, we adjusted some of our internal data structures not only to make use of advanced JungleDB features, but also to half verification time of blocks. This, for example, includes a restructuring of the accounts tree, which is part of the Mini-Blockchain scheme and holds the accounts’ balances. Our new data structure offers significantly better verification and retrieval performance. It also allows us to efficiently sync the tree to light clients.

Upcoming Release

The upcoming launch of Luna won’t be just a hard-fork but a full reset of our previous Betanet.

Luna will be almost fully feature complete such that we can start our in-depth security and scalability tests as final preparation for our Mainnet launch.

Our private Testnet was already launched last week and we feel reasonably confident to release it to the public in November.

Stay Tuned

You can expect more technical updates concerning Luna so stay tuned for more Nimiq News!

Cheers to our Community, and specially thanks to Sinarnb for creating awesome Nimiq emojis for Telegram and Discord. Below his favorite creation.