Our goal at Nash is to bring decentralization to everyone. Since blockchains are too slow to implement high-performance exchanges, users turn to centralized solutions for trading. If decentralized technology is to be truly widespread, we must overcome these bottlenecks. Genuinely decentralized systems have to compete in terms of performance.
This is exactly what our off-chain matching engine achieves. By matching trades off the blockchain, we bypass its speed restrictions. We can also match trades across multiple chains, like a centralized exchange. However, with Nash, users never give up control of their funds. What’s more, our matching engine is a provably fair, distributed system, adding extra security and requiring even less trust.
We’d like to give you a better idea of the main features of our matching engine. For a start, this is what it looks like:
The Nash matching engine is essentially a multi-chain state channel manager. A state channel is a kind of account that is opened off a blockchain, allowing users to update balances that are only written to the chain at a later date. This is faster than recording every transaction to the blockchain and is essential to scaling solutions such as Ethereum’s Raiden Network. Cryptography ensures that requests to change balances in the channel are valid.
Nash takes this concept further, handling state channels across multiple chains. Users who wish to trade first transfer funds from their personal wallets to our trading smart contracts, which are capable of interacting with the matching engine. When a user places an order on the exchange, they sign that order using elliptic-curve cryptography (ECC). This gives the matching engine permission to update their smart contract balances appropriately. It is impossible for the matching engine to adjust a user’s balance on the blockchain unless they have agreed to the change.
As a system independent of the blockchain, the matching engine is capable of rapidly executing the algorithms required to match trades fairly. It does not have to write every trade or balance update to the blockchain. Instead, it writes balance updates periodically. These represent the state of users’ funds after what could have been a large number of smaller transactions.
During this time, user funds are never controlled by Nash. Users must sign off on the trades they send to the matching engine and are free to withdraw their funds from our trading smart contracts at any time, even if the matching engine and Nash web platform are not functional.
Nash doesn’t stop at taking trading off the blockchain. Our matching engine also provides a provably fair, distributed system. The matching engine is initially designed to support five nodes, with four nodes having to reach consensus for updates to be written to the blockchain. This will significantly increase the security of our system from attackers. Moreover, our present architecture is constructed with a view to upgrading to a fully decentralized system in the future.
For the matching engine to work as a distributed system, it must possess a specific property: determinism. This makes the Nash matching engine unique within the blockchain space.
Determinism simply means that a given input will always generate the same output, regardless of who is running the system, where or on what hardware. If multiple nodes are to reach consensus, they must all be deterministic, which in turn proves the correctness of the whole system. Nash users do not have to trust that a centralized exchange or smart contract–based DEX is matching trades fairly. Nash can prove that our matching engine matches trades in the fairest way, and does so every time.
This is also why our matching engine has a heartbeat.
To increase the speed of our system, each market (e.g. BTC-ETH) is treated as an independent parallel process. These individual processes are deterministic. However, this doesn’t guarantee determinism for the whole system, since the order in which individual processes run isn’t fixed.
Heartbeats let us handle any inconsistencies that may arise, making the matching engine fully deterministic. They are part of an audit system running dozens of times per second. With each heartbeat, the system updates user account balances globally. Moreover, these heartbeats let us check consistency across nodes by comparing the hashes of heartbeat data.
Watch the video above and you can see the heartbeat in action!
Nash will be unveiling our new website and exchange launch program at NEO DevCon in Seattle on 17 February. Keep watching @nashsocial for more updates!