Skip to content

Commit

Permalink
Merge pull request #13 from 0xPolygonID/v3_circuits
Browse files Browse the repository at this point in the history
Support for V3 circuits
  • Loading branch information
olomix authored Dec 1, 2023
2 parents 1d4a0a8 + 7a40985 commit 3c8a515
Show file tree
Hide file tree
Showing 16 changed files with 2,169,832 additions and 3 deletions.
28 changes: 25 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches:
- main
- cibuild
- v3_circuits

jobs:
build-apple-arm64:
Expand Down Expand Up @@ -36,7 +36,7 @@ jobs:
run: |
mkdir build_witnesscalc && cd build_witnesscalc
cmake .. -DTARGET_PLATFORM=arm64_host -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package
make -j8 -vvv
make -j8
make install
cd ../
Expand All @@ -47,6 +47,8 @@ jobs:
xcodebuild -project witnesscalc.xcodeproj -destination 'generic/platform=iOS' -configuration Release -scheme witnesscalc_credentialAtomicQueryMTPV2Static
xcodebuild -project witnesscalc.xcodeproj -destination 'generic/platform=iOS' -configuration Release -scheme witnesscalc_credentialAtomicQuerySigV2OnChainStatic
xcodebuild -project witnesscalc.xcodeproj -destination 'generic/platform=iOS' -configuration Release -scheme witnesscalc_credentialAtomicQuerySigV2Static
xcodebuild -project witnesscalc.xcodeproj -destination 'generic/platform=iOS' -configuration Release -scheme witnesscalc_credentialAtomicQueryV3Static
xcodebuild -project witnesscalc.xcodeproj -destination 'generic/platform=iOS' -configuration Release -scheme witnesscalc_credentialAtomicQueryV3OnChainStatic
mkdir -p ../package_ios/lib
cp ../depends/gmp/package_ios_arm64/lib/libgmp.a ../package_ios/lib
cp \
Expand All @@ -56,6 +58,15 @@ jobs:
./src/Release-iphoneos/libwitnesscalc_credentialAtomicQueryMTPV2OnChain.a \
./src/Release-iphoneos/libwitnesscalc_credentialAtomicQuerySigV2.a \
./src/Release-iphoneos/libwitnesscalc_credentialAtomicQuerySigV2OnChain.a \
./src/Release-iphoneos/libwitnesscalc_credentialAtomicQueryV3.a \
./src/Release-iphoneos/libwitnesscalc_credentialAtomicQueryV3OnChain.a \
../src/authV2.dat \
../src/credentialAtomicQueryMTPV2.dat \
../src/credentialAtomicQueryMTPV2OnChain.dat \
../src/credentialAtomicQuerySigV2.dat \
../src/credentialAtomicQuerySigV2OnChain.dat \
../src/credentialAtomicQueryV3.dat \
../src/credentialAtomicQueryV3OnChain.dat \
../package_ios/lib
cp -r ../package/include ../package_ios/include
cd ../
Expand All @@ -67,6 +78,8 @@ jobs:
xcodebuild -project witnesscalc.xcodeproj -destination 'generic/platform=iOS Simulator' -configuration Debug -scheme witnesscalc_credentialAtomicQueryMTPV2Static
xcodebuild -project witnesscalc.xcodeproj -destination 'generic/platform=iOS Simulator' -configuration Debug -scheme witnesscalc_credentialAtomicQuerySigV2OnChainStatic
xcodebuild -project witnesscalc.xcodeproj -destination 'generic/platform=iOS Simulator' -configuration Debug -scheme witnesscalc_credentialAtomicQuerySigV2Static
xcodebuild -project witnesscalc.xcodeproj -destination 'generic/platform=iOS Simulator' -configuration Debug -scheme witnesscalc_credentialAtomicQueryV3Static
xcodebuild -project witnesscalc.xcodeproj -destination 'generic/platform=iOS Simulator' -configuration Debug -scheme witnesscalc_credentialAtomicQueryV3OnChainStatic
mkdir -p ../package_ios_simulator/lib
cp ../depends/gmp/package_iphone_simulator/lib/libgmp.a src/Debug-iphonesimulator
cp \
Expand All @@ -76,6 +89,15 @@ jobs:
./src/Debug-iphonesimulator/libwitnesscalc_credentialAtomicQueryMTPV2OnChain.a \
./src/Debug-iphonesimulator/libwitnesscalc_credentialAtomicQuerySigV2.a \
./src/Debug-iphonesimulator/libwitnesscalc_credentialAtomicQuerySigV2OnChain.a \
./src/Debug-iphonesimulator/libwitnesscalc_credentialAtomicQueryV3.a \
./src/Debug-iphonesimulator/libwitnesscalc_credentialAtomicQueryV3OnChain.a \
../src/authV2.dat \
../src/credentialAtomicQueryMTPV2.dat \
../src/credentialAtomicQueryMTPV2OnChain.dat \
../src/credentialAtomicQuerySigV2.dat \
../src/credentialAtomicQuerySigV2OnChain.dat \
../src/credentialAtomicQueryV3.dat \
../src/credentialAtomicQueryV3OnChain.dat \
../package_ios_simulator/lib
cp -r ../package/include ../package_ios_simulator/include
cd ../
Expand All @@ -85,7 +107,7 @@ jobs:
with:
path: |
circuits
key: circuits-ci.zip
key: circuits-ci-2.zip

- name: Get circuits
run: |
Expand Down
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ install(TARGETS
credentialAtomicQuerySigV2OnChain
witnesscalc_credentialAtomicQuerySigV2OnChain
witnesscalc_credentialAtomicQuerySigV2OnChainStatic
credentialAtomicQueryV3
witnesscalc_credentialAtomicQueryV3
witnesscalc_credentialAtomicQueryV3Static
credentialAtomicQueryV3OnChain
witnesscalc_credentialAtomicQueryV3OnChain
witnesscalc_credentialAtomicQueryV3OnChainStatic
fr
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
BUNDLE DESTINATION ${CMAKE_INSTALL_PREFIX}/app
Expand All @@ -67,6 +73,8 @@ install(FILES
src/credentialAtomicQueryMTPV2.dat
src/credentialAtomicQuerySigV2OnChain.dat
src/credentialAtomicQueryMTPV2OnChain.dat
src/credentialAtomicQueryV3.dat
src/credentialAtomicQueryV3OnChain.dat
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)

install(FILES
Expand All @@ -77,4 +85,6 @@ install(FILES
src/witnesscalc_credentialAtomicQueryMTPV2.h
src/witnesscalc_credentialAtomicQuerySigV2OnChain.h
src/witnesscalc_credentialAtomicQueryMTPV2OnChain.h
src/witnesscalc_credentialAtomicQueryV3.h
src/witnesscalc_credentialAtomicQueryV3OnChain.h
DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
52 changes: 52 additions & 0 deletions run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,55 @@ snarkjs groth16 verify \
circuits/credentialAtomicQueryMTPV2OnChain/verification_key.json \
temp/credentialAtomicQueryMTPV2OnChain_public.json \
temp/credentialAtomicQueryMTPV2OnChain_proof.json

package/bin/credentialAtomicQueryV3 \
testdata/credentialAtomicQueryV3_Sig_input.json \
temp/credentialAtomicQueryV3_Sig_witness.wtns
snarkjs groth16 prove \
circuits/credentialAtomicQueryV3/circuit_final.zkey \
temp/credentialAtomicQueryV3_Sig_witness.wtns \
temp/credentialAtomicQueryV3_Sig_proof.json \
temp/credentialAtomicQueryV3_Sig_public.json
snarkjs groth16 verify \
circuits/credentialAtomicQueryV3/verification_key.json \
temp/credentialAtomicQueryV3_Sig_public.json \
temp/credentialAtomicQueryV3_Sig_proof.json

package/bin/credentialAtomicQueryV3 \
testdata/credentialAtomicQueryV3_MTP_input.json \
temp/credentialAtomicQueryV3_MTP_witness.wtns
snarkjs groth16 prove \
circuits/credentialAtomicQueryV3/circuit_final.zkey \
temp/credentialAtomicQueryV3_MTP_witness.wtns \
temp/credentialAtomicQueryV3_MTP_proof.json \
temp/credentialAtomicQueryV3_MTP_public.json
snarkjs groth16 verify \
circuits/credentialAtomicQueryV3/verification_key.json \
temp/credentialAtomicQueryV3_MTP_public.json \
temp/credentialAtomicQueryV3_MTP_proof.json

package/bin/credentialAtomicQueryV3OnChain \
testdata/credentialAtomicQueryV3OnChain_Sig_input.json \
temp/credentialAtomicQueryV3OnChain_Sig_witness.wtns
snarkjs groth16 prove \
circuits/credentialAtomicQueryV3OnChain/circuit_final.zkey \
temp/credentialAtomicQueryV3OnChain_Sig_witness.wtns \
temp/credentialAtomicQueryV3OnChain_Sig_proof.json \
temp/credentialAtomicQueryV3OnChain_Sig_public.json
snarkjs groth16 verify \
circuits/credentialAtomicQueryV3OnChain/verification_key.json \
temp/credentialAtomicQueryV3OnChain_Sig_public.json \
temp/credentialAtomicQueryV3OnChain_Sig_proof.json

package/bin/credentialAtomicQueryV3OnChain \
testdata/credentialAtomicQueryV3OnChain_MTP_input.json \
temp/credentialAtomicQueryV3OnChain_MTP_witness.wtns
snarkjs groth16 prove \
circuits/credentialAtomicQueryV3OnChain/circuit_final.zkey \
temp/credentialAtomicQueryV3OnChain_MTP_witness.wtns \
temp/credentialAtomicQueryV3OnChain_MTP_proof.json \
temp/credentialAtomicQueryV3OnChain_MTP_public.json
snarkjs groth16 verify \
circuits/credentialAtomicQueryV3OnChain/verification_key.json \
temp/credentialAtomicQueryV3OnChain_MTP_public.json \
temp/credentialAtomicQueryV3OnChain_MTP_proof.json
36 changes: 36 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,39 @@ target_link_libraries(credentialAtomicQuerySigV2OnChain witnesscalc_credentialAt
target_compile_definitions(witnesscalc_credentialAtomicQuerySigV2OnChain PUBLIC CIRCUIT_NAME=credentialAtomicQuerySigV2OnChain)
target_compile_definitions(witnesscalc_credentialAtomicQuerySigV2OnChainStatic PUBLIC CIRCUIT_NAME=credentialAtomicQuerySigV2OnChain)
target_compile_definitions(credentialAtomicQuerySigV2OnChain PUBLIC CIRCUIT_NAME=credentialAtomicQuerySigV2OnChain)

# credentialAtomicQueryV3
set(CREDENTIALATOMICQUERYV3OFFCHAIN_SOURCES ${LIB_SOURCES}
credentialAtomicQueryV3.cpp
witnesscalc_credentialAtomicQueryV3.h
witnesscalc_credentialAtomicQueryV3.cpp
)

add_library(witnesscalc_credentialAtomicQueryV3 SHARED ${CREDENTIALATOMICQUERYV3OFFCHAIN_SOURCES})
add_library(witnesscalc_credentialAtomicQueryV3Static STATIC ${CREDENTIALATOMICQUERYV3OFFCHAIN_SOURCES})
set_target_properties(witnesscalc_credentialAtomicQueryV3Static PROPERTIES OUTPUT_NAME witnesscalc_credentialAtomicQueryV3)

add_executable(credentialAtomicQueryV3 main.cpp)
target_link_libraries(credentialAtomicQueryV3 witnesscalc_credentialAtomicQueryV3Static)

target_compile_definitions(witnesscalc_credentialAtomicQueryV3 PUBLIC CIRCUIT_NAME=credentialAtomicQueryV3)
target_compile_definitions(witnesscalc_credentialAtomicQueryV3Static PUBLIC CIRCUIT_NAME=credentialAtomicQueryV3)
target_compile_definitions(credentialAtomicQueryV3 PUBLIC CIRCUIT_NAME=credentialAtomicQueryV3)

# credentialAtomicQueryV3OnChain
set(CREDENTIALATOMICQUERYV3ONCHAIN_SOURCES ${LIB_SOURCES}
credentialAtomicQueryV3OnChain.cpp
witnesscalc_credentialAtomicQueryV3OnChain.h
witnesscalc_credentialAtomicQueryV3OnChain.cpp
)

add_library(witnesscalc_credentialAtomicQueryV3OnChain SHARED ${CREDENTIALATOMICQUERYV3ONCHAIN_SOURCES})
add_library(witnesscalc_credentialAtomicQueryV3OnChainStatic STATIC ${CREDENTIALATOMICQUERYV3ONCHAIN_SOURCES})
set_target_properties(witnesscalc_credentialAtomicQueryV3OnChainStatic PROPERTIES OUTPUT_NAME witnesscalc_credentialAtomicQueryV3OnChain)

add_executable(credentialAtomicQueryV3OnChain main.cpp)
target_link_libraries(credentialAtomicQueryV3OnChain witnesscalc_credentialAtomicQueryV3OnChainStatic)

target_compile_definitions(witnesscalc_credentialAtomicQueryV3OnChain PUBLIC CIRCUIT_NAME=credentialAtomicQueryV3OnChain)
target_compile_definitions(witnesscalc_credentialAtomicQueryV3OnChainStatic PUBLIC CIRCUIT_NAME=credentialAtomicQueryV3OnChain)
target_compile_definitions(credentialAtomicQueryV3OnChain PUBLIC CIRCUIT_NAME=credentialAtomicQueryV3OnChain)
Loading

0 comments on commit 3c8a515

Please sign in to comment.