Verona 백서

Verona

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 54쪽 중 32쪽

h vkey is: * Identified by a unique name * Associated with a specific proving system * Required for on-chain proof verification ### Who Should Use This Guide **This guide is for developers who need to:** * Use **custom ZK circuits** (Circom, Gnark, Noir) for specialized verification logic * Publish verification keys for any ZK proving system supported by Verona > **Note**: Most verification integrations use pre-configured vkeys managed by the protocol. This guide is primarily for **advanced use cases** requiring custom circuits. If you're integrating standard verification features, start with the [Internet Verification (zkTLS)](/en/build-on-verona/verification/internet-verification) guides instead. ## Supported Proving Systems | Proving System | CLI Value | Format | Curve | Use Case | | ----------------- | ----------- | ------ | ----- | ------------------------- | | **Groth16** | `groth16` | JSON | BN254 | Circom/SnarkJS circuits | | **Gnark Groth16** | `gnark` | Binary | BN254 | gnark native circuits | | **UltraHonk** | `ultrahonk` | Binary | — | Noir/Barretenberg (≥0.87) | ## Prerequisites 1. **xiond installed** — See [Setting up your Local Environment](/en/build-on-verona/computation/local-development/setting-up-env/installation-prerequisites-setup-local-environment) 2. **A funded account** — You need $VERONA tokens to pay transaction fees ([request testnet tokens](/en/build-on-verona/references/testnet-tokens)) 3. **Your verification key file** — Generated from your ZK circuit ### Environment Setup ```bash # Set your RPC endpoint (see Public Endpoints for options) export RPC_URL="https://rpc.xion-testnet-2.burnt.com:443" # Set your chain ID export CHAIN_ID="xion-testnet-2" # Your account name in the keyring export ACCOUNT="mykey" ``` For network endpoints, see [Public Endpoints & Resources](/en/build-on-verona/references/public-endpoints-and-resources). *** ## Publishing VKeys ### Command Syntax ```bash xiond tx zk add-vkey [name] [vkey-file] [description] [proof-system] [flags] ``` **Parameters:** | Parameter | Description | | -------------- | ----------------------------------------------- | | `name` | Unique identifier for your vkey (max 128 bytes) | | `vkey-file` | Path to your verification key file | | `description` | Description of the circuit (max 1024 bytes) | | `proof-system` | One of: `groth16`, `gnark`, or `ultrahonk` | These size limits are enforced on-chain in bytes, not characters. For non-ASCII text, multi-byte UTF-8 characters count toward the byte limit according to their encoded size. **Common Flags:** | Flag | Description | | ------------------ | ------------------------------------------- | | `--from` | Your account name or address | | `--chain-id` | Chain ID (e.g., `xion-testnet-2`, `xion-1`) | | `--node` | RPC endpoint URL | | `--gas` | Gas limit (use `auto` for estimation) | | `--gas-prices` | Gas price (e.g., `0.001uxion`) | | `--gas-adjustment` | Gas adjustment factor (recommended: `1.5`) | *** ## Groth16 (Circom/SnarkJS) Use this for verification keys exported from Circom circuits compiled with SnarkJS. ### VKey Format Your `vkey.json` should have this structure: ```json { "protocol": "groth16", "curve": "bn128", "nPublic": 88, "vk_alpha_1": ["..."], "vk_beta_2": [["..."], ["..."]], "vk_gamma_2": [["..."], ["..."]], "vk_delta_2": [["..."], ["..."]], "vk_alphabeta_12": [...], "IC": [["..."], ...] } ``` ### Publishing ```bash # Export vkey from SnarkJS snarkjs zkey export verificationkey circuit.zkey vkey.json # Publish to Verona xiond tx zk add-vkey \ email_auth \ ./vkey.json \ "Email authentication circuit for account abstraction" \ groth16 \ --from $ACCOUNT \ --chain-id $CHAIN_ID \ --node $RPC_URL \ --gas auto \ --gas-prices 0.001uxion \ --gas-adjustment 1.5 ``` ### Verifying Proofs ```bash xiond query zk verify-proof \ ./proof.json \ --vkey-name email_auth \ --public-inputs "input1,input2,input3" \ --node $RPC_URL ``` *** ## Gnark (Native Groth16) Use this for verification keys generated from gnark circuits using the native Go library. ### Generating the VKey ```go package main import ( "os" "github.com/consensys/gnark-crypto/ecc" "github.com/consensys/gnark/backend/groth16" "github.com/consensys/gnark/frontend" "github.com/consensys/gnark/frontend/cs/r1cs" ) // Define your circuit type MyCircuit struct { X frontend.Variable `gnark:"x"` Y frontend.Variable `gnark:",public"` } func (circuit *MyCircuit) Define(api frontend.API) error { result := api.Mul(circuit.X, circuit.X) result = api.Mul(result, circuit.X) api.AssertIsEqual(result, circuit.Y) return nil } func main() { var circuit MyCircuit // Compile ccs, _ := frontend.Compile(ecc.BN254.ScalarField(), r1cs.NewBuilder, &circuit) // Setup pk, vk, _ := groth16.Setup(ccs) // Export verification key to binary file vkFile, _ := os.Create("vkey.bin") defer vkFile.Close() vk.WriteTo(vkFile) // Export proving key (for proof generation) pkFile, _ := os.Create("pkey.bin") defer pkFile.Close() pk.WriteTo(pkFile) } ``` ### Publishing ```bash xiond tx zk add-vkey \ cube_circuit \ ./vkey.bin \ "Cube computation circuit (x^3 = y)" \ gnark \ --from $ACCOUNT \ --chain-id $CHAIN_ID \ --node $RPC_URL \ --gas auto \ --gas-prices 0.001uxion \ --gas-adjustment 1.5 ``` ### Verifying Proofs ```bash xiond query zk verify-gnark \ ./proof.bin \ --vkey-name cube_circuit \ --public-inputs-file ./public_input.bin \ --node $RPC_URL ``` *** ## UltraHonk (Noir/Barretenberg) Use this for circuits compiled with Noir and proven using Barretenberg (version ≥0.87). ### Prerequisites ```bash # Install nargo (Noir compiler) — bb is included curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash noirup ``` ### Circuit Setup 1. Create a Noir project: ```bash nargo new my_circuit cd my_circuit ``` 2. Define your circuit in `src/main.nr`: ```noir fn main(x: pub Field, y: Field) { assert(x * x == y); } ``` 3. Compile and generate artifacts: ```bash # Compile nargo compile # Generate verification key bb write_vk -b ./target/my_circuit.json -o ./vkey.bin # Generate proof (with inputs in Prover.toml) bb prove -b ./target/my_circuit.json -w ./target/my_circuit.gz -o ./proof.bin ``` ### Publishing ```bash xiond tx zk add-vkey \ square_check \ ./vkey.bin \ "Square verification circuit (x^2 = y)" \ ultrahonk \ --from $ACCOUNT \ --chain-id $CHAIN_ID \ --node $RPC_URL \ --gas auto \ --gas-prices 0.001uxion \ --gas-adjustment 1.5 ``` ### Verifying Proofs ```bash xiond query zk verify-ultrahonk \ ./proof.bin \ --vkey-name square_check \ --public-inputs-file ./public_inputs.bin \ --node $RPC_URL ``` *** ## Managing VKeys ### Query Commands ```bash # Check if a vkey exists xiond query zk has-vkey email_auth --node $RPC_URL # Get vkey by name xiond query zk vkey-by-name email_auth --node $RPC_URL # Get vkey by ID xiond query zk vkey 0 --node $RPC_URL # List all vkeys xiond query zk vkeys --node $RPC_URL # List with pagination xiond query zk vkeys --limit 10 --page 1 --node $RPC_URL ``` ### Update a VKey Only the original uploader can update a vkey: ```bash xiond tx zk update-vkey \ email_auth \ ./new_vkey.json \ "Updated email authentication circuit v2" \ groth16 \ --from $ACCOUNT \ --chain-id $CHAIN_ID \ --node $RPC_URL \ --gas auto \ --gas-prices 0.001uxion \ --gas-adjustment 1.5 ``` ### Remove a VKey Only the original uploader can remove a vkey: ```bash xiond tx zk remove-vkey old_circuit \ --from $ACCOUNT \ --chain-id $CHAIN_ID \ --node $RPC_URL \ --gas auto \ --gas-prices 0.001uxion \ --gas-adjustment 1.5 ``` *** ## Reference ### Size Limits | Parameter | Maximum | | ----------------------- | ---------- | | VKey Size | 256 KiB | | Groth16 Proof Size | 4 KiB | | Groth16 Public Inputs | 30 KiB | | Gnark Proof Size | 4 KiB | | Gnark Public Inputs | 10 KiB | | UltraHonk Proof Size | 20 KiB | | UltraHonk Public Inputs | 10 KiB | | VKey Name | 128 bytes | | VKey Description | 1024 bytes | ### Gas Estimation VKey upload gas is calculated as: ``` gas = base_gas + (vkey_size / chunk_size) × chunk_gas ``` Default values: * **Chunk size:** 20 bytes * **Chunk gas:** 10,000 gas per chunk For a typical vkey (\~10KB), expect approximately 5,000,000–5,100,000 gas, depending on `base_gas`. ### Query Module Parameters ```bash xiond query zk params --node $RPC_URL ``` ### Networks | Network | Chain ID | RPC URL | | ------- | ---------------- | ------------------------------------------ | | Testnet | `xion-testnet-2` | `https://rpc.xion-testnet-2.burnt.com:443` | | Mainnet | `xion-1` | `https://rpc.xion-mainnet-1.burnt.com:443` | *** ## Troubleshooting | Error | Cause | Solution | | ---------------------------- | ------------------------------------------------ | -------------------------------------------------------------- | | `vkey already exists` | A vkey with this name is already registered | Use a different name or `update-vkey` to modify existing | | `verification key not found` | No vkey with the specified name or ID exists | Check if the vkey exists with `xiond query zk has-vkey <name>` | | `invalid vkey bytes` | File format doesn't match the specified system | Ensure JSON for `groth16`, binary for `gnark` and `ultrahonk` | | `vkey size exceeds limit` | VKey is larger than the maximum allowed size | Check limits with `xiond query zk params` | | `unauthorized` | Only the original uploader can update/remove | Use the same account that uploaded the vkey | | `proof verification failed` | Proof doesn't match the vkey or inputs are wrong | Verify correct vkey name, proof file, and public inputs format | ### Getting Help ```bash # Transaction commands help xiond tx zk --help xiond tx zk add-vkey --help xiond tx zk update-vkey --help xiond tx zk remove-vkey --help # Query commands help xiond query zk --help xiond query zk verify-proof --help xiond query zk verify-gnark --help xiond query zk verify-ultrahonk --help ``` ## Next Steps * Learn about the [Truth Engine](/en/about-verona/verification-infrastructure) * Explore [zkTLS Integration](/en/build-on-verona/verification/internet-verification) for internet data verification * See [Daemon CLI (`xiond`)](/en/build-on-verona/tools/daemon-cli) for general CLI usage # Internet Verification (zkTLS) Verona supports advanced **Zero Knowledge (ZK)** tools to enable developers to build privacy-preserving, verifiable applications that interact with real-world data, securely and credibly. Whether you're building identity-based apps, verification layers, or attestation protocols, the ZK stack on Verona gives you the tools to prove anything online without compromising privacy. ## Why Zero Knowledge? Zero Knowledge Proofs allow users to prove a fact is true, without revealing any underlying data. In the context of Verona, this means: * Verifying user attributes (like age, membership, or ownership) without sharing personal data. * Connecting on-chain logic to real-world, off-chain data sources like APIs and platforms. * Building privacy-first apps that still maintain trust and transparency. ## zkTLS: Verifying Web2 Data with Zero Knowledge **zkTLS** is a powerful protocol that lets developers verify HTTPS data (web2 websites, dashboards, portals) using zero knowledge proofs. It bridges the gap between trusted web2 platforms and on-chain smart contracts, without needing an API or centralized integration. #### Use Cases * Prove you have a certain follower count on X (formerly Twitter). * Prove attendance to a concert by showing a login to Ticketmaster. * Verify you're a student by logging into your university portal. * Authenticate any HTTPS session with trustless guarantees. ### How it Works on Verona Verona integrates zkTLS via the [Reclaim Protocol](https://reclaimprotocol.org), allowing mobile users to generate zk-proofs of identity or status, and enabling smart contracts on the Verona network to verify them. Get started with our guide on [zkTLS Integration using Reclaim in a Verona Mobile App](/en/build-on-verona/verification/internet-verification/zktls-integration-using-reclaim-in-a-mobile-app). ## zkFetch: Prove Anything Behind an API **zkFetch** extends the power of zkTLS by letting you fetch and prove arbitrary data from authenticated APIs, both public and private. It gives developers an interface to generate verifiable claims from any web service that requires login or access tokens. ### Example Use Cases * Prove your win/loss ratio in a gaming API. * Prove your fitness activity from Strava. * Prove subscription status on platforms like Netflix or Spotify. * Prove earnings from freelancing platforms like Upwork or Fiverr. ### Why it Matters With zkFetch, you’re not limited to static web data. You can verify API-authenticated information using the Reclaim App and connect it to your Verona dApp—creating rich, dynamic verification flows. Get started with our guide on [Verifying API Data with Zero Knowledge (zkFetch)](/en/build-on-verona/verification/internet-verification/verifying-api-data-with-zero-knowledge-zkfetch). ## Reclaim Protocol: Your Gateway to zk Identity [Reclaim Protocol](https://reclaimprotocol.org) is the underlying infrastructure powering both **zkTLS** and **zkFetch** on the Verona network. It enables users to privately generate and submit zk proofs from their mobile device based on real-world credentials. #### Key Features * Mobile-first integration with the Reclaim App * OAuth2-style provider setup for developers * Seamless zkTLS and zkFetch support * Used in production on Verona mobile dApps Whether you're proving your online reputation, access rights, or user attributes—Reclaim gives your app verifiability, security, and user privacy out of the box. # zkTLS Integration using Reclaim in a Mobile App The ability to verify real-world facts without compromising user privacy is critical. Traditional methods of user verification can introduce trust assumptions, privacy tradeoffs, and central points of failure. **zkTLS** (Zero-Knowledge Transport Layer Security) bridges this gap by allowing clients to generate verifiable proofs of HTTPS interactions, without revealing the full response or needing to trust the server. This has massive implications for Apps: * **Trustless verification** of real-world data from web2 sources (e.g., social platforms, email providers, SaaS tools) * **Privacy-preserving:** users reveal only what's necessary, not the full data * **On-chain utility:** proofs can be verified by smart contracts for gating access or triggering functionality ## Prerequisites Before you begin, ensure you have the following installed and configured: * [**Node.js** (LTS version recommended) and **npm**](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) * An Android Emulator via [Android Studio](https://docs.expo.dev/get-started/set-up-your-environment?platform=android\&device=physical\&mode=development-build\&buildEnv=local#set-up-an-android-device-with-a-development-build), iOS Simulator via [Xcode](https://docs.expo.dev/get-started/set-up-your-environment?platform=ios\&device=physical\&mode=development-build\&buildEnv=local#set-up-an-ios-device-with-a-development-build), **or** a physical mobile device for testing The following [guide](https://docs.expo.dev/guides/local-app-development) will help you set up your local development environment for Expo. We also have a guide to help [Set up your Verona Mobile Development Environment](/en/build-on-verona/accounts/mobile-app/set-up-mobile-development-environment), which shows how to get your Android emulator and iOS simulator set up. ## Create a Reclaim Account **Reclaim** is a decentralized identity protocol that allows users to prove facts about themselves, such as social media stats, financial data, or platform activity, using **zero-knowledge proofs (ZKPs)**. Rather than sharing raw data, Reclaim enables users to generate cryptographic proofs that can be verified on-chain without revealing the underlying information. In this guide, we’ll use Reclaim to let users prove their **Twitter follower count** without exposing their full profile or login credentials. This is done through Reclaim’s integration with trusted data providers like Twitter (Now X.com), wrapped in a ZK-proof that can be verified by your frontend or smart contract. To get started, you’ll need to: 1. Visit [Reclaim](https://dev.reclaimprotocol.org/explore) and sign in. 2. Create a new application. 3. Save your **Application ID** and **Application Secret**. 4. Add the "**Twitter User Profile**" provider to your application. You will need the "**httpProviderId**" later. ## Reclaim's Verification Contract Reclaim provides a zkTLS verification smart contract that validates user proofs. You do not need to deploy your own instance unless you want to customize it. The verification contract address is as follows: * Verification Contract Address: `xion1qf8jtznwf0tykpg7e65gwafwp47rwxl4x2g2kldvv357s6frcjlsh2m24e` ## Reclaim User Map (RUM) Contract The **Reclaim User Map (RUM)** contract is a modified version of the [User Map contract](/en/build-on-verona/computation/use-cases/building-a-per-user-data-storage-dapp#user-map-contract), designed to store per-user data in JSON format. Instead of storing arbitrary user data, this contract is purpose-built to: * Accept verified proof data from Reclaim (e.g., Twitter follower count) * Map the data to the user's address * Enable your application to query and verify the stored proof #### Example Document Schema ```javascript const claimInfo = { provider: verificationResult.proofs[0].claimData.provider, parameters: verificationResult.proofs[0].claimData.parameters, context: verificationResult.proofs[0].claimData.context, }; const signedClaim = { claim: { identifier: verificationResult.proofs[0].claimData.identifier, owner: verificationResult.proofs[0].claimData.owner, epoch: verificationResult.proofs[0].claimData.epoch, timestampS: verificationResult.proofs[0].claimData.timestampS, }, signatures: verificationResult.proofs[0].signatures, }; // This would be the execute message to update the RUM contract state const executeMsg = { update: { value: { proof: { claimInfo: claimInfo, signedClaim: signedClaim, }, }, }, }; ``` You can find the RUM contract here <https://github.com/burnt-labs/contracts/pull/72>. There are two parameters required when creating an instance of the contract: * **Verification Address**: Which is the address of the verification contract that will be called to verify if the proof is valid. * **Claim Key**: This is an element in the proof dataset that will be stored on chain. This comes from picking out the value from the `claimData.context` within the proof. For this guide we will be using the `followers_count` key. We have deployed a version of the RUM contract on Testnet with `CODE_ID` being `1289`. If you are using the [provided verification contract instance](#reclaims-verification-contract), you only need to update the `claim_key` parameter.\ If you are using your own verification contract, you must update both the `claim_key` and `verification_addr` parameters. ```javascript const instantiateRUMContract = async () => { if (!account?.bech32Address || !client) { Alert.alert("Error", "Account or client not found"); return; } try { const instantiateMsg = { verification_addr: "xion1qf8jtznwf0tykpg7e65gwafwp47rwxl4x2g2kldvv357s6frcjlsh2m24e", // this stays hardcoded to our verification contract claim_key: "followers_count", // Change this to whatever claim key you want to use }; let CODE_ID = 1289; const instantiateResult = await client.instantiate( account?.bech32Address, CODE_ID, instantiateMsg, "test-init", "auto" ); console.log("RUM contract instantiated:", instantiateResult); Alert.alert("Success", "RUM contract instantiated!"); return instantiate
프로젝트로 돌아가기