mirror of
https://github.com/selfxyz/self.git
synced 2026-04-27 03:01:15 -04:00
Merge pull request #99 from zk-passport/fix-build-scripts
Fix build scripts
This commit is contained in:
@@ -21,8 +21,6 @@ yarn
|
||||
|
||||
## Run the app
|
||||
|
||||
Let's run the app with the currently deployed zkey to mint the Proof of Passport SBT.
|
||||
|
||||
First, connect your phone to your computer and allow access.
|
||||
|
||||
### Android
|
||||
@@ -56,28 +54,24 @@ If you want to modify the circuits, you'll have to adapt a few things.
|
||||
|
||||
First, go to the `circuit` folder of the monorepo, modify the circuits and build them.
|
||||
|
||||
Then, upload the zkey and the arkzkey built at a publicly available url and replace the two urls in `common/src/constants/constants.ts`. Be sure they have the name you put as ZKEY_NAME before you zip them, because they will need to unzip to theses name.
|
||||
Then, upload the zipped zkeys built at publicly available urls and replace the urls in `app/src/utils/zkeyDownload.ts`. Be sure the zkey is named `<circuit_name>.zkey` before you zip it, and the zip is then named `<circuit_name>.zkey.zip`.
|
||||
|
||||
Adapt the inputs you pass in `app/src/utils/prover.ts` and if you want to mint SBTs, adapt and redeploy the contracts.
|
||||
Adapt the inputs you pass in `app/src/utils/prover.ts`, and adapt and redeploy the contracts.
|
||||
|
||||
Run the common init script:
|
||||
```
|
||||
./scripts/common.sh
|
||||
```
|
||||
|
||||
### Android
|
||||
|
||||
Find your android ndk path. It should be something like `/Users/<your-user-name>/Library/Android/sdk/ndk/23.1.7779620`
|
||||
Build the android native module:
|
||||
```
|
||||
export ANDROID_NDK="<your-android-ndk-path>"
|
||||
./scripts/build_android_module.sh
|
||||
```
|
||||
|
||||
You might need to set the rust-toolchain rust version as global default. Example:
|
||||
```
|
||||
rustup default 1.67.0
|
||||
```
|
||||
|
||||
For macOS users you might also need to set-up the path to sdk:
|
||||
in `/app/android` create `local.properties`
|
||||
|
||||
Add the following line:
|
||||
`sdk.dir=/Users/<user>/Library/Android/sdk` or any relevant path to your sdk
|
||||
|
||||
### iOS
|
||||
|
||||
Find your [development team id](https://chat.openai.com/share/9d52c37f-d9da-4a62-acb9-9e4ee8179f95) and run:
|
||||
|
||||
@@ -215,7 +215,10 @@ class ZKPUseCase(val context: Context) {
|
||||
|
||||
Log.e("ZKPUseCase", "Witness gen res: $res")
|
||||
Log.e("ZKPUseCase", "Witness gen return length: ${byteArr.size}")
|
||||
Log.e("ZKPUseCase", "witnessLen: $witnessLen")
|
||||
|
||||
if (res == 3) {
|
||||
throw Exception("Error 3")
|
||||
}
|
||||
|
||||
if (res == 2) {
|
||||
throw Exception("Not enough memory for zkp")
|
||||
@@ -235,6 +238,8 @@ class ZKPUseCase(val context: Context) {
|
||||
|
||||
val witnessData = byteArr.copyOfRange(0, witnessLen[0].toInt())
|
||||
|
||||
Log.e("ZKPUseCase", "zkey_path: $zkey_path")
|
||||
|
||||
val verification = zkpTool.groth16_prover_zkey_file(
|
||||
zkey_path,
|
||||
witnessData,
|
||||
@@ -247,6 +252,8 @@ class ZKPUseCase(val context: Context) {
|
||||
256
|
||||
)
|
||||
|
||||
Log.e("ZKPUseCase", "Verification res: $verification")
|
||||
|
||||
if (verification == 2) {
|
||||
throw Exception("Not enough memory for verification ${msg.decodeToString()}")
|
||||
}
|
||||
@@ -266,14 +273,19 @@ class ZKPUseCase(val context: Context) {
|
||||
"]"
|
||||
)
|
||||
|
||||
val formatedPubData = pubData.decodeToString().slice(0..indexPubData)
|
||||
val formattedPubData = pubData.decodeToString().slice(0..indexPubData)
|
||||
|
||||
val foramtedProof = proofDataZip.toString(Charsets.UTF_8).slice(0..index)
|
||||
val proof = Proof.fromJson(foramtedProof)
|
||||
val formattedProof = proofDataZip.toString(Charsets.UTF_8).slice(0..index)
|
||||
|
||||
Log.e("ZKPUseCase", "formattedProof: $formattedProof")
|
||||
|
||||
val proof = Proof.fromJson(formattedProof)
|
||||
|
||||
Log.e("ZKPUseCase", "Proof: $proof")
|
||||
|
||||
return ZkProof(
|
||||
proof = proof,
|
||||
pub_signals = getPubSignals(formatedPubData).toList()
|
||||
pub_signals = getPubSignals(formattedPubData).toList()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
@@ -1,31 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Make that not happen if build ios is already done
|
||||
|
||||
# cp ../circuits/build/proof_of_passport_cpp/proof_of_passport.cpp witnesscalc/src
|
||||
# cp ../circuits/build/proof_of_passport_cpp/proof_of_passport.dat witnesscalc/src
|
||||
|
||||
# cd witnesscalc/src
|
||||
# # This adds the namespace to the circuit file as described in the README
|
||||
# last_include=$(grep -n '#include' proof_of_passport.cpp | tail -1 | cut -d: -f1)
|
||||
# if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# # macOS requires an empty string with the -i flag and handles backslashes differently
|
||||
# sed -i "" "${last_include}a\\
|
||||
# namespace CIRCUIT_NAME {" proof_of_passport.cpp
|
||||
# else
|
||||
# # Linux
|
||||
# sed -i "${last_include}a \\nnamespace CIRCUIT_NAME {" proof_of_passport.cpp
|
||||
# fi
|
||||
# echo "}" >> proof_of_passport.cpp
|
||||
|
||||
# cd ../../..
|
||||
# git submodule init
|
||||
# git submodule update
|
||||
|
||||
# cd app/witnesscalc
|
||||
cd witnesscalc
|
||||
./build_gmp.sh android
|
||||
make android
|
||||
cd ..
|
||||
|
||||
cp ../circuits/build/proof_of_passport_cpp/proof_of_passport.dat android/app/src/main/res/raw/proof_of_passport.dat
|
||||
cp witnesscalc/build_witnesscalc_android/src/libwitnesscalc_proof_of_passport.so android/app/src/main/cpp/lib/
|
||||
@@ -1,39 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
cp ../circuits/build/proof_of_passport_cpp/proof_of_passport.cpp witnesscalc/src
|
||||
cp ../circuits/build/proof_of_passport_cpp/proof_of_passport.dat witnesscalc/src
|
||||
|
||||
cd witnesscalc/src
|
||||
# This adds the namespace to the circuit file as described in the README
|
||||
last_include=$(grep -n '#include' proof_of_passport.cpp | tail -1 | cut -d: -f1)
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# macOS requires an empty string with the -i flag and handles backslashes differently
|
||||
sed -i "" "${last_include}a\\
|
||||
namespace CIRCUIT_NAME {" proof_of_passport.cpp
|
||||
else
|
||||
# Linux
|
||||
sed -i "${last_include}a \\nnamespace CIRCUIT_NAME {" proof_of_passport.cpp
|
||||
fi
|
||||
echo "}" >> proof_of_passport.cpp
|
||||
|
||||
cd ../../..
|
||||
git submodule init
|
||||
git submodule update
|
||||
|
||||
cd app/witnesscalc
|
||||
cd witnesscalc
|
||||
./build_gmp.sh ios
|
||||
make ios
|
||||
|
||||
cd build_witnesscalc_ios
|
||||
|
||||
xcodebuild -project witnesscalc.xcodeproj \
|
||||
-scheme proof_of_passport \
|
||||
-sdk iphoneos \
|
||||
-configuration Release \
|
||||
DEVELOPMENT_TEAM="$DEVELOPMENT_TEAM" \
|
||||
ARCHS="arm64" \
|
||||
-destination 'generic/platform=iOS' \
|
||||
PRODUCT_BUNDLE_IDENTIFIER=com.warrom.witnesscalc \
|
||||
build
|
||||
-scheme proof_of_passport \
|
||||
-sdk iphoneos \
|
||||
-configuration Release \
|
||||
DEVELOPMENT_TEAM="$DEVELOPMENT_TEAM" \
|
||||
ARCHS="arm64" \
|
||||
-destination 'generic/platform=iOS' \
|
||||
PRODUCT_BUNDLE_IDENTIFIER=com.warrom.witnesscalc \
|
||||
build
|
||||
|
||||
cd ../..
|
||||
cp witnesscalc/build_witnesscalc_ios/src/Release-iphoneos/libwitnesscalc_proof_of_passport.a ios
|
||||
cp witnesscalc/src/proof_of_passport.dat ios/ProofOfPassport/Assets.xcassets/proof_of_passport.dat.dataset/proof_of_passport.dat
|
||||
cp witnesscalc/src/proof_of_passport.dat ios/ProofOfPassport/Assets.xcassets/proof_of_passport.dat.dataset/proof_of_passport.dat
|
||||
22
app/scripts/common.sh
Normal file
22
app/scripts/common.sh
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
cp ../circuits/build/proof_of_passport_cpp/proof_of_passport.cpp witnesscalc/src
|
||||
cp ../circuits/build/proof_of_passport_cpp/proof_of_passport.dat witnesscalc/src
|
||||
|
||||
cd witnesscalc/src
|
||||
|
||||
# This adds the namespace to the circuit file as described in the README
|
||||
last_include=$(grep -n '#include' proof_of_passport.cpp | tail -1 | cut -d: -f1)
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# macOS requires an empty string with the -i flag and handles backslashes differently
|
||||
sed -i "" "${last_include}a\\
|
||||
namespace CIRCUIT_NAME {" proof_of_passport.cpp
|
||||
else
|
||||
# Linux
|
||||
sed -i "${last_include}a \\nnamespace CIRCUIT_NAME {" proof_of_passport.cpp
|
||||
fi
|
||||
echo "}" >> proof_of_passport.cpp
|
||||
|
||||
cd ../..
|
||||
git submodule init
|
||||
git submodule update
|
||||
Reference in New Issue
Block a user