Developers Guide (zkVerify)

ajtech0001

AJTECH0001

Posted on August 17, 2024

Developers Guide (zkVerify)

Understanding Zero-knowledge Proofs

zero-knowledge proof (ZKP) is a way to prove something is true without actually revealing the details of what you're proving. The ability to prove a claim without having to reveal the underlying details of that claim.
At its core, the system operates on a three-party model: a prover, a verifier, and a challenge.

Prover: The party proving knowledge of a secret without revealing the secret itself.
Verifier: The party verifying the proof without revealing the secret.
Challenge: A process where the verifier challenges the prover to prove their claim without disclosing the secret.

Zero knowledge and web3

Zero-knowledge proof is one of the most powerful tools in the world of cryptography and blockchain. There are several reasons for this claim :

Enhanced privacy and security

It boosts privacy and security in transactions. With zero-knowledge proofs, you can prove a transaction is legit without giving away any personal details.

Scalability of blockchain networks

ZKPs and zkRollups significantly enhance blockchain scalability by enabling off-chain computation and validation. ZkRollups bundle transactions and submit a single proof to the blockchain, dramatically increasing transaction throughput.

New applications and use cases

Zero-knowledge opens the door to additional web3 use cases. Think proving you own a digital asset without anyone knowing who you are, or logging in without needing a password.

Cryptography

In cryptography, zero-knowledge proofs are integral to protocols like anonymous digital signatures and secure multiparty computation. They enable secure communication and data sharing without exposing sensitive information.

Some of the use cases of zero knowledge are:

Password verification

When you enter your password on a website, zero-knowledge proofs can verify it without the website actually seeing the password. This keeps your password private and secure.

Financial transactions

Zero-knowledge proofs ensure that financial transactions are valid without revealing sensitive details such as account balances or transaction amounts.

Identity verification

Zero-knowledge proofs can confirm a person's identity without disclosing any personally identifiable information. This is particularly useful in sensitive contexts like medical or legal situations.

zkSNARKs and zkSTARKs

These are two of the most well-known types of zero-knowledge proofs, each with its own quirks and features.

zkSNARKs (Zero-Knowledge Succinct Non-Interactive Argument of Knowledge) are known for their compact proofs and fast verification. They're great for quick checks in cases like blockchain transactions. But they also need an additional initial trusted setup.

zkSTARKs (Zero-Knowledge Scalable Transparent Argument of Knowledge) are newer and focus on handling bigger and more complex proofs efficiently. They skip the trusted setup part, which makes them more transparent and theoretically safer in some ways. However, they tend to have larger proofs and can take longer to verify compared to zkSNARKs.

What is zkVerify?

zkVerify is a platform or tool that focuses on verifying zero-knowledge proofs (ZKP). It essentially acts as a bridge between entities that generate ZKPs (provers) and those that need to verify their validity (verifiers).

zkVerify is a high-performance, public, decentralized, reliable, and secure blockchain. It offers modular solutions and more affordable proof verification, with verifiers written in the Rust programming language. Just like breaking down a big task into smaller, manageable parts, zkVerify makes blockchain processes smoother and more efficient! Feel free to explore their official website as well.

The “Goals of zkVerify”

Reducing Costs: Just like keeping amusement park tickets affordable, zkVerify helps keep blockchain-proof verification costs low and stable. This also enhances the efficiency by offloading the computational burden of the blockchain while reducing the cost.

Promoting Innovation: Just like adding new, thrilling rides to the park, zkVerify supports the use of new cryptographic methods, making the blockchain more versatile, modular, and innovative.

Ensuring Smooth Experience: By handling heavy verification processes, zkVerify ensures the blockchain runs smoothly, much like ensuring all the park's rides are up and running without long wait times.

Setting Up a Wallet and Connecting to Testnet

we will be going through the process of setting up a wallet and getting some zkVerift ACME testnet tokens.

Setting up a wallet

There are currently two recommended wallet options - Talisman and SubWallet. We will be going ahead and setting up a wallet with Talisman. Talisman provides a secure and user-friendly platform for managing assets, interacting with dApps, and exploring both the Polkadot and Ethereum ecosystems. It also comes with support for a variety of networks, NFT management, and hardware wallets, Talisman presents itself as a holistic wallet solution.

Click on https://www.talisman.xyz/ and click on the “Download Wallet” button.

Image description

Next, click on the “Add to Chrome button” to add the wallet extension to your Chrome. Please make sure you are using Chrome for this tutorial.

Now after adding the wallet, it will prompt you to the new window. Click on the “Get Started” button to continue.

Image description

You will be asked to choose a strong password now. Please set a strong password and click on the “Continue” button. If prompted to agree to privacy policies please click on the “I Agree” button.

Image description

Once you’re done, click on the “New Polkadot Account” button to create a new account.

Image description

You will be asked to give a name to your account. So, give any name to your account. We gave it zkVerify and click on the “Create” button.

Image description

You will be prompted to save your seed phrase. Make sure you save your seed phrase properly as it's very crucial. Verify your seed phrase next and complete the verification.

Image description

Once that is done, congratulations!!! You have successfully set up your wallet!!

Explore the zkVerify testnet blockchain

Now, let’s add Test Network and get some testnet $ACME tokens as well.

Click on the three dots in the lower right corner of the Talisman wallet. Then click on the “Settings” button as pointed out in the following image.

Select “Network & Tokens” from the left sidebar.

Choose the “Manage networks” option.

Image description

Find and click on “Polkadot” from the two of the options mentioned in the screenshot.

Click on the “Add Network” button as shown in the screenshot.

Fill in the information with the following and click on the “Add Network” button:

RPC URLs: wss://testnet-rpc.zkverify.io
Network Name: zkVerify Testnet

Image description

Now, once you have added a network when you search for networks, you should see your Network in the option.

Image description

Copy wallet address

Now, you need to find and copy the wallet address to get some testnet tokens. So, follow the following steps:

Go back to your Talisman wallet.

You must be able to see the account name you added to your account. Click on it.

Then click on the copy button.

Next, you will be prompted to select the network. Type “zkVerify” in the search bar. There you’ll find the “zkVerify Network”. Click on the copy button to finally copy the wallet address.

Image description

Get $ACME zkVerify testnet tokens

To get testnet $ACME token:

Go to Test Token Faucet Request form.

Enter your email address and wallet address you copied and should be able to receive $ACME within 24 hours.

Proof Submission Tutorial

we’re going to dive in and submit proofs for verification to zkVerify, walking through each step from start to finish.Let’s get started!

wsl --install

Make sure that if you are using Windows, use WSL to work with this project. Now let’s get started!

Clone GIT repository

First of all, open the terminal/CLI in your system and clone the repository using the following command.

git clone https://github.com/0xmetaschool/zkverify-proofverification.git

cd zkverify-proofverification

Do some installations

Now, we need to do some installations. So, run the following commands one by one.

Install the snarkjs latest version:
npm install -g snarkjs@latest

Install Rust. If prompted to ask about different installation setups please press “Enter” to just install the default ones.

curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh

Here’s what it looks like for us on macOS:

Image description

Now, we need to clone the circom git repository to do the installations. So, run the following command:

git clone https://github.com/iden3/circom.git

Move to circom folder and run the following cargo install command.

cd circom

cargo install --path circom

cd ..

Run the .sh file

Now, we need to run the circuit_setup.sh file. So, run the following commands.

sudo chmod +x circuit_setup.sh

./circuit_setup.sh

After running the command, you’ll see that many new files namely proof.json, public.json, and verification_key.json are generated as shown below:

Image description

Convert to zkVerify format

We need to convert JSON files to zkVerify format to submit them for proof verifications. Follow the following steps to do so.

Run the following commands one by one to set up the snarkjs2zkv.

git clone https://github.com/HorizenLabs/snarkjs2zkv.git

cd snarkjs2zkv

npm install

Run the following command and replace the path with the complete path of the proof.json file.

node snarkjs2zkv convert-proof <path_to_proof.json> -o proof_zkv.json

Run the following command and replace the path with the complete verification_key.json path.

node snarkjs2zkv convert-vk <path_to_verification_key.json> -o verification_key_zkv.json

Run the following command to convert the public.json file. Replace the path with the complete path of the public.json file.

node snarkjs2zkv convert-public <path_to_public.json> -o public_zkv.json -c bn128

After completing these steps, you will see three new files generated in snarkjs2zkv called proof_zkv.json, public_zkv.json, and verification_key_zkv.json

Thank you.

💖 💪 🙅 🚩
ajtech0001
AJTECH0001

Posted on August 17, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related