Skip to content

Commit

Permalink
test circuits
Browse files Browse the repository at this point in the history
  • Loading branch information
olomix committed Nov 16, 2023
1 parent b489d24 commit 0cde853
Show file tree
Hide file tree
Showing 7 changed files with 332 additions and 0 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,61 @@ on:
- cibuild

jobs:
build-apple-test:
runs-on: macos-13-xlarge
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"

- name: Cache circuits
uses: actions/cache@v3
with:
path: |
circuits
key: circuits-ci.zip

- name: Get circuits
run: |
set -e
if [[ ! -d "circuits" ]]; then
curl -o circuits/ci.zip -L https://iden3-circuits-bucket.s3.eu-west-1.amazonaws.com/ci.zip
unzip -o circuits/ci.zip -d circuits
rm circuits/ci.zip
fi
- name: Cache gmp build
uses: actions/cache@v3
with:
path: |
depends/gmp
depends/gmp-6.2.1.tar.xz
key: ${{ runner.os }}-witnesscalc-gmp-apple-arm64-${{ hashFiles('build_gmp.sh') }}

- name: install dependencies
run: |
brew install nasm
- name: build gmp
run: |
if [[ ! -d "depends/gmp/package" ]]; then ./build_gmp.sh host; fi
if [[ ! -d "depends/gmp/package_ios_arm64" ]]; then ./build_gmp.sh ios; fi
if [[ ! -d "depends/gmp/package_iphone_simulator" ]]; then ./build_gmp.sh ios_simulator; fi
- name: build
run: |
mkdir build_witnesscalc && cd build_witnesscalc
cmake .. -DTARGET_PLATFORM=arm64_host -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package
make -j8 -vvv
make install
cd ../
- name: test witness generation
run: |
npm install -g snarkjs
mkdir temp
./run_tests.sh
build-apple-arm64:
runs-on: macos-13-xlarge
if: false
Expand Down Expand Up @@ -107,6 +162,7 @@ jobs:

build-linux:
runs-on: ubuntu-22.04
if: false
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -143,3 +199,27 @@ jobs:

- name: build android_x86_64
run: make android_x86_64

- name: upload Linux amd64 artifacts
uses: actions/upload-artifact@v3
with:
name: witnesscalc-linux-amd64
path: |
package
if-no-files-found: error

- name: upload Android artifacts
uses: actions/upload-artifact@v3
with:
name: witnesscalc-Android
path: |
package_android
if-no-files-found: error

- name: upload Android x86_64 artifacts
uses: actions/upload-artifact@v3
with:
name: witnesscalc-Android-x86_64
path: |
package_android_x86_64
if-no-files-found: error
69 changes: 69 additions & 0 deletions run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env bash

set -e
set -x

package/bin/authV2 \
testdata/authV2_input.json \
temp/authV2_witness.wtns
snarkjs groth16 prove \
circuits/authV2/circuit_final.zkey \
temp/authV2_witness.wtns \
temp/authV2_proof.json \
temp/authV2_public.json
snarkjs groth16 verify \
circuits/authV2/verification_key.json \
temp/authV2_public.json \
temp/authV2_proof.json

package/bin/credentialAtomicQuerySigV2 \
testdata/credentialAtomicQuerySigV2_input.json \
temp/credentialAtomicQuerySigV2_witness.wtns
snarkjs groth16 prove \
circuits/credentialAtomicQuerySigV2/circuit_final.zkey \
temp/credentialAtomicQuerySigV2_witness.wtns \
temp/credentialAtomicQuerySigV2_proof.json \
temp/credentialAtomicQuerySigV2_public.json
snarkjs groth16 verify \
circuits/credentialAtomicQuerySigV2/verification_key.json \
temp/credentialAtomicQuerySigV2_public.json \
temp/credentialAtomicQuerySigV2_proof.json

package/bin/credentialAtomicQuerySigV2OnChain \
testdata/credentialAtomicQuerySigV2OnChain_input.json \
temp/credentialAtomicQuerySigV2OnChain_witness.wtns
snarkjs groth16 prove \
circuits/credentialAtomicQuerySigV2OnChain/circuit_final.zkey \
temp/credentialAtomicQuerySigV2OnChain_witness.wtns \
temp/credentialAtomicQuerySigV2OnChain_proof.json \
temp/credentialAtomicQuerySigV2OnChain_public.json
snarkjs groth16 verify \
circuits/credentialAtomicQuerySigV2OnChain/verification_key.json \
temp/credentialAtomicQuerySigV2OnChain_public.json \
temp/credentialAtomicQuerySigV2OnChain_proof.json

package/bin/credentialAtomicQueryMTPV2 \
testdata/credentialAtomicQueryMTPV2_input.json \
temp/credentialAtomicQueryMTPV2_witness.wtns
snarkjs groth16 prove \
circuits/credentialAtomicQueryMTPV2/circuit_final.zkey \
temp/credentialAtomicQueryMTPV2_witness.wtns \
temp/credentialAtomicQueryMTPV2_proof.json \
temp/credentialAtomicQueryMTPV2_public.json
snarkjs groth16 verify \
circuits/credentialAtomicQueryMTPV2/verification_key.json \
temp/credentialAtomicQueryMTPV2_public.json \
temp/credentialAtomicQueryMTPV2_proof.json

package/bin/credentialAtomicQueryMTPV2OnChain \
testdata/credentialAtomicQueryMTPV2OnChain_input.json \
temp/credentialAtomicQueryMTPV2OnChain_witness.wtns
snarkjs groth16 prove \
circuits/credentialAtomicQueryMTPV2OnChain/circuit_final.zkey \
temp/credentialAtomicQueryMTPV2OnChain_witness.wtns \
temp/credentialAtomicQueryMTPV2OnChain_proof.json \
temp/credentialAtomicQueryMTPV2OnChain_public.json
snarkjs groth16 verify \
circuits/credentialAtomicQueryMTPV2OnChain/verification_key.json \
temp/credentialAtomicQueryMTPV2OnChain_public.json \
temp/credentialAtomicQueryMTPV2OnChain_proof.json
179 changes: 179 additions & 0 deletions testdata/authV2_input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
{
"genesisID": "23148936466334350744548790012294489365207440754509988986684797708370051073",
"profileNonce": "10",
"authClaim": [
"80551937543569765027552589160822318028",
"0",
"4720763745722683616702324599137259461509439547324750011830105416383780791263",
"4844030361230692908091131578688419341633213823133966379083981236400104720538",
"16547485850637761685",
"0",
"0",
"0"
],
"authClaimIncMtp": [
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0"
],
"authClaimNonRevMtp": [
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0"
],
"authClaimNonRevMtpAuxHi": "0",
"authClaimNonRevMtpAuxHv": "0",
"authClaimNonRevMtpNoAux": "1",
"challenge": "12345",
"challengeSignatureR8x": "15829360093371098546177008474519342171461782120259125067189481965541223738777",
"challengeSignatureR8y": "10840522802382821290541462398953040493080116495308402635486440290351677745960",
"challengeSignatureS": "1196477404779941775725836688033485533497812196897664950083199167075327114562",
"claimsTreeRoot": "8162166103065016664685834856644195001371303013149727027131225893397958846382",
"revTreeRoot": "0",
"rootsTreeRoot": "0",
"state": "8039964009611210398788855768060749920589777058607598891238307089541758339342",
"gistRoot": "1243904711429961858774220647610724273798918457991486031567244100767259239747",
"gistMtp": [
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0"
],
"gistMtpAuxHi": "1",
"gistMtpAuxHv": "1",
"gistMtpNoAux": "0"
}
1 change: 1 addition & 0 deletions testdata/credentialAtomicQueryMTPV2OnChain_input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"requestID":"23","userGenesisID":"26109404700696283154998654512117952420503675471097392618762221546565140481","profileNonce":"0","claimSubjectProfileNonce":"0","issuerID":"27918766665310231445021466320959318414450284884582375163563581940319453185","issuerClaim":["3583233690122716044519380227940806650830","26109404700696283154998654512117952420503675471097392618762221546565140481","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimMtp":["0","10304430946970870697981400054531724100803206948489006715521525892274350097449","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerClaimClaimsTreeRoot":"21551875744466996287712204148827400686061292275961899951444219768723484280073","issuerClaimRevTreeRoot":"0","issuerClaimRootsTreeRoot":"0","issuerClaimIdenState":"19157496396839393206871475267813888069926627705277243727237933406423274512449","issuerClaimNonRevClaimsTreeRoot":"21551875744466996287712204148827400686061292275961899951444219768723484280073","issuerClaimNonRevRevTreeRoot":"0","issuerClaimNonRevRootsTreeRoot":"0","issuerClaimNonRevState":"19157496396839393206871475267813888069926627705277243727237933406423274512449","issuerClaimNonRevMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerClaimNonRevMtpAuxHi":"0","issuerClaimNonRevMtpAuxHv":"0","issuerClaimNonRevMtpNoAux":"1","isRevocationChecked":1,"claimSchema":"180410020913331409885634153623124536270","claimPathNotExists":1,"claimPathMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"claimPathMtpNoAux":"1","claimPathMtpAuxHi":"0","claimPathMtpAuxHv":"0","claimPathKey":"0","claimPathValue":"0","operator":1,"slotIndex":2,"timestamp":1642074362,"value":["10","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"authClaim":["80551937543569765027552589160822318028","0","17640206035128972995519606214765283372613874593503528180869261482403155458945","20634138280259599560273310290025659992320584624461316485434108770067472477956","15930428023331155902","0","0","0"],"authClaimIncMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"authClaimNonRevMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"authClaimNonRevMtpAuxHi":"0","authClaimNonRevMtpAuxHv":"0","authClaimNonRevMtpNoAux":"1","challenge":"10","challengeSignatureR8x":"2436614617352067078274240654647841101298221663194055411539273018411814965042","challengeSignatureR8y":"18597752099468941062473075570139025288787892531282848931228194191266230422780","challengeSignatureS":"1642466479083925938589665711747519202726798003514101885795868643287098549939","userClaimsTreeRoot":"9860409408344985873118363460916733946840214387455464863344022463808838582364","userRevTreeRoot":"0","userRootsTreeRoot":"0","userState":"1648710229725601204870171311149827592640182384459240511403224642152766848235","gistRoot":"11098939821764568131087645431296528907277253709936443029379587475821759259406","gistMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"gistMtpAuxHi":"27918766665310231445021466320959318414450284884582375163563581940319453185","gistMtpAuxHv":"20177832565449474772630743317224985532862797657496372535616634430055981993180","gistMtpNoAux":"0"}
1 change: 1 addition & 0 deletions testdata/credentialAtomicQueryMTPV2_input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"requestID":"23","userGenesisID":"26109404700696283154998654512117952420503675471097392618762221546565140481","profileNonce":"0","claimSubjectProfileNonce":"0","issuerID":"27918766665310231445021466320959318414450284884582375163563581940319453185","issuerClaim":["3583233690122716044519380227940806650830","26109404700696283154998654512117952420503675471097392618762221546565140481","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimMtp":["0","10304430946970870697981400054531724100803206948489006715521525892274350097449","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerClaimClaimsTreeRoot":"21551875744466996287712204148827400686061292275961899951444219768723484280073","issuerClaimRevTreeRoot":"0","issuerClaimRootsTreeRoot":"0","issuerClaimIdenState":"19157496396839393206871475267813888069926627705277243727237933406423274512449","issuerClaimNonRevClaimsTreeRoot":"21551875744466996287712204148827400686061292275961899951444219768723484280073","issuerClaimNonRevRevTreeRoot":"0","issuerClaimNonRevRootsTreeRoot":"0","issuerClaimNonRevState":"19157496396839393206871475267813888069926627705277243727237933406423274512449","issuerClaimNonRevMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerClaimNonRevMtpAuxHi":"0","issuerClaimNonRevMtpAuxHv":"0","issuerClaimNonRevMtpNoAux":"1","isRevocationChecked":1,"claimSchema":"180410020913331409885634153623124536270","claimPathNotExists":1,"claimPathMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"claimPathMtpNoAux":"1","claimPathMtpAuxHi":"0","claimPathMtpAuxHv":"0","claimPathKey":"0","claimPathValue":"0","operator":1,"slotIndex":2,"timestamp":1642074362,"value":["10","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]}
1 change: 1 addition & 0 deletions testdata/credentialAtomicQuerySigV2OnChain_input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"requestID":"23","userGenesisID":"26109404700696283154998654512117952420503675471097392618762221546565140481","profileNonce":"0","claimSubjectProfileNonce":"0","issuerID":"27918766665310231445021466320959318414450284884582375163563581940319453185","issuerClaim":["3583233690122716044519380227940806650830","26109404700696283154998654512117952420503675471097392618762221546565140481","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimNonRevClaimsTreeRoot":"10304430946970870697981400054531724100803206948489006715521525892274350097449","issuerClaimNonRevRevTreeRoot":"0","issuerClaimNonRevRootsTreeRoot":"0","issuerClaimNonRevState":"20177832565449474772630743317224985532862797657496372535616634430055981993180","issuerClaimNonRevMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerClaimNonRevMtpAuxHi":"0","issuerClaimNonRevMtpAuxHv":"0","issuerClaimNonRevMtpNoAux":"1","claimSchema":"180410020913331409885634153623124536270","issuerClaimSignatureR8x":"1651985418874087649697147889073653461168250997226887249132054770010575868904","issuerClaimSignatureR8y":"21186185889289266863036576968009990777000485497741800844819909873882380374550","issuerClaimSignatureS":"1462737848034339569304412491966425713268123077483712855404323511126257598464","issuerAuthClaim":["80551937543569765027552589160822318028","0","9582165609074695838007712438814613121302719752874385708394134542816240804696","18271435592817415588213874506882839610978320325722319742324814767882756910515","11203087622270641253","0","0","0"],"issuerAuthClaimMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerAuthClaimNonRevMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerAuthClaimNonRevMtpAuxHi":"0","issuerAuthClaimNonRevMtpAuxHv":"0","issuerAuthClaimNonRevMtpNoAux":"1","issuerAuthClaimsTreeRoot":"10304430946970870697981400054531724100803206948489006715521525892274350097449","issuerAuthRevTreeRoot":"0","issuerAuthRootsTreeRoot":"0","isRevocationChecked":1,"claimPathNotExists":1,"claimPathMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"claimPathMtpNoAux":"1","claimPathMtpAuxHi":"0","claimPathMtpAuxHv":"0","claimPathKey":"0","claimPathValue":"0","operator":1,"slotIndex":2,"timestamp":1642074362,"value":["10","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"authClaim":["80551937543569765027552589160822318028","0","17640206035128972995519606214765283372613874593503528180869261482403155458945","20634138280259599560273310290025659992320584624461316485434108770067472477956","15930428023331155902","0","0","0"],"authClaimIncMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"authClaimNonRevMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"authClaimNonRevMtpAuxHi":"0","authClaimNonRevMtpAuxHv":"0","authClaimNonRevMtpNoAux":"1","challenge":"10","challengeSignatureR8x":"2436614617352067078274240654647841101298221663194055411539273018411814965042","challengeSignatureR8y":"18597752099468941062473075570139025288787892531282848931228194191266230422780","challengeSignatureS":"1642466479083925938589665711747519202726798003514101885795868643287098549939","userClaimsTreeRoot":"9860409408344985873118363460916733946840214387455464863344022463808838582364","userRevTreeRoot":"0","userRootsTreeRoot":"0","userState":"1648710229725601204870171311149827592640182384459240511403224642152766848235","gistRoot":"11098939821764568131087645431296528907277253709936443029379587475821759259406","gistMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"gistMtpAuxHi":"27918766665310231445021466320959318414450284884582375163563581940319453185","gistMtpAuxHv":"20177832565449474772630743317224985532862797657496372535616634430055981993180","gistMtpNoAux":"0"}
Loading

0 comments on commit 0cde853

Please sign in to comment.