A Lightning Network (state channels) built using recursive ZK-Snark Proofs
This project implements state channels in a completely novel way: using recursive ZK-Snark proofs. Like the Bitcoin Lightning Network, it allows for near-instant transactions at virtually no fees. Users trade between themselves directly over a P2P network, and with the security of a recursive ZK-Snark Proof (😎), be able to close their channel and finalize their balances whenever they want.
The project runs on the Mina Network, but it can pretty easily run on any other chain that supports recursive ZK-Snarks using SnarkyJS.
User flow: A user deposits funds to the Lightning Protocol's smart contract (any token may be used). This locks the funds for a specific period of time. As long as the funds are locked, the user may transact with other users of the Lightning Protocol, off-chain, by simply passing a recursive ZK-snark proof back and forth. That means no on-chain transaction is performed, but the user can be sure the money sent to them cannot be forfeited from them.
When the user is done trading over Lightning, she can post her recursive proof on-chain and receive her funds on the actual blockchain. That means a million trades can be compressed into a single transaction paying only a one time fee.
The ZK-Snark proof is smart enough to fail when balances reach 0 or when there's a double spend, so users can be confident that they can always post the proof to finalize their trades.
The project is based on SnarkyJS, a Zk-Snarks library that converts typescript into provable circuits. It is the circuit language used by the Mina Network, and the smart contracts are deployed to the Berkley testnets.
I greatly enjoyed the dev tooling that the Mina Team has created for spinning up ZK-Apps. I used it to create the Lightning Protocol, implementing two main contracts: one is a sample token contract for the mina network, and the other is Lightning Protocol smart contract that implements fund locking, proof verification, withdrawal, the various witness verification logic for verifying and setting Merkle root state, and the ZK-Snarks recursive proof that I created which enables this novel state channel solution.