by troymc · 3y ago · 0 comments
Computation is done by a Prover and duplicated by a Verifier. If the Verifier finds the computation result to be wrong, then they can identify a single gate (e.g. a NAND-gate) in the circuit doing the computation whose output bit(s) is wrong for its input bits, and expose this by engaging in an on-chain gate fraud proof, consisting of an alternation of transactions by Prover and Verifier that ends with one of them taking funds (the Prover in case the single gate computed correctly, the Verifier otherwise).
(Downvotes? I’m being serious.)
On-chain verification is the ideal though. On-chain computation is incredibly expensive and wasteful.
To make things concrete let's look at an example. Computational state in a block chain contract is typically stored in a Merkle hash trie. Let's say that the data stored is a key, and the holder of the key is allowed to spend the coins bound to the contract. The _computation_ is to check that the key is contained within the Merkel trie, then check signature of the key and the spend. However with some cool zero-knowledge crypto magic, you don't even have to reveal the Merkle inclusion proof, nor even the key itself. All you have to do is provide a zero-knowledge transcript which verifies that the computation of the contract (Merkle inclusion proof and signature check) validates. This is, essentially, how zerocash works.
This result generalizes. For whatever computation you want to perform in a contract, the contract can be rewritten to instead just validate a transcript of a successful execution of that computation. This isn't just academic either. All NP problems have transcripts that are validatable in polynomial time. A derivative of this result is that while you might need Turing completeness to express the logic of a smart contract, you do NOT need Turing completeness to validate its transcript. As a trivial example, a smart contract that involves computing a hash preimage by brute force in a tight loop, could be replaced with a contract that merely takes a string and checks that it hashes to the desired value.
Look into Mina or Zcash to better understand what I mean. Off-chain clients (eg, wallets in Zcash) keep the application state, and the state committed to the chain is just the proof that the application state is following an agreed-upon state transition function.
Relying on hashing, computation proofs, etc are ways to asymmetrically enjoy the benefits of global coordination without requiring all nodes in the network to run the code. Instead, they just verify the receipts of off-chain agents who ran the code.
always a sham