Magic Beans
Magic beans is crypto slang for zero knowledge proofs. Zero-Knowledge Proofs are used to verify possession without revealing any further details regarding the owner to preserve their privacy.
There are many zero knowledge solutions being developed and actively used. Two of the first and most prominent are zK-SNARKs and zK-STARKs
zK-SNARKs
While potentially applicable to a wide variety of information, zk-SNARKs were developed by Zcash to preserve the privacy of users conducting transactions with Zcash’s native token, ZEC.
Employing zk-Snarks requires a prover, verifier, and witness. The verifier is seeking to confirm the prover possesses knowledge of the witness, often referred to as a secret key.
Typically, the prover would be the seller of the asset. Transferring the asset to the verifier, who is buying the asset. With the witness confirming the seller possesses the asset and is able to transfer it to the buyer.
One advantage of zk-SNARKs versus other zero knowledge proofs is their non-interactivity. The prover does not need to be actively involved in the verification process for transfers to be completed.
Constructing zk-SNARKs requires three algorithms:
Key Generator – Used to create the proving key and verification key required to generate a proof
Prover – Combines the proving key with the witness to create the proof confirming the prover knows the witness
Verifier – Combines the verification key with the proof verifying the prover knows the witness
A critical element for security purposes is the trusted set up of the key generator. If the key generator is compromised malicious actors can set up fake proofs and undermine the legitimacy of transactions taking place across the network. Since the set up generates the common reference string used by the key generator to create the proving and verification keys for proofs.
zK-STARKs
Zero-Knowledge Scalable Transparent Arguments of Knowledge, provide scalable verification of computational integrity over confidential datasets.
Introduction
Zk-STARKs use cryptographic hash functions, similar to the mining algorithms employed to mine Proof of Work cryptoassets like Bitcoin, to produce zero-knowledge proofs. The proofs are constructed using publicly verifiable randomness from the hash chain produced by the hash function and known to both the prover and the verifier. Generating zero-knowledge proofs this way makes their deployment more scalable.
Because proofs are generated off chain and then pulled on chain when required for verification. The way this works is the root of the Merkle Tree is stored on chain. While the leaves of the tree (proofs) are generated off-chain and then batched together for scalable verification via the root on-chain. Once verified the root updates to reflect the additional leaves added from the off chain calculated proofs.
Use of a cryptographic hash function to produce proofs via Merkle Trees makes STARKs more transparent than SNARKs. Because information for the cryptographic hash function used to create proofs is public. Where-as SNARKs require a trusted set up process in which certain details remain exclusive to the parties entrusted with set up.
Additionally, zk-STARKs should be resistant to advances in quantum computing while the elliptic-curve cryptography that is the foundation of zk-SNARKs could prove more vulnerable.
Because much of the computation for STARKs occurs off chain, they could potentially alleviate some of the challenges decentralized exchanges face with scaling. 0x and StarkWare have partnered to create StarkDEX as a proof of concept of how this might work.
Further Reading Magic Beans
Example of A Good Zero Knowledge Proof