LogoLogo
  • Overview
  • Basics
    • Architecture
  • Key Concepts
    • EVM Ledger
    • UTXO Chain
      • Confidential transfers
        • Overview
        • Concepts
        • Technical Specifications
    • Prism++ Transfer
    • Triple Masking
      • Overview
      • SDK Installation
      • Bar to Abar
      • Abar to Bar
      • Abar Transfer
    • Staking
      • Overview
      • EVM Staking
        • UTXO Staking and EVM Staking
        • EVM Staking Portal User Guide
      • Consensus
      • Rewards
      • Penalties
  • Developers
    • Acquire Testnet FRA
    • EVM Tools & Tutorials
      • Contract Deployment
        • Ganache
        • Hardhat
        • Remix
        • Truffle
        • Waffle
      • The Graph
      • Band Protocol
      • Mint NFTs
        • Deploy NFT Contract (1 of 3)
        • Mint NFT (2 of 3)
        • View NFT (3 of 3)
    • Developer SDKs
      • UTXO Native Chain SDK
        • UTXO Native Chain SDK Installation
        • Developer Tools
          • Findora CLI Tool
        • UTXO API Reference
          • Account
          • Keypair
          • Network
          • Asset
          • Staking
          • Transaction
          • Helpers
      • ZkRouting SDK
      • zkDID SDK
        • zkDID SDK Installation
        • zkDID API Reference
        • zkDID Example Code
      • Prism++ SDK
    • EVM References
      • Metamask
      • Local Development Network Setup
      • EVM API Reference
      • Precompiled Contracts
    • Resources
      • Bug Bounties
      • Events
        • 🏗️ETH San Francisco 2022
          • zkDID and Credentials
        • 🏗️ETH Denver 2023
    • Game-Specific Chains
      • GSC Highlights
      • User Guide
      • Developer Tools
  • Network Settings
    • Contract Addresses
    • Network Settings
  • General User Materials
    • Acquire FRA
    • Acquire FRA (Testnet)
    • Stake FRA
    • Use Wallets
      • MetaMask
        • Download
        • Configure (Auto)
        • Configure (Manual)
      • Findora Wallet
        • Download
        • New Wallet
        • Transfer
        • Prism++
        • Adding Assets to the Findora Wallet
        • Manage Assets
      • Ledger Hardware Wallet
    • Bridging Tokens to Findora
    • Use Block Explorers
    • Explore Testnet
      • Triple Masking
        • Triple Masking Demo
      • EVM Staking
      • Prism++
        • Prism++ Testing Campaign
          • 💰Testnet Wallet Setup/Funding
          • 👨‍🌾👨🌾 Peasant: Prism++ Campaign Signup
          • 🧒Pupil: FRC20 Token Transfers
          • 🧑‍🎨🧑🎨 Pilgrim: FRC 721 Token Transfers
          • 🧑‍🎓🧑🎓 Prodigy: FRC1155 Token Transfers
          • 🧑‍🚀🧑🚀 Pioneer: Mainnet Transfers
          • Prism++ Testnet Campaign FAQs
    • Gaxle Events
      • Game Chain Challenges
        • Getting Started
        • The Campaigns
        • The Reward Raffles
  • Validator Materials
    • Findora's University Program
    • Validator Setup Guides
      • System Requirements
      • Acquire a Server
      • Validator Toolbox Setup
        • New Build
        • Existing Build
        • Additional Info
      • Manual Setup
      • Automated Setup (Deprecated)
    • Upgrade Guides
      • Node Upgrade (Toolbox)
      • Node Upgrade (Manual)
      • fn CLI Upgrade (Wallet)
    • Operational Guides
      • Emergency Recovery
      • Data Backup
      • CLI Staking
Powered by GitBook
On this page
  • Overview
  • Example 1
  • Example 2
  • Example 3

Was this helpful?

Edit on GitHub
  1. Developers
  2. Developer SDKs
  3. zkDID SDK

zkDID Example Code

PreviouszkDID API ReferenceNextPrism++ SDK

Last updated 2 years ago

Was this helpful?

Overview

Below are code examples of how the zkDID API can be used to create DID identifiers, zkCircuits, zkCredentials and zkProofs — as well as verifying zkProofs. To learn more about how DIDs and credentials work in general, visit the .

The full example codebase can be accessed here: .

Example 1

// # Example 1: Use pre-defined zkCircuit and zkCredential to create and verify zkProofs #

// ### Goal ###

// The code example below showcases how to use pre-generated (i.e. mocked up) zero-knowledge (zk) proof circuits that can verify that GPA is above a certain range and related to a zkCredential containing a GPA value.

// ### Use Pre-Defined Objects (to simplify things for demo purposes) ###

// The example code provides a pre-defined wallet address (”address”), a pre-defined did identifier (”did”), a pre-defined zkCredential (”GPACredential()”) representing GPA, and a pre-defined zkCircuit (”CONSTRAINT_GPA_35” that checks if GPA is greater than 3.5)

// ### Key SDK APIs Used ###

// For example purposes, the code creates a zkCredential (”createZKCredential()”) for the user with a GPA of 4.0, creates a zkCircuit (”ZKCircuit()”) to check if GPA is greater than 3.5, creates a zkProof (”generateZKProof()” using the zkCredential as the input) and then verifies the credential (”verifyZKProof()”)

// ### Real-World Notes ###

// In real-world, the identity issuer would create the DID identifier and first zkCredential (”createZKCredential()”) with name and perhaps date of birth for the DID holder. The identity issuer would also create their own zkCircuit (”ZKCircuit()”) or have a trusted partner create it to be used to generate a zkProof to prove the date of birth. A 3rd party (or even verifier) Dapp would enable users to create the zkProof (”generateZKProof()”), and the verifier Dapp would verify the proof.


Example 2

// # Example 2: Create Custom zkCircuit and zkCredential to create and verify zkProofs #

// ### Goal ###

The code example below showcases how to create your own custom zkCircuit and zkCredential. Later, you will create a zkProof from your custom credential and then verify the zkProof.

// ### Key Code Components ###

// Part a) Create a custom credential (KYC_Credential). This example chooses to create a custom credential that stores three values a) dateOfBirth and b) name, and c) country

// Part b) Create constraints (which will be used in the zkCircuits later) that allow the zkCircuits to prove specific facts about the DID holder. This examples creates constraints to prove i) born after year 1900 or 2000 (”KYC_BORN_in_the_20th_century_min”/”max”) and ii) country of birth (”KYC_Country_ASoutheast_Asia_v0001_range”)

// Part c) Create an array of example wallets addresses (and DID identifiers) — each representing a unique DID holder with a random birthdate and country of birth generated for each of them

// Part d) Create a custom zkCircuit with two constraints — using the constraints defined above for 1) birth date and 2) country

// Part e) Create a zkCredential and zkProof for each DID holder created earlier and then verify the zkProof


Example 3

// # Example 3: Use custom credential and multiple circuits to create proofs and verify zkProofs #

// ### Goal ###

// Similar to Example 2 but creates more zkCircuits for different verifications.

zkDID and Credentials modules section
https://zkdid.pages.dev
https://zkdid.pages.dev
https://zkdid.pages.dev
https://zkdid.pages.dev