The application of zk-SNARKs to zero-knowledge proofs: Part 3

By TechThop, August 03, 2022

As we have previously shown, using a technique called ZK Key-Statement Proof, ZKKSP, we can construct a zero-knowledge proof ZKP that is valid for the following statement.

The basic idea behind it is that it proves not only the prover knows the secret key to a given public key, but also the secret hashes to the digest, but by doing so doesn't leak the secret. The ZKKSP model may be found to work, but there is a severe limitation to it: namely, it is only suitable for one specific form of a statement. That is, a secret is the private key of a given public key, as well as the preimage of a given hash.

The question is how to extend it to a slightly modified statement, such as saying that a secret is also an even number, not just having the attributes of a private key and preimage, but also being an even number.

As an added downside, coming up with such a scheme requires a patent-level understanding of cryptography, such as a basic understanding of protocol and commitment schemes. As a result of this, we have re-implemented the ZKKSP by leveraging the programmability of zkSNARKs. In this part, we combine the elliptic curve point multiplication used in Part 2 with the hashing library used in Part 1.

We are going to use ECDSAPrivToPub to derive a public key from the private key that we obtained at Line 14 by using ECDSAPrivToPub.As a final step, we have the same private key using Sha256 from the sha256 library imported at Line 3. This will ensure that the result matches the hash given in Line 17.

We have just "programmed" ZKKSP, meaning there is no need for prior knowledge of advanced cryptography to complete this task. As well as this, the composability of zkSNARKs makes it possible for us to add constraints to the secret, such as its evenness because they can be easily extended to add such constraints.


source: coin geek