Skip to content

About

Demo code for tutorial "Integrate zkTLS into your Aztec app"

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

Demo code for tutorial "Integrate zkTLS into your Aztec app"

Aztec version 4.2.0-aztecnr-rc.2.

Demo for https://github.com/primus-labs/zktls-verification-noir/

This repo demonstrates the full flow of obtaining a zkTLS attestation via Primus, deploying an Aztec smart contract that can verify this attestation and finally executing the verification function via a transaction. It is meant as a full example to get you started to incorporate Primus zkTLS in your own Aztec app.

Important links

Setup

Make sure to obtain all the code:

git clone https://github.com/hashcloak/zktls_aztec_demo
cd zktls_aztec_demo
git submodule init
git submodule update

Install Aztec following the instructions on their website.

Attestation parsing library & Aztec SDK

Build the parsing library and Aztec SDK:

cd zktls-verification-noir/att_verifier_parsing
yarn && yarn build
cd ../aztec-attestation-sdk
yarn && yarn build

dvc-client environment

The dvc-client uses the Primus network to perform zkTLS attestations. It requires a wallet with a small amount of ETH on Base Sepolia to pay for on-chain task submission.

cd dvc-client
cp .env.example .env

Fill in .env:

Variable Description
PRIVATE_KEY Private key of a Base Sepolia wallet (needs a small amount of ETH for gas)
CHAIN_ID 84532 for Base Sepolia (default)
RPC_URL RPC endpoint, e.g. https://sepolia.base.org
GITHUB_REPO_OWNER GitHub username or org that owns the target repo
GITHUB_REPO_NAME Repository name
GITHUB_TOKEN (Optional) Personal access token — raises rate limit from 60 to 5000 req/hr. Create at https://github.com/settings/tokens.

Then install dependencies:

npm install

Running the demo

The two attestation modes (hash-based and commitment-based) follow the same three steps. The only difference is which dvc-client script you run in step 1 and which verification script you run in step 3.

Step 1 — Obtain attestation

From the dvc-client directory:

# Hash-based
node demo/demo_github_contributors_hash.js

# Commitment-based
node demo/demo_github_contributors_commitment.js

The attestation JSON will be saved locally.

Step 2 — Compile the Aztec smart contract

The contract supports both attestation modes, so this step is the same either way:

cd zktls-verification-noir/example/github_example
aztec compile
aztec codegen -o ../js_test/bindings target

Step 3 — Deploy and verify

The script for deployment and verification are located in zktls-verification-noir/example/js_test for both hash-based and commitment-based attestations. First, install dependencies:

cd ../js_test
yarn install

Make sure there is a local Aztec network running:

aztec start --local-network

Run the example scripts that deploy the verifier contract and run a verification transaction:

# Hash-based
yarn tsx local-verify-github-comm.ts 

# Commitment-based
yarn tsx local-verify-github-hash.ts 

Note

There are additional scripts in dvc-client/demo to obtain the liveness of BTC-USD trading pair via okx.com, for both hash-based and commitment-based attestations. The verifier contract for that case is in zktls-verification-noir/example/okx_example, and the scripts for deployment and verification are zktls-verification-noir/example/js_test/local-verify-okx-comm.ts and zktls-verification-noir/example/js_test/local-verify-okx-hash.ts.

About

Demo code for tutorial "Integrate zkTLS into your Aztec app"

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages