2. My Background
● Nxt Core Developer
● SmartContract.com / Secureae.com backend dev
● Consensus Research member
3. Fields of Interest
● Distributed & P2P systems
● Blockchain Tech
● Functional Programming (Haskell / Scala)
● Finite State Machines
● Formal Methods (model checking / Coq)
4. The Design of a Cryptocurrency
● P2P Network
● Persistent distributed fully-replicate database (aka
Blockchain)
● Transactions over tokens grouped within blocks, a block is
a database version
● Consensus algorithm
● Optional: additional layers on top of transactional
layer(mesages, tokens, code)
6. Blockchain As Database
● Persistent(versioned) database
● Genesis state – initial verion of the database
● Block as state modifier: State(h) * Block → State(h+1)
● Very weak consistency!
9. Weakest Consensus Property
● After k permutations a state of the blockchain database for
versions 1..N-k is considered to be stable (with some
assumptions made)
● Bitcoin(PoW): k = 6
● Proof-of-Stake: k = ?
10. Proof-of-Work
● Secured by NP problem
● (not by cryptography magic!)
● Find x by hash(x) is well-known NP problem
● PrimeCoin: Cunningham chains
● Length could be considered as a chain quality measure(in
the blocktree)
11. Proof-of-Stake
● No mining
● Consensus is within network
● Right to generate a block depends on stake
● hit < target
● CumulativeDificulty is the chain quality measure(in the
blocktree)
13. Problem
● Bitcoin has more than 100K LoC's (80K C++ only)
● Nxt 40+K LoCs(Java)
● Even simple(and pretty buggy) Qora is ~20K (Java)
● Each product's code is hard to understand
● Hard to make experiments
● It's easy to make an error
14. Security Problems
● Consensus algo flaws – FATAL
● Transaction layer flaws – from trivial to critical
● Network layer – ddoses, unconfirmed pool attacks
15. Bitcoin: Transaction Layer bug
On July 28 2010, two bugs were discovered and
demonstrated on the test network. One exploited a bug in
the transaction handling code and allowed an attacker to
spend coins that they did not own. This was never
exploited on the main network, and was fixed by Bitcoin
version 0.3.5.
After these bugs were discovered, many currently-unused
script words were disabled for safety.
16. Bitcoin: Transaction Layer Bug
On 15 August 2010, with an exploit over 184 billion
bitcoins were generated in a transaction, and sent to two
addresses on the network. This was the only major
security flaw found and exploited in Bitcoin's history.
● Fixed with hard-fork
17. Better Quality of Blockchain Impls
● Safer languages(Scala/Ocaml, Haskell, Idris/Coq)
● Formal methods usage
● Prototypes before products
18. SCOREX
● The cryptocurrency engine in less than 4K lines of Scala code
● To make proof-of-concepts FAST!
● Compact code
● Not production-ready
● CC0 license
19. Lagonaki Release
● 100% Proof-of-stake
● Simplified account-based transaction model
● Simple payments only
● Curve25519 for signing
● JSON API
● Command-line client
20. Under The Hood:
● Scala
(only Curve25519/RIPEMD160 impls are in Java)
● Akka
● MapDB
● Spray for HTTP API
● Play Json
● Scalatest
● Logback