Dwarves
Memo
Memo
0) { selectedRecent = recentPages[0]; selectedSection = 'recents'; }">
Reading Mode
+shift+f
zk-SNARKs
What is this?
ZK-SNARKs stands for Zero-Knowledge Succinct Non-Interactive Argument of Knowledges.
Nowadays, we often hear this word when mentioning zk-rollups. But it is actually a Privacy-enhancing technology, and has a lot of applications that we will delve into in another post.
Decomposition
- ZK aka Zero-Knowledge mean:
- Prove possession of certain information.
- Without revealing that information.
- For Example:
- Given the hash of a random number.
- The prover could convince the verifier that a number with this hash value exists without revealing what it is.
- Succinct:
- Can be verified within a few milliseconds.
- no matter how long the statement is.
- Non-interactive:
- In the first version of ZK, the prover and verifier had to communicate repeatedly for multiple rounds.
- Now, by implementing this characteristic, the proof consists of a single message sent from the prover to the verifier.
Implementation by Example
Example 1: Function C
- You have a program denoted
C. - C have 2 input
C(x,w):xis the public stuff, that can be shared with anyone.wis the secret witness.
- The condition
C(x,w)===true, means “Prover actually knows a secret witnesswsatisfied a statement related tox”. - As a prover, how can we prove that we know
w, without sendingwto the verifier to check with the statements? - Can map this example to the example of the hash function of the previous part. Let’s do it, and go to the next example.
Example 2: Bob, Alice, and Hash
- Bob is given a hash
H. - Alice is given the original string
Ssatisfied the condition when hashingSby a hash function such asSHA,His issued (akaSHA(S) === H). - How can Alice prove to Bob know that she knows the
S? - Normally
- Alice needs to send
Sto Bob. - Bob needs to hash again to check
SHA(S) === H.
- Alice needs to send
- But in this case,
Sis a secret witness, and must not send to any locations, how can Alice prove this statement to Bob?- Solution:
- Alice need a proof to send to Bob.
- This proof can prove
SHA(S)===His true. Mapping to programC, with publicxasHand privatewasS, in other words, when this proof provesC(x,w)===true, it means Bob can confirm that Alice knows thiswakaSsatisfiedSHA(S)===Hwithout knowledge aboutS. - Example of
C:function C(x, w) { return ( sha256(w) == x );}
- Note that
C(x,w)===trueis proved by theproof, not by itself. How can?
- Solution:
Example 3: Implementation of zk-SNARKs in simple words
A ZK-SNARK consists of three functions
G, P, Vdefined as follows:Key generator aka
GG(lambda, C) = pk,vklambda: secret parameter. Noted this.C: a program that proves thatproverknowswbyC(x,w)=true. Aka aboveCin Example 1 and Example 2.pk: proving keyvk: verification key
pkandvkare public parameters that only need to be generated once for a given programC.- Can assume that:
- From
pk, we can create aproofthat can be verified by usingvkin a pre-defined way.
- From
Prover function aka
PP(pk,x,w) = prfpk: proving key issued fromGx: public inputw: private witnessprf: proof proves that prover knowswsatisfy programC.
Verifier function aka
VV(vk,x,prf)=true/falsevk: verification key generated fromGx: public inputprf: proof generated fromP
By above functions,
V(vk,x,prf)=truemeans:- With the proof
prfgenerated depends on a logic that includesx,wandpk. - And
pkis a pair withvkso they are closely related to each other. - So when having
vk,x,prf, by a pre-defined way, we can confirm thatC(x,w)===true.
- With the proof
Note that
lambdacan cause security issues when used in real work- Reason: anyone who knows
lambdacan generate fake proofs - Example:
- From any
C, and knownlambda, can find a pairf_pkandf_vk - From
f_pk, malicious actor can generate afake_prfthat representsC(x,w)==truewhen checking withf_vk.
- From any
- Solution: multi-party-ceremonies for Trusted Setup -> To build
lambda.
- Reason: anyone who knows
Resolve the Example 2:
Bob uses
Gto generate key, sendpkto AliceAlice gen
prf-> Sent to BobBob verifies using
vkIssue: Bob can’t be a prover because he holds the
Lambda.- A trusted independent group separate from Alice and Bob could run the generator and create the proving key pk and verification key vk in such a way that no one learns about lambda.
Example 4: In Ethereum zk-rollups
- Can add the building blocks of the verification algorithm to Ethereum in the form of precompiled contracts.
References
Mentioned in
Subscribe to Dwarves Memo
Receive the latest updates directly to your inbox.
zk-SNARKsLoading...

