Here's the directory structure for Tyepscript SDK tutorial.
Components :
MyHoder, MyIssuer, and MyVerifier provide an overview of the process.
The Libs folder contains the detailed implementation of each actor.
The Utils folder includes miscellaneous functions.
This section describes how we use the zkPass SDK in our demo code
This code snippet generates a zkPass proof. It requires 3 parameters:
SERVICE_URL
: you can use https://playground-zkpass.ssi.id
, or use your own endpoint if you deploy zkPass on your own server.
API_KEY
& API_SECRET
: Get yours at https://portal.ssi.id
userDataToken
: check section for more details.
dvrToken
: check section for more details.
This code snippet verifies a zkPass proof token. Components :
expectedMetadata
: this is the expected metadata of the dvr.
dvrPayload
: the dvr payload extracted from Dvr token.
This code snippet generate user data token. Components :
signingKey
: a private key used to sign user data.
data
: user data in JSON format.
verifyingKey
: a public key to verify that user data token.
This code snippet generate DVR token. Components :
signingKey
: a private key used to sign dvr.
dvrData
: Dvr data to sign.
zkPassProofToken
: check section for more details.
This section demonstrates how to use the DVR module client SDK to:
Generate a DVR token.
Generate a User Data token.
Generate a zkPass proof.
Verify a zkPass proof.
To install the Dvr Module Client lib separately, please refer to this section Installing the Dvr Module Client lib
Ubuntu version 20 or higher, WSL (Windows Subsystem for Linux) is also supported.
Node.js 18.17.0 or later.
Make sure the VPN is off
This command will enable the necessary features to run WSL and install the Ubuntu distribution of Linux.
If your underlying system, like Ubuntu, is already Linux-based, you can skip this step.
If your Windows version is below Windows 10 2004, please refer to this documentation instead.
Open PowerShell or Windows Command Prompt in administrator mode by right-clicking and selecting "Run as administrator"
Run the command below
Restart your machine
Once you have installed WSL, you will need to create a user account and password for your newly installed Linux distribution.
The above command only works if WSL is not installed at all, if you run wsl --install
and see the WSL help text, please try running wsl --list --online
to see a list of available distros and run wsl --install -d <DistroName>
to install a distro. To uninstall WSL, see Uninstall legacy version of WSL or unregister or uninstall a Linux distribution.
If you have installed WSL before, you can login using the command wsl
For a complete WSL installation guide, refer to this documentation.
nvm
allows you to quickly install and use different versions of node via the command line.
Run the command below
Restart your terminal session
To check whether Node has been installed properly, run the commands below:
Complete NVM documentation can be found here.
To check whether Node has been installed properly, run the commands below:
Complete Git documentation can be found here.
If you wish to explore our demo application, feel free to skip this installation step, as it has already been completed in the demo application.
If you want to use our zkpass-client-ts library on your own project / outside the demo application, you can follow this step
Set the npm registry configuration to gdp-labs registry.
Install the zkpass-client library for typescript
For NextJS projects with App Routing, several configurations have to be made in next.config.js
file:
The serverComponentsExternalPackages
configuration ensures that the package @zkpass/dvr-client-ts
is excluded from NextJS' bundling and compilation process, allowing it to be imported directly from node_modules
. As a result, remember to include the node_modules
directory in your production build. See NextJS Deployment Guide.
The demo application will run in a CLI and requires 2 parameters: DVR and user data. Please review zkPass key concepts to have better understanding of the use case.
To try our Typescript CLI demo, you can follow these steps
Clone demo repository
Go to Typescript CLI demo directory (Let's assume this is our root directory for steps below)
Install packages
Run Dewi demo
It will run the demo using predefined user data and DVR for Dewi. The expected query result is "false".
Expected result :
Run Ramana demo
It will run the demo using predefined user data and DVR for Ramana. The expected query result is "true".
Expected result :
Run Jane demo
It will run the demo using predefined user data and DVR for Jane. The expected query result is "true".
Expected result :
Run demo with custom data
You can run the demo using custom data. Examples for user data and DVR can be found in rust/test/data
.
Example running demo using custom data :
Expected result :
Run demo with multiple user data
You can also run the demo using multiple user data. Examples for multiple user data and DVR can be found in typescript/test/data/multiple
.
Example running demo using multiple data: