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
- Primus DVC demo code used in this repo
- Primus Docs
- Aztec Docs
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.
Build the parsing library and Aztec SDK:
cd zktls-verification-noir/att_verifier_parsing
yarn && yarn build
cd ../aztec-attestation-sdk
yarn && yarn buildThe 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 .envFill 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 installThe 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.
From the dvc-client directory:
# Hash-based
node demo/demo_github_contributors_hash.js
# Commitment-based
node demo/demo_github_contributors_commitment.jsThe attestation JSON will be saved locally.
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 targetThe 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 installMake sure there is a local Aztec network running:
aztec start --local-networkRun 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
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.