zkPass
zkPass Developer's Guide
zkPass Developer's Guide
  • â›Šī¸Introduction
  • ZKPASS OVERVIEW
    • đŸ›ī¸Architecture
    • 🧱zkPass Components
    • 🤝Trust Models
    • 🚚Deployment
      • Public-Cloud Hosting
      • Private-Cloud Hosting
      • On-Premise Hosting
    • đŸŽ¯SDK Objectives
    • 🔑API Key
  • zkPass Modules
    • â˜ī¸DVR
      • đŸ—ģHigh Level View
      • đŸ—ī¸Key Concepts
        • User Data
        • DVR Info
        • zkPass Proof
      • đŸ‘ĨDVR Client Roles
        • Data Issuer
          • Providing User Data Retrieval API
        • Data Holder
          • 1. Retrieving the DVR
          • 2. Retrieving the User Data
          • 3. Generating the Proof
          • 4. Verifying the Proof
        • Proof Verifier
          • 1. Providing DVR Retrieval API
          • 2. Providing Proof Verification API
      • 🔎DVR Query
        • Building Query Engine
        • Processing Query
        • Query Grammar
      • đŸ—ī¸Integration Guidelines
      • 🌊DVR Workflows
  • SDK Tutorial
    • Typescript
      • Running Code
      • Code Snippet
      • Directory Structure
    • Rust
      • Running Code
      • Code Snippet
      • Directory Structure
  • API Reference
    • Typescript
      • Classes
        • Class: DvrModuleClient
      • Functions
        • Functions: ffiHelper
        • Functions: jwtHelper
        • Functions: publicKeyOptionUtils
      • Type Aliases
        • Types
        • Types: ffiType
      • Interfaces
        • Interfaces
      • Constants
        • Constants
        • Enums
      • Errors
    • Rust
      • Building Rust doc
    • RESTful API
      • Overview
      • Endpoints
        • Generate Proof
      • Utilities
        • Generate Key Pair
        • Sign User Data and DVR
        • Encrypt User Data and DVR
      • Errors
  • Glossary
    • DVR
    • User Data
    • ZKP
Powered by GitBook
On this page
  • System Requirements
  • Installing the SDK and Run zkpass-demo
  • Troubleshooting
  • Fetch Timeout
  • Missing/Corrupt .so Files
Export as PDF
  1. SDK Tutorial
  2. Rust

Running Code

PreviousRustNextCode Snippet

Last updated 12 days ago

System Requirements

  1. Ubuntu version 20 or higher WSL (Windows Subsystem for Linux) is also supported. Other similar Linux distros should also work.

For WSL installation guide, .

  1. Some APT package dependencies Run the following to install the required packages:

sudo apt install build-essential
sudo apt install pkg-config
sudo apt install libssl-dev
  1. Rust compiler toolchain Follow this 2-step instruction to install the Rust toolchain.

# 1: install cargo toolchain
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
# 2: source the cargo env for the first time
source "$HOME/.cargo/env"

Installing the SDK and Run zkpass-demo

Follow these steps to install the zkPass SDK and to run the demo application.

For the purposes of this guide, the zkpass-sdk repository is cloned under the home directory of the current user, retaining its default name. This places the root directory for the zkpass-sdk repository at ~/zkpass-sdk. As a result, the directory for the Rust/Linux binding of the SDK is set at ~/zkpass-sdk/rust.

Should you choose to clone the zkpass-sdk repository into a different location, ensure that you adjust any referenced paths in the instructions to match your chosen directory structure.

  1. Clone the zkpass-sdk repo

git clone https://github.com/gl-zkPass/zkpass-sdk.git
  1. Enter zkpass-sdk/rust Directory

cd zkpass-sdk/rust
  1. Set up environment variables (Use zkpass-demo/.env.example as starting point)

cp zkpass-demo/.env.example zkpass-demo/.env
  1. From the zkpass-sdk/rust directory, execute test.sh script to build the SDK and run the demo application:

./test.sh

The correct output of zkpass-demo should look like the following:

<== Using Single User Data ==>
#### starting zkpass proof generation...
2024-09-03T07:23:42.591248Z  INFO run_data_holder{zkvm="r0" ... (omitted for clarity) ... >> generate_zkpass_proof
2024-09-03T07:23:42.626726Z  INFO run_data_holder{zkvm="r0" ... (omitted for clarity) ... Fetching public keys from https://playground-zkpass.ssi.id/.well-known/jwks.json
2024-09-03T07:23:48.169443Z  INFO run_data_holder{zkvm="r0" ... (omitted for clarity) ... << generate_zkpass_proof
#### generation completed [time=5.833258046s]

#### starting zkpass proof verification...
2024-09-03T07:23:48.424559Z  INFO run_data_holder{zkvm="r0" ... (omitted for clarity) ... >> verify_zkpass_proof_internal
2024-09-03T07:23:48.461295Z  INFO run_data_holder{zkvm="r0" ... (omitted for clarity) ... Fetching public keys from https://playground-zkpass.ssi.id/.well-known/jwks.json
2024-09-03T07:23:48.729210Z  INFO run_data_holder{zkvm="r0" ... (omitted for clarity) ... >> verify_zkproof
2024-09-03T07:23:48.729437Z  INFO run_data_holder{zkvm="r0" ... (omitted for clarity) ... << verify_zkproof
2024-09-03T07:23:48.732602Z  INFO run_data_holder{zkvm="r0" ... (omitted for clarity) ... << verify_zkpass_proof_internal
#### found dvr: id=868cbebb-9172-4807-846f-7f5bea6d20e3
#### verification completed [time=308.127227ms]
json-result={
  "name": "Dewi",
  "result": true
}
>> output list:
key=name, value=Str("Dewi")
key=result, value=Bool(true)
<< end of list
the query result is true

... (omitted for clarity) ...


<== Using Multiple User Data ==>
#### starting zkpass proof generation...
... (omitted for clarity) ...
#### generation completed [time=5.33967994s]

#### starting zkpass proof verification...
... (omitted for clarity) ...
#### verification completed [time=221.231359ms]
json-result={
  "name": "Dewi",
  "result": true
}
>> output list:
key=name, value=Str("Dewi")
key=result, value=Bool(true)
<< end of list
the query result is true

... (omitted for clarity) ...


<== Using Example ==>
#### starting zkpass proof generation...
... (omitted for clarity) ...
#### generation completed [time=5.55306725s]

#### starting zkpass proof verification...
... (omitted for clarity) ...
#### verification completed [time=288.768931ms]
json-result={
  "title": "Loan Query Results",
  "result": true,
  "name": "Ramana",
  "email": "Ramana.Maharshi@karma.org"
}
>> output list:
key=title, value=Str("Loan Query Results")
key=result, value=Bool(true)
key=name, value=Str("Ramana")
key=email, value=Str("Ramana.Maharshi@karma.org")
<< end of list
the query result is true

Troubleshooting

Fetch Timeout

This demo will download a binary file. If the download process times out, try the following solutions:

  1. Ensure you have a stable internet connection when running the script.

  2. Turn off any active VPNs and try again.

Missing/Corrupt .so Files

The error message "cannot open shared object file: No such file or directory" indicates an issue. This may occur due to missing or corrupted .so. Here are some possible solutions:

  1. Ensure you have a stable internet connection when running the script.

  2. Turn off any active VPNs and try again.

  3. Manually download the .so file:

    1. Move these files to zkpass-sdk/rust/lib folder.

    2. Comment out download-so.sh in test.shscript.

    3. Run the test.sh script again; the error should be resolved.

Download file from the website.

read here
libdvr_client.so