mirror of
https://github.com/selfxyz/self.git
synced 2026-01-10 23:27:56 -05:00
Integrate new two-step process and proving in mobile app
- still need to solve https call to merkle tree server - not tested on android
This commit is contained in:
4
app/.gitignore
vendored
4
app/.gitignore
vendored
@@ -66,6 +66,4 @@ yarn-error.log
|
||||
|
||||
.env
|
||||
|
||||
.expo/
|
||||
|
||||
ios/ProofOfPassport/Assets.xcassets/proof_of_passport.zkey.dataset/proof_of_passport.zkey
|
||||
.expo/
|
||||
@@ -11,11 +11,14 @@ add_library(rapidsnark SHARED IMPORTED)
|
||||
set_target_properties(rapidsnark PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/lib/librapidsnark.so)
|
||||
|
||||
|
||||
add_library(proof_of_passport SHARED IMPORTED)
|
||||
set_target_properties(proof_of_passport PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/lib/libwitnesscalc_proof_of_passport.so)
|
||||
add_library(register_sha256WithRSAEncryption_65537 SHARED IMPORTED)
|
||||
set_target_properties(register_sha256WithRSAEncryption_65537 PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/lib/libwitnesscalc_register_sha256WithRSAEncryption_65537.so)
|
||||
|
||||
add_library(disclose SHARED IMPORTED)
|
||||
set_target_properties(disclose PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/lib/libwitnesscalc_disclose.so)
|
||||
|
||||
add_library(${CMAKE_PROJECT_NAME} SHARED
|
||||
proofofpassport.cpp)
|
||||
|
||||
target_link_libraries(${CMAKE_PROJECT_NAME}
|
||||
rapidsnark proof_of_passport)
|
||||
rapidsnark register_sha256WithRSAEncryption_65537 disclose)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef WITNESSCALC_PROOFOFPASSPORT_H
|
||||
#define WITNESSCALC_PROOFOFPASSPORT_H
|
||||
#ifndef WITNESSCALC_disclose_H
|
||||
#define WITNESSCALC_disclose_H
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -25,7 +25,7 @@ extern "C" {
|
||||
*/
|
||||
|
||||
int
|
||||
witnesscalc_proof_of_passport(
|
||||
witnesscalc_disclose(
|
||||
const char *circuit_buffer, unsigned long circuit_size,
|
||||
const char *json_buffer, unsigned long json_size,
|
||||
char *wtns_buffer, unsigned long *wtns_size,
|
||||
@@ -36,4 +36,4 @@ witnesscalc_proof_of_passport(
|
||||
#endif
|
||||
|
||||
|
||||
#endif // WITNESSCALC_PROOFOFPASSPORT_H
|
||||
#endif // WITNESSCALC_disclose_H
|
||||
@@ -0,0 +1,39 @@
|
||||
#ifndef WITNESSCALC_register_sha256WithRSAEncryption_65537_H
|
||||
#define WITNESSCALC_register_sha256WithRSAEncryption_65537_H
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define WITNESSCALC_OK 0x0
|
||||
#define WITNESSCALC_ERROR 0x1
|
||||
#define WITNESSCALC_ERROR_SHORT_BUFFER 0x2
|
||||
|
||||
/**
|
||||
*
|
||||
* @return error code:
|
||||
* WITNESSCALC_OK - in case of success.
|
||||
* WITNESSCALC_ERROR - in case of an error.
|
||||
*
|
||||
* On success wtns_buffer is filled with witness data and
|
||||
* wtns_size contains the number bytes copied to wtns_buffer.
|
||||
*
|
||||
* If wtns_buffer is too small then the function returns WITNESSCALC_ERROR_SHORT_BUFFER
|
||||
* and the minimum size for wtns_buffer in wtns_size.
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
witnesscalc_register_sha256WithRSAEncryption_65537(
|
||||
const char *circuit_buffer, unsigned long circuit_size,
|
||||
const char *json_buffer, unsigned long json_size,
|
||||
char *wtns_buffer, unsigned long *wtns_size,
|
||||
char *error_msg, unsigned long error_msg_maxsize);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // WITNESSCALC_register_sha256WithRSAEncryption_65537_H
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,6 @@
|
||||
#include "include/prover.h"
|
||||
#include "include/witnesscalc_proof_of_passport.h"
|
||||
#include "include/witnesscalc_register_sha256WithRSAEncryption_65537.h"
|
||||
#include "include/witnesscalc_disclose.h"
|
||||
|
||||
#include <jni.h>
|
||||
#include <iostream>
|
||||
@@ -48,7 +49,7 @@ Java_com_proofofpassport_prover_ZKPTools_groth16_1prover(JNIEnv *env, jobject th
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_proofofpassport_prover_ZKPTools_witnesscalc_1proof_1of_1passport(JNIEnv *env, jobject thiz,
|
||||
Java_com_proofofpassport_prover_ZKPTools_witnesscalc_1register_1sha256WithRSAEncryption_165537(JNIEnv *env, jobject thiz,
|
||||
jbyteArray circuit_buffer,
|
||||
jlong circuit_size, jbyteArray json_buffer,
|
||||
jlong json_size, jbyteArray wtns_buffer,
|
||||
@@ -64,7 +65,44 @@ Java_com_proofofpassport_prover_ZKPTools_witnesscalc_1proof_1of_1passport(JNIEnv
|
||||
unsigned long wtnsSize = env->GetLongArrayElements(wtns_size, nullptr)[0];
|
||||
|
||||
|
||||
int result = witnesscalc_proof_of_passport(
|
||||
int result = witnesscalc_register_sha256WithRSAEncryption_65537(
|
||||
circuitBuffer, static_cast<unsigned long>(circuit_size),
|
||||
jsonBuffer, static_cast<unsigned long>(json_size),
|
||||
wtnsBuffer, &wtnsSize,
|
||||
errorMsg, static_cast<unsigned long>(error_msg_max_size));
|
||||
|
||||
// Set the result and release the resources
|
||||
env->SetLongArrayRegion(wtns_size, 0, 1, reinterpret_cast<jlong *>(&wtnsSize));
|
||||
|
||||
env->ReleaseByteArrayElements(circuit_buffer,
|
||||
reinterpret_cast<jbyte *>(const_cast<char *>(circuitBuffer)), 0);
|
||||
env->ReleaseByteArrayElements(json_buffer,
|
||||
reinterpret_cast<jbyte *>(const_cast<char *>(jsonBuffer)), 0);
|
||||
env->ReleaseByteArrayElements(wtns_buffer, reinterpret_cast<jbyte *>(wtnsBuffer), 0);
|
||||
env->ReleaseByteArrayElements(error_msg, reinterpret_cast<jbyte *>(errorMsg), 0);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_proofofpassport_prover_ZKPTools_witnesscalc_1disclose(JNIEnv *env, jobject thiz,
|
||||
jbyteArray circuit_buffer,
|
||||
jlong circuit_size, jbyteArray json_buffer,
|
||||
jlong json_size, jbyteArray wtns_buffer,
|
||||
jlongArray wtns_size, jbyteArray error_msg,
|
||||
jlong error_msg_max_size) {
|
||||
const char *circuitBuffer = reinterpret_cast<const char *>(env->GetByteArrayElements(
|
||||
circuit_buffer, nullptr));
|
||||
const char *jsonBuffer = reinterpret_cast<const char *>(env->GetByteArrayElements(json_buffer,
|
||||
nullptr));
|
||||
char *wtnsBuffer = reinterpret_cast<char *>(env->GetByteArrayElements(wtns_buffer, nullptr));
|
||||
char *errorMsg = reinterpret_cast<char *>(env->GetByteArrayElements(error_msg, nullptr));
|
||||
|
||||
unsigned long wtnsSize = env->GetLongArrayElements(wtns_size, nullptr)[0];
|
||||
|
||||
|
||||
int result = witnesscalc_disclose(
|
||||
circuitBuffer, static_cast<unsigned long>(circuit_size),
|
||||
jsonBuffer, static_cast<unsigned long>(json_size),
|
||||
wtnsBuffer, &wtnsSize,
|
||||
|
||||
@@ -75,8 +75,8 @@ class ProverModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
|
||||
val zkpTools = ZKPTools(reactApplicationContext)
|
||||
|
||||
val witnessCalcFunction = when (witness_calculator) {
|
||||
"proof_of_passport" -> zkpTools::witnesscalc_proof_of_passport
|
||||
// "another_calculator" -> zkpTools::witnesscalc_another_calculator
|
||||
"register_sha256WithRSAEncryption_65537" -> zkpTools::witnesscalc_register_sha256WithRSAEncryption_65537
|
||||
"disclose" -> zkpTools::witnesscalc_disclose
|
||||
else -> throw IllegalArgumentException("Invalid witness calculator name")
|
||||
}
|
||||
|
||||
@@ -127,7 +127,15 @@ data class ZkProof(
|
||||
)
|
||||
|
||||
class ZKPTools(val context: Context) {
|
||||
external fun witnesscalc_proof_of_passport(circuitBuffer: ByteArray,
|
||||
external fun witnesscalc_register_sha256WithRSAEncryption_65537(circuitBuffer: ByteArray,
|
||||
circuitSize: Long,
|
||||
jsonBuffer: ByteArray,
|
||||
jsonSize: Long,
|
||||
wtnsBuffer: ByteArray,
|
||||
wtnsSize: LongArray,
|
||||
errorMsg: ByteArray,
|
||||
errorMsgMaxSize: Long): Int
|
||||
external fun witnesscalc_disclose(circuitBuffer: ByteArray,
|
||||
circuitSize: Long,
|
||||
jsonBuffer: ByteArray,
|
||||
jsonSize: Long,
|
||||
|
||||
BIN
app/android/app/src/main/res/raw/disclose.dat
Normal file
BIN
app/android/app/src/main/res/raw/disclose.dat
Normal file
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"ProofOfPassport": "0x6277C3963B71685746588a927Ad6df0ebb21faDe",
|
||||
"Groth16Verifier": "0xEd7495516a957dD7d378d8A78846646461cFF25f"
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../build-info/d8fbe1f09e244f2ed82c9ecd6cc17dfb.json"
|
||||
}
|
||||
205
app/deployments/artifacts/Deploy_Registry#Formatter.json
Normal file
205
app/deployments/artifacts/Deploy_Registry#Formatter.json
Normal file
File diff suppressed because one or more lines are too long
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../build-info/d8fbe1f09e244f2ed82c9ecd6cc17dfb.json"
|
||||
}
|
||||
30
app/deployments/artifacts/Deploy_Registry#PoseidonT3.json
Normal file
30
app/deployments/artifacts/Deploy_Registry#PoseidonT3.json
Normal file
File diff suppressed because one or more lines are too long
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../build-info/9f49f04627522c81f1132ca8d0152949.json"
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../build-info/d8fbe1f09e244f2ed82c9ecd6cc17dfb.json"
|
||||
}
|
||||
119
app/deployments/artifacts/Deploy_Registry#Registry.json
Normal file
119
app/deployments/artifacts/Deploy_Registry#Registry.json
Normal file
@@ -0,0 +1,119 @@
|
||||
{
|
||||
"_format": "hh-sol-artifact-1",
|
||||
"contractName": "Registry",
|
||||
"sourceName": "contracts/Registry.sol",
|
||||
"abi": [
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "bytes32",
|
||||
"name": "_merkleRoot",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "constructor"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "previousOwner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "newOwner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "OwnershipTransferred",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "bytes32",
|
||||
"name": "_merkleRoot",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "checkRoot",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "bool",
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "merkleRoot",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "bytes32",
|
||||
"name": "",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "owner",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "renounceOwnership",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "newOwner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "transferOwnership",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "bytes32",
|
||||
"name": "_merkleRoot",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "update",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
}
|
||||
],
|
||||
"bytecode": "0x608060405234801561001057600080fd5b5060405161043038038061043083398101604081905261002f91610176565b6100383361004c565b60018190556100463361009c565b5061018f565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6100a461011a565b6001600160a01b03811661010e5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b6101178161004c565b50565b6000546001600160a01b031633146101745760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610105565b565b60006020828403121561018857600080fd5b5051919050565b6102928061019e6000396000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c806306c8442b146100675780632eb4a7ab14610091578063715018a6146100a85780638b147245146100b25780638da5cb5b146100c5578063f2fde38b146100e0575b600080fd5b61007c61007536600461023c565b6001541490565b60405190151581526020015b60405180910390f35b61009a60015481565b604051908152602001610088565b6100b06100f3565b005b6100b06100c036600461023c565b610107565b6000546040516001600160a01b039091168152602001610088565b6100b06100ee366004610255565b610114565b6100fb610192565b61010560006101ec565b565b61010f610192565b600155565b61011c610192565b6001600160a01b0381166101865760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b61018f816101ec565b50565b6000546001600160a01b031633146101055760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161017d565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006020828403121561024e57600080fd5b5035919050565b60006020828403121561026757600080fd5b81356001600160a01b038116811461027e57600080fd5b939250505056fea164736f6c6343000812000a",
|
||||
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100625760003560e01c806306c8442b146100675780632eb4a7ab14610091578063715018a6146100a85780638b147245146100b25780638da5cb5b146100c5578063f2fde38b146100e0575b600080fd5b61007c61007536600461023c565b6001541490565b60405190151581526020015b60405180910390f35b61009a60015481565b604051908152602001610088565b6100b06100f3565b005b6100b06100c036600461023c565b610107565b6000546040516001600160a01b039091168152602001610088565b6100b06100ee366004610255565b610114565b6100fb610192565b61010560006101ec565b565b61010f610192565b600155565b61011c610192565b6001600160a01b0381166101865760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b61018f816101ec565b50565b6000546001600160a01b031633146101055760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161017d565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006020828403121561024e57600080fd5b5035919050565b60006020828403121561026757600080fd5b81356001600160a01b038116811461027e57600080fd5b939250505056fea164736f6c6343000812000a",
|
||||
"linkReferences": {},
|
||||
"deployedLinkReferences": {}
|
||||
}
|
||||
4
app/deployments/artifacts/Deploy_Registry#SBT.dbg.json
Normal file
4
app/deployments/artifacts/Deploy_Registry#SBT.dbg.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../build-info/39503cf5684494f7fa04fc6ec69486cb.json"
|
||||
}
|
||||
908
app/deployments/artifacts/Deploy_Registry#SBT.json
Normal file
908
app/deployments/artifacts/Deploy_Registry#SBT.json
Normal file
File diff suppressed because one or more lines are too long
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../build-info/d8fbe1f09e244f2ed82c9ecd6cc17dfb.json"
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../build-info/e930a132cd15a40163915f8e7206c704.json"
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"_format": "hh-sol-artifact-1",
|
||||
"contractName": "Verifier_register_sha256WithRSAEncryption_65537",
|
||||
"sourceName": "contracts/Verifier_register.sol",
|
||||
"abi": [
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "uint256[2]",
|
||||
"name": "_pA",
|
||||
"type": "uint256[2]"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256[2][2]",
|
||||
"name": "_pB",
|
||||
"type": "uint256[2][2]"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256[2]",
|
||||
"name": "_pC",
|
||||
"type": "uint256[2]"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256[4]",
|
||||
"name": "_pubSignals",
|
||||
"type": "uint256[4]"
|
||||
}
|
||||
],
|
||||
"name": "verifyProof",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "bool",
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
}
|
||||
],
|
||||
"bytecode": "0x608060405234801561001057600080fd5b5061065e806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80635fe8c13b14610030575b600080fd5b61004361003e3660046105f7565b610057565b604051901515815260200160405180910390f35b600061056a565b7f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47811061008f576000805260206000f35b50565b600060405183815284602082015285604082015260408160608360076107d05a03fa9150816100c5576000805260206000f35b825160408201526020830151606082015260408360808360066107d05a03fa915050806100f6576000805260206000f35b5050505050565b7f0741c4a6333181bd706a8a033d5a85404e25496f1ac7de88d72485d183f254ab85527f28f0bd0e3df4a61721906ddcf3fab2bfec2653aa4b9445c0ce03469a3602e46860208601526000608086018661019a87357f180596a0a0ff036523011190f8339463af20c8e05ed417311f714951543d54857f0bb02eb704601e28b76faac986aee01262de5bff9aa2aedca60d955e0f20b6a284610092565b6101ea60208801357f0861c242170001b2853807f7704612fc50f6f11127d5475adea1ea077c65d6ef7f26669ae9d2d8ce61a428147ad8f4aa5ff7dfaaa572a6ad0d48c64c48e3851b0584610092565b61023a60408801357f0eba24afeb50182fce361a4c3fbaa0b2bad603408bab52789506653a06ce5a1d7f23b1f8ab87589d236f87b409171b9ed7f73352a2932570924960b2803521a6ca84610092565b61028a60608801357f2ff616ded463054c291848ced17ac3673aec5ebf4ec9fbc312eefb388440affe7f1b53979275b5f9012990d64397d1062d3efc33aec76fcc3f9aeeadfa603e63d984610092565b50823581527f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd4760208401357f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd4703066020820152833560408201526020840135606082015260408401356080820152606084013560a08201527f2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e260c08201527f14bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d192660e08201527f0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c6101008201527f0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab6101208201527f304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a76101408201527f1739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8610160820152600087015161018082015260206000018701516101a08201527f198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c26101c08201527f1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed6101e08201527f090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b6102008201527f12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa610220820152843561024082015260208501356102608201527f130f9f7b4fa1c46d75e8ba089a19ff81ab6b793103f4573a95e27adc1c82c19f6102808201527f21640e27d7f4fed1cb30f67042e95e947181fc71298316d68ff78ff3bbf9cb286102a08201527f0eb10762f2b520903bbf4f29df1a67a7a2b277111b2488f682720ca6ca5e948e6102c08201527f17cc34a8b69fc78f2eae10ff468fa92220c9a2f72f20dc5281a8a9ee49e2154d6102e08201526020816103008360086107d05a03fa9051169695505050505050565b6040516103808101604052610582600084013561005e565b61058f602084013561005e565b61059c604084013561005e565b6105a9606084013561005e565b6105b6608084013561005e565b6105c3818486888a6100fd565b90508060005260206000f35b80604081018310156105e057600080fd5b92915050565b80608081018310156105e057600080fd5b600080600080610180858703121561060e57600080fd5b61061886866105cf565b935061062786604087016105e6565b92506106368660c087016105cf565b91506106468661010087016105e6565b90509295919450925056fea164736f6c6343000812000a",
|
||||
"deployedBytecode": "0x608060405234801561001057600080fd5b506004361061002b5760003560e01c80635fe8c13b14610030575b600080fd5b61004361003e3660046105f7565b610057565b604051901515815260200160405180910390f35b600061056a565b7f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47811061008f576000805260206000f35b50565b600060405183815284602082015285604082015260408160608360076107d05a03fa9150816100c5576000805260206000f35b825160408201526020830151606082015260408360808360066107d05a03fa915050806100f6576000805260206000f35b5050505050565b7f0741c4a6333181bd706a8a033d5a85404e25496f1ac7de88d72485d183f254ab85527f28f0bd0e3df4a61721906ddcf3fab2bfec2653aa4b9445c0ce03469a3602e46860208601526000608086018661019a87357f180596a0a0ff036523011190f8339463af20c8e05ed417311f714951543d54857f0bb02eb704601e28b76faac986aee01262de5bff9aa2aedca60d955e0f20b6a284610092565b6101ea60208801357f0861c242170001b2853807f7704612fc50f6f11127d5475adea1ea077c65d6ef7f26669ae9d2d8ce61a428147ad8f4aa5ff7dfaaa572a6ad0d48c64c48e3851b0584610092565b61023a60408801357f0eba24afeb50182fce361a4c3fbaa0b2bad603408bab52789506653a06ce5a1d7f23b1f8ab87589d236f87b409171b9ed7f73352a2932570924960b2803521a6ca84610092565b61028a60608801357f2ff616ded463054c291848ced17ac3673aec5ebf4ec9fbc312eefb388440affe7f1b53979275b5f9012990d64397d1062d3efc33aec76fcc3f9aeeadfa603e63d984610092565b50823581527f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd4760208401357f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd4703066020820152833560408201526020840135606082015260408401356080820152606084013560a08201527f2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e260c08201527f14bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d192660e08201527f0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c6101008201527f0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab6101208201527f304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a76101408201527f1739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8610160820152600087015161018082015260206000018701516101a08201527f198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c26101c08201527f1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed6101e08201527f090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b6102008201527f12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa610220820152843561024082015260208501356102608201527f130f9f7b4fa1c46d75e8ba089a19ff81ab6b793103f4573a95e27adc1c82c19f6102808201527f21640e27d7f4fed1cb30f67042e95e947181fc71298316d68ff78ff3bbf9cb286102a08201527f0eb10762f2b520903bbf4f29df1a67a7a2b277111b2488f682720ca6ca5e948e6102c08201527f17cc34a8b69fc78f2eae10ff468fa92220c9a2f72f20dc5281a8a9ee49e2154d6102e08201526020816103008360086107d05a03fa9051169695505050505050565b6040516103808101604052610582600084013561005e565b61058f602084013561005e565b61059c604084013561005e565b6105a9606084013561005e565b6105b6608084013561005e565b6105c3818486888a6100fd565b90508060005260206000f35b80604081018310156105e057600080fd5b92915050565b80608081018310156105e057600080fd5b600080600080610180858703121561060e57600080fd5b61061886866105cf565b935061062786604087016105e6565b92506106368660c087016105cf565b91506106468661010087016105e6565b90509295919450925056fea164736f6c6343000812000a",
|
||||
"linkReferences": {},
|
||||
"deployedLinkReferences": {}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"Formatter": "0xDf8070E1315FcD6b69DAcDD914CB299C6179FB56",
|
||||
"PoseidonT3": "0x014fe2398ef00F6D75A73A9799070d8C88ffb680",
|
||||
"Registry": "0x0413943095001c11Cb7A27D407C1b10547E03e8F",
|
||||
"Verifier_disclose": "0xA9fC53214d22A6fa2b5bF0Fc9f34B1a91ef7C027",
|
||||
"Verifier_register_sha256WithRSAEncryption_65537": "0x73c484F0Af94C8C73fb358457f835b056219AF05",
|
||||
"ProofOfPassportRegister": "0x6277C3963B71685746588a927Ad6df0ebb21faDe",
|
||||
"SBT": "0xAadB5C885e153f37D2d4AB94387F727515551FC7"
|
||||
}
|
||||
"Deploy_Registry#Formatter": "0x6BE397955e562172dCBCab6B3a2DBBb12eaB0CB9",
|
||||
"Deploy_Registry#PoseidonT3": "0xFA915138883C434067DdA1198F9202D4d07C0b28",
|
||||
"Deploy_Registry#Registry": "0x3F34D2a3c320Fa531339FB17844ad7BBDFDbF306",
|
||||
"Deploy_Registry#Verifier_disclose": "0xe27ebf1DF8080A03d4AeB187FaE96404b2769cd2",
|
||||
"Deploy_Registry#Verifier_register_sha256WithRSAEncryption_65537": "0x35c9B5cb9AE9Dea1Fe8dC62854EB84d3e1c6F55b",
|
||||
"Deploy_Registry#ProofOfPassportRegister": "0xc376571556Ee5103255dc29F23dBf16830Ba1031",
|
||||
"Deploy_Registry#SBT": "0xD95986A045D362cc050ED91AAcBa01270eA53b9B"
|
||||
}
|
||||
|
||||
@@ -400,6 +400,8 @@ PODS:
|
||||
- React-jsi (= 0.72.3)
|
||||
- React-logger (= 0.72.3)
|
||||
- React-perflogger (= 0.72.3)
|
||||
- RNCAsyncStorage (1.23.1):
|
||||
- React-Core
|
||||
- RNCClipboard (1.5.1):
|
||||
- React-Core
|
||||
- RNFS (2.20.0):
|
||||
@@ -464,6 +466,7 @@ DEPENDENCIES:
|
||||
- React-runtimescheduler (from `../node_modules/react-native/ReactCommon/react/renderer/runtimescheduler`)
|
||||
- React-utils (from `../node_modules/react-native/ReactCommon/react/utils`)
|
||||
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
|
||||
- "RNCAsyncStorage (from `../node_modules/@react-native-async-storage/async-storage`)"
|
||||
- "RNCClipboard (from `../node_modules/@react-native-community/clipboard`)"
|
||||
- RNFS (from `../node_modules/react-native-fs`)
|
||||
- RNKeychain (from `../node_modules/react-native-keychain`)
|
||||
@@ -565,6 +568,8 @@ EXTERNAL SOURCES:
|
||||
:path: "../node_modules/react-native/ReactCommon/react/utils"
|
||||
ReactCommon:
|
||||
:path: "../node_modules/react-native/ReactCommon"
|
||||
RNCAsyncStorage:
|
||||
:path: "../node_modules/@react-native-async-storage/async-storage"
|
||||
RNCClipboard:
|
||||
:path: "../node_modules/@react-native-community/clipboard"
|
||||
RNFS:
|
||||
@@ -604,7 +609,7 @@ SPEC CHECKSUMS:
|
||||
React-Core: 8293312ad137ea82fd2c29deb163dbc24aa4e00e
|
||||
React-CoreModules: 32fab1d62416849a3b6dac6feff9d54e5ddc2d1e
|
||||
React-cxxreact: 55d0f7cb6b4cc09ba9190797f1da87182d1a2fb6
|
||||
React-debug: 878f0c4026b30a6240f7a15f8612efcf5d8c3df9
|
||||
React-debug: 7e61555c8158126c6cd98c3154381ad3821aaaca
|
||||
React-jsc: 0db8e8cc2074d979c37ffa7b8d7c914833960497
|
||||
React-jsi: 58677ff4848ceb6aeb9118fe03448a843ea5e16a
|
||||
React-jsiexecutor: 2c15ba1bace70177492368d5180b564f165870fd
|
||||
@@ -629,6 +634,7 @@ SPEC CHECKSUMS:
|
||||
React-runtimescheduler: ec1066a4f2d1152eb1bc3fb61d69376b3bc0dde0
|
||||
React-utils: d55ba834beb39f01b0b470ae43478c0a3a024abe
|
||||
ReactCommon: 68e3a815fbb69af3bb4196e04c6ae7abb306e7a8
|
||||
RNCAsyncStorage: 826b603ae9c0f88b5ac4e956801f755109fa4d5c
|
||||
RNCClipboard: 41d8d918092ae8e676f18adada19104fa3e68495
|
||||
RNFS: 4ac0f0ea233904cb798630b3c077808c06931688
|
||||
RNKeychain: bfe3d12bf4620fe488771c414530bf16e88f3678
|
||||
@@ -641,4 +647,4 @@ SPEC CHECKSUMS:
|
||||
|
||||
PODFILE CHECKSUM: 2e0fb25883367cd333873ac29cbb9f28ba88c30f
|
||||
|
||||
COCOAPODS: 1.15.2
|
||||
COCOAPODS: 1.14.3
|
||||
|
||||
@@ -2,5 +2,6 @@
|
||||
// Use this file to import your target's public headers that you would like to expose to Swift.
|
||||
//
|
||||
|
||||
#include "witnesscalc_proof_of_passport.h"
|
||||
#include "witnesscalc_register_sha256WithRSAEncryption_65537.h"
|
||||
#include "witnesscalc_disclose.h"
|
||||
#include "groth16_prover.h"
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
/* Begin PBXBuildFile section */
|
||||
0569F35B2BBC9015006670BD /* librapidsnark.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0569F35A2BBC900D006670BD /* librapidsnark.a */; };
|
||||
0569F35F2BBC98D5006670BD /* libfq.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0569F35E2BBC98C9006670BD /* libfq.a */; };
|
||||
0569F3612BBCE4EF006670BD /* libwitnesscalc_proof_of_passport.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0569F3602BBCE4EB006670BD /* libwitnesscalc_proof_of_passport.a */; };
|
||||
058516D42BF49B98006A14DA /* libwitnesscalc_disclose.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 058516D32BF49B91006A14DA /* libwitnesscalc_disclose.a */; };
|
||||
058516D52BF49B98006A14DA /* libwitnesscalc_register_sha256WithRSAEncryption_65537.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 058516D22BF49B91006A14DA /* libwitnesscalc_register_sha256WithRSAEncryption_65537.a */; };
|
||||
05D985F52BB331AB00F58EEA /* libgmp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 05D985F22BB331AB00F58EEA /* libgmp.a */; };
|
||||
05D985F62BB331AB00F58EEA /* libfr.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 05D985F32BB331AB00F58EEA /* libfr.a */; };
|
||||
05D985FB2BB3344600F58EEA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 05D985FA2BB3344600F58EEA /* Assets.xcassets */; };
|
||||
@@ -69,9 +70,8 @@
|
||||
00E356EE1AD99517003FC87E /* ProofOfPassportTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ProofOfPassportTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
0569F35A2BBC900D006670BD /* librapidsnark.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = librapidsnark.a; sourceTree = "<group>"; };
|
||||
0569F35E2BBC98C9006670BD /* libfq.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libfq.a; sourceTree = "<group>"; };
|
||||
0569F3602BBCE4EB006670BD /* libwitnesscalc_proof_of_passport.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libwitnesscalc_proof_of_passport.a; sourceTree = "<group>"; };
|
||||
0569F3622BBCE52D006670BD /* proof_of_passport.zkey */ = {isa = PBXFileReference; lastKnownFileType = file; name = proof_of_passport.zkey; path = ProofOfPassport/Assets.xcassets/proof_of_passport.zkey.dataset/proof_of_passport.zkey; sourceTree = "<group>"; };
|
||||
0569F3642BBCE53D006670BD /* proof_of_passport.dat */ = {isa = PBXFileReference; lastKnownFileType = file; name = proof_of_passport.dat; path = ProofOfPassport/Assets.xcassets/proof_of_passport.dat.dataset/proof_of_passport.dat; sourceTree = "<group>"; };
|
||||
058516D22BF49B91006A14DA /* libwitnesscalc_register_sha256WithRSAEncryption_65537.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libwitnesscalc_register_sha256WithRSAEncryption_65537.a; sourceTree = "<group>"; };
|
||||
058516D32BF49B91006A14DA /* libwitnesscalc_disclose.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libwitnesscalc_disclose.a; sourceTree = "<group>"; };
|
||||
05D985F22BB331AB00F58EEA /* libgmp.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libgmp.a; sourceTree = "<group>"; };
|
||||
05D985F32BB331AB00F58EEA /* libfr.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libfr.a; sourceTree = "<group>"; };
|
||||
05D985FA2BB3344600F58EEA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = ProofOfPassport/Assets.xcassets; sourceTree = "<group>"; };
|
||||
@@ -140,11 +140,12 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
058516D52BF49B98006A14DA /* libwitnesscalc_register_sha256WithRSAEncryption_65537.a in Frameworks */,
|
||||
0651723A94C70A2B31E3E4F8 /* Pods_ProofOfPassport.framework in Frameworks */,
|
||||
0569F3612BBCE4EF006670BD /* libwitnesscalc_proof_of_passport.a in Frameworks */,
|
||||
05D985F52BB331AB00F58EEA /* libgmp.a in Frameworks */,
|
||||
0569F35F2BBC98D5006670BD /* libfq.a in Frameworks */,
|
||||
0569F35B2BBC9015006670BD /* librapidsnark.a in Frameworks */,
|
||||
058516D42BF49B98006A14DA /* libwitnesscalc_disclose.a in Frameworks */,
|
||||
05D985F62BB331AB00F58EEA /* libfr.a in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -182,7 +183,8 @@
|
||||
2D16E6871FA4F8E400B85C8A /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0569F3602BBCE4EB006670BD /* libwitnesscalc_proof_of_passport.a */,
|
||||
058516D32BF49B91006A14DA /* libwitnesscalc_disclose.a */,
|
||||
058516D22BF49B91006A14DA /* libwitnesscalc_register_sha256WithRSAEncryption_65537.a */,
|
||||
0569F35E2BBC98C9006670BD /* libfq.a */,
|
||||
0569F35A2BBC900D006670BD /* librapidsnark.a */,
|
||||
ED297162215061F000B7C4FE /* JavaScriptCore.framework */,
|
||||
@@ -234,8 +236,6 @@
|
||||
83CBB9F61A601CBA00E9B192 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0569F3642BBCE53D006670BD /* proof_of_passport.dat */,
|
||||
0569F3622BBCE52D006670BD /* proof_of_passport.zkey */,
|
||||
13B07FAE1A68108700A75B9A /* ProofOfPassport */,
|
||||
832341AE1AAA6A7D00B99B32 /* Libraries */,
|
||||
83CBBA001A601CBA00E9B192 /* Products */,
|
||||
@@ -726,7 +726,7 @@
|
||||
"-ObjC",
|
||||
"-lc++",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "com.warroom.proofofpassport-turnoff";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.warroom.proofofpassport;
|
||||
PRODUCT_NAME = ProofOfPassport;
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "$(PROJECT_DIR)/ProofOfPassport-Bridging-Header.h";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"data" : [
|
||||
{
|
||||
"filename" : "proof_of_passport.dat",
|
||||
"filename" : "disclose.dat",
|
||||
"idiom" : "universal",
|
||||
"universal-type-identifier" : "dyn.ah62d4rv4ge80k2py"
|
||||
}
|
||||
Binary file not shown.
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"data" : [
|
||||
{
|
||||
"filename" : "proof_of_passport.zkey",
|
||||
"idiom" : "universal",
|
||||
"universal-type-identifier" : "dyn.ah62d4rv4ge81y45fte"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"data" : [
|
||||
{
|
||||
"filename" : "register_sha256WithRSAEncryption_65537.dat",
|
||||
"idiom" : "universal",
|
||||
"universal-type-identifier" : "dyn.ah62d4rv4ge80k2py"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -9,8 +9,12 @@ import Foundation
|
||||
import React
|
||||
import Security
|
||||
|
||||
#if canImport(witnesscalc_proof_of_passport)
|
||||
import witnesscalc_proof_of_passport
|
||||
#if canImport(witnesscalc_register_sha256WithRSAEncryption_65537)
|
||||
import witnesscalc_register_sha256WithRSAEncryption_65537
|
||||
#endif
|
||||
|
||||
#if canImport(witnesscalc_disclose)
|
||||
import witnesscalc_disclose
|
||||
#endif
|
||||
|
||||
#if canImport(groth16_prover)
|
||||
@@ -91,8 +95,15 @@ private func _calcWtns(witness_calculator: String, dat: Data, jsonData: Data) th
|
||||
|
||||
let result: Int32
|
||||
|
||||
if witness_calculator == "proof_of_passport" {
|
||||
result = witnesscalc_proof_of_passport(
|
||||
if witness_calculator == "register_sha256WithRSAEncryption_65537" {
|
||||
result = witnesscalc_register_sha256WithRSAEncryption_65537(
|
||||
(dat as NSData).bytes, datSize,
|
||||
(jsonData as NSData).bytes, jsonDataSize,
|
||||
wtnsBuffer, wtnsSize,
|
||||
errorBuffer, errorSize
|
||||
)
|
||||
} else if witness_calculator == "disclose" {
|
||||
result = witnesscalc_disclose(
|
||||
(dat as NSData).bytes, datSize,
|
||||
(jsonData as NSData).bytes, jsonDataSize,
|
||||
wtnsBuffer, wtnsSize,
|
||||
|
||||
BIN
app/ios/libwitnesscalc_disclose.a
Normal file
BIN
app/ios/libwitnesscalc_disclose.a
Normal file
Binary file not shown.
Binary file not shown.
BIN
app/ios/libwitnesscalc_register_sha256WithRSAEncryption_65537.a
Normal file
BIN
app/ios/libwitnesscalc_register_sha256WithRSAEncryption_65537.a
Normal file
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
#ifndef WITNESSCALC_PROOFOFPASSPORT_H
|
||||
#define WITNESSCALC_PROOFOFPASSPORT_H
|
||||
#ifndef WITNESSCALC_disclose_H
|
||||
#define WITNESSCALC_disclose_H
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -25,7 +25,7 @@ extern "C" {
|
||||
*/
|
||||
|
||||
int
|
||||
witnesscalc_proof_of_passport(
|
||||
witnesscalc_disclose(
|
||||
const char *circuit_buffer, unsigned long circuit_size,
|
||||
const char *json_buffer, unsigned long json_size,
|
||||
char *wtns_buffer, unsigned long *wtns_size,
|
||||
@@ -36,4 +36,4 @@ witnesscalc_proof_of_passport(
|
||||
#endif
|
||||
|
||||
|
||||
#endif // WITNESSCALC_PROOFOFPASSPORT_H
|
||||
#endif // WITNESSCALC_disclose_H
|
||||
39
app/ios/witnesscalc_register_sha256WithRSAEncryption_65537.h
Normal file
39
app/ios/witnesscalc_register_sha256WithRSAEncryption_65537.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifndef WITNESSCALC_register_sha256WithRSAEncryption_65537_H
|
||||
#define WITNESSCALC_register_sha256WithRSAEncryption_65537_H
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define WITNESSCALC_OK 0x0
|
||||
#define WITNESSCALC_ERROR 0x1
|
||||
#define WITNESSCALC_ERROR_SHORT_BUFFER 0x2
|
||||
|
||||
/**
|
||||
*
|
||||
* @return error code:
|
||||
* WITNESSCALC_OK - in case of success.
|
||||
* WITNESSCALC_ERROR - in case of an error.
|
||||
*
|
||||
* On success wtns_buffer is filled with witness data and
|
||||
* wtns_size contains the number bytes copied to wtns_buffer.
|
||||
*
|
||||
* If wtns_buffer is too small then the function returns WITNESSCALC_ERROR_SHORT_BUFFER
|
||||
* and the minimum size for wtns_buffer in wtns_size.
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
witnesscalc_register_sha256WithRSAEncryption_65537(
|
||||
const char *circuit_buffer, unsigned long circuit_size,
|
||||
const char *json_buffer, unsigned long json_size,
|
||||
char *wtns_buffer, unsigned long *wtns_size,
|
||||
char *error_msg, unsigned long error_msg_maxsize);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // WITNESSCALC_register_sha256WithRSAEncryption_65537_H
|
||||
@@ -13,6 +13,7 @@
|
||||
"@amplitude/analytics-react-native": "^1.4.7",
|
||||
"@babel/plugin-transform-private-methods": "^7.23.3",
|
||||
"@ethersproject/shims": "^5.7.0",
|
||||
"@react-native-async-storage/async-storage": "^1.23.1",
|
||||
"@react-native-community/clipboard": "^1.5.1",
|
||||
"@react-native-community/netinfo": "^11.3.1",
|
||||
"@tamagui/colors": "^1.94.3",
|
||||
|
||||
@@ -5,5 +5,10 @@ cd witnesscalc
|
||||
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/
|
||||
cp ../circuits/build/register_sha256WithRSAEncryption_65537_cpp/register_sha256WithRSAEncryption_65537.dat android/app/src/main/res/raw/register_sha256WithRSAEncryption_65537.dat
|
||||
cp witnesscalc/build_witnesscalc_android/src/libwitnesscalc_register_sha256WithRSAEncryption_65537.so android/app/src/main/cpp/lib/
|
||||
cp witnesscalc/src/witnesscalc_register_sha256WithRSAEncryption_65537.h android/app/src/main/cpp/include/
|
||||
|
||||
cp ../circuits/build/disclose_cpp/disclose.dat android/app/src/main/res/raw/disclose.dat
|
||||
cp witnesscalc/build_witnesscalc_android/src/libwitnesscalc_disclose.so android/app/src/main/cpp/lib/
|
||||
cp witnesscalc/src/witnesscalc_disclose.h android/app/src/main/cpp/include/
|
||||
|
||||
@@ -6,7 +6,17 @@ make ios
|
||||
cd build_witnesscalc_ios
|
||||
|
||||
xcodebuild -project witnesscalc.xcodeproj \
|
||||
-scheme proof_of_passport \
|
||||
-scheme register_sha256WithRSAEncryption_65537 \
|
||||
-sdk iphoneos \
|
||||
-configuration Release \
|
||||
DEVELOPMENT_TEAM="$DEVELOPMENT_TEAM" \
|
||||
ARCHS="arm64" \
|
||||
-destination 'generic/platform=iOS' \
|
||||
PRODUCT_BUNDLE_IDENTIFIER=com.warrom.witnesscalc \
|
||||
build
|
||||
|
||||
xcodebuild -project witnesscalc.xcodeproj \
|
||||
-scheme disclose \
|
||||
-sdk iphoneos \
|
||||
-configuration Release \
|
||||
DEVELOPMENT_TEAM="$DEVELOPMENT_TEAM" \
|
||||
@@ -16,5 +26,12 @@ xcodebuild -project witnesscalc.xcodeproj \
|
||||
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/build_witnesscalc_ios/src/Release-iphoneos/libwitnesscalc_register_sha256WithRSAEncryption_65537.a ios
|
||||
mkdir -p ios/ProofOfPassport/Assets.xcassets/register_sha256WithRSAEncryption_65537.dat.dataset
|
||||
cp witnesscalc/src/register_sha256WithRSAEncryption_65537.dat ios/ProofOfPassport/Assets.xcassets/register_sha256WithRSAEncryption_65537.dat.dataset/register_sha256WithRSAEncryption_65537.dat
|
||||
cp witnesscalc/src/witnesscalc_register_sha256WithRSAEncryption_65537.h ios
|
||||
|
||||
cp witnesscalc/build_witnesscalc_ios/src/Release-iphoneos/libwitnesscalc_disclose.a ios
|
||||
mkdir -p ios/ProofOfPassport/Assets.xcassets/disclose.dat.dataset
|
||||
cp witnesscalc/src/disclose.dat ios/ProofOfPassport/Assets.xcassets/disclose.dat.dataset/disclose.dat
|
||||
cp witnesscalc/src/witnesscalc_disclose.h ios
|
||||
|
||||
26
app/scripts/common.sh
Normal file → Executable file
26
app/scripts/common.sh
Normal file → Executable file
@@ -1,21 +1,35 @@
|
||||
#!/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
|
||||
cp ../circuits/build/register_sha256WithRSAEncryption_65537_cpp/register_sha256WithRSAEncryption_65537.cpp witnesscalc/src
|
||||
cp ../circuits/build/register_sha256WithRSAEncryption_65537_cpp/register_sha256WithRSAEncryption_65537.dat witnesscalc/src
|
||||
cp ../circuits/build/disclose_cpp/disclose.cpp witnesscalc/src
|
||||
cp ../circuits/build/disclose_cpp/disclose.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)
|
||||
last_include=$(grep -n '#include' register_sha256WithRSAEncryption_65537.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
|
||||
namespace CIRCUIT_NAME {" register_sha256WithRSAEncryption_65537.cpp
|
||||
else
|
||||
# Linux
|
||||
sed -i "${last_include}a \\nnamespace CIRCUIT_NAME {" proof_of_passport.cpp
|
||||
sed -i "${last_include}a \\nnamespace CIRCUIT_NAME {" register_sha256WithRSAEncryption_65537.cpp
|
||||
fi
|
||||
echo "}" >> proof_of_passport.cpp
|
||||
echo "}" >> register_sha256WithRSAEncryption_65537.cpp
|
||||
|
||||
# This adds the namespace to the circuit file as described in the README
|
||||
last_include=$(grep -n '#include' disclose.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 {" disclose.cpp
|
||||
else
|
||||
# Linux
|
||||
sed -i "${last_include}a \\nnamespace CIRCUIT_NAME {" disclose.cpp
|
||||
fi
|
||||
echo "}" >> disclose.cpp
|
||||
|
||||
cd ../..
|
||||
git submodule init
|
||||
|
||||
@@ -3,19 +3,23 @@ import { Flame } from '@tamagui/lucide-icons';
|
||||
import { Text, XStack, YStack } from 'tamagui';
|
||||
import { generateProof } from "../utils/prover";
|
||||
import useUserStore from "../stores/userStore";
|
||||
import { generateCircuitInputs } from "../../../common/src/utils/generateInputs";
|
||||
import { generateCircuitInputsDisclose } from "../../../common/src/utils/generateInputs";
|
||||
import EnterAddress from "../components/EnterAddress";
|
||||
import { revealBitmapFromMapping } from "../../../common/src/utils/revealBitmap";
|
||||
import useSbtStore from "../stores/sbtStore";
|
||||
import useNavigationStore from "../stores/navigationStore";
|
||||
import { Steps } from "../utils/utils";
|
||||
import { mintSBT } from "../utils/minter";
|
||||
import { mintSBT } from "../utils/transactions";
|
||||
import { ethers } from "ethers";
|
||||
import * as amplitude from '@amplitude/analytics-react-native';
|
||||
import Clipboard from "@react-native-community/clipboard";
|
||||
import { shortenTxHash } from "../../utils/utils";
|
||||
import { textColor1 } from "../utils/colors";
|
||||
import { Pressable } from "react-native";
|
||||
import { COMMITMENT_TREE_TRACKER_URL, PASSPORT_ATTESTATION_ID, RPC_URL } from "../../../common/src/constants/constants";
|
||||
import { poseidon2 } from "poseidon-lite";
|
||||
import axios from 'axios';
|
||||
import { LeanIMT } from "@zk-kit/imt";
|
||||
|
||||
const sepolia = () => (
|
||||
<YStack ml="$2" p="$2" px="$3" bc="#0d1e18" borderRadius="$10">
|
||||
@@ -91,8 +95,8 @@ export const sbtApp: AppType = {
|
||||
|
||||
finalButtonText: 'Copy to clipboard',
|
||||
|
||||
|
||||
circuit: "proof_of_passport", // will be "disclose" soon
|
||||
scope: '1',
|
||||
circuit: "disclose",
|
||||
|
||||
// fields the user can fill
|
||||
fields: [
|
||||
@@ -104,28 +108,45 @@ export const sbtApp: AppType = {
|
||||
update,
|
||||
disclosure,
|
||||
address,
|
||||
majority
|
||||
majority,
|
||||
} = useSbtStore.getState();
|
||||
|
||||
const {
|
||||
toast,
|
||||
setStep
|
||||
setStep,
|
||||
} = useNavigationStore.getState();
|
||||
|
||||
const {
|
||||
secret,
|
||||
passportData
|
||||
} = useUserStore.getState();
|
||||
|
||||
setStep(Steps.GENERATING_PROOF);
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 10));
|
||||
const reveal_bitmap = revealBitmapFromMapping(disclosure);
|
||||
|
||||
const passportData = useUserStore.getState().passportData;
|
||||
|
||||
|
||||
const serializedCommitmentTree = await axios.get(COMMITMENT_TREE_TRACKER_URL);
|
||||
|
||||
console.log('serializedCommitmentTree:', serializedCommitmentTree);
|
||||
|
||||
const imt = new LeanIMT(
|
||||
(a: bigint, b: bigint) => poseidon2([a, b]),
|
||||
[]
|
||||
);
|
||||
|
||||
imt.import(serializedCommitmentTree.data);
|
||||
|
||||
try {
|
||||
const inputs = generateCircuitInputs(
|
||||
const inputs = generateCircuitInputsDisclose(
|
||||
secret,
|
||||
PASSPORT_ATTESTATION_ID,
|
||||
passportData,
|
||||
imt,
|
||||
majority.toString().split(""),
|
||||
reveal_bitmap,
|
||||
sbtApp.scope,
|
||||
address,
|
||||
majority,
|
||||
{ developmentMode: false }
|
||||
);
|
||||
|
||||
console.log('inputs:', inputs);
|
||||
@@ -183,15 +204,10 @@ export const sbtApp: AppType = {
|
||||
},
|
||||
})
|
||||
|
||||
const provider = new ethers.JsonRpcProvider('https://gateway.tenderly.co/public/sepolia');
|
||||
// https://mainnet.optimism.io
|
||||
const provider = new ethers.JsonRpcProvider(RPC_URL);
|
||||
|
||||
try {
|
||||
const serverResponse = await mintSBT(
|
||||
proof,
|
||||
provider,
|
||||
"sepolia"
|
||||
)
|
||||
const serverResponse = await mintSBT(proof)
|
||||
const txHash = serverResponse?.data.hash;
|
||||
|
||||
setStep(Steps.PROOF_SENT);
|
||||
|
||||
@@ -22,7 +22,6 @@ const useNavigationStore = create<NavigationState>((set, get) => ({
|
||||
isZkeyDownloading: {
|
||||
register_sha256WithRSAEncryption_65537: false,
|
||||
disclose: false,
|
||||
proof_of_passport: false,
|
||||
},
|
||||
showWarningModal: {
|
||||
show: false,
|
||||
|
||||
@@ -12,6 +12,11 @@ import useNavigationStore from './navigationStore';
|
||||
import { Steps } from '../utils/utils';
|
||||
import { ethers } from 'ethers';
|
||||
import { downloadZkey } from '../utils/zkeyDownload';
|
||||
import { generateCircuitInputsRegister } from '../../../common/src/utils/generateInputs';
|
||||
import { PASSPORT_ATTESTATION_ID, RPC_URL } from '../../../common/src/constants/constants';
|
||||
import { generateProof } from '../utils/prover';
|
||||
import { formatSigAlg } from '../../../common/src/utils/utils';
|
||||
import { sendRegisterTransaction } from '../utils/transactions';
|
||||
|
||||
interface UserState {
|
||||
passportNumber: string
|
||||
@@ -60,9 +65,8 @@ const useUserStore = create<UserState>((set, get) => ({
|
||||
useNavigationStore.getState().setStep(Steps.NFC_SCAN_COMPLETED); // this currently means go to app selection screen
|
||||
|
||||
// download zkeys if they are not already downloaded
|
||||
// downloadZkey("register_sha256WithRSAEncryption_65537"); // might move after nfc scanning
|
||||
// downloadZkey("disclose");
|
||||
downloadZkey("proof_of_passport");
|
||||
downloadZkey("register_sha256WithRSAEncryption_65537"); // might move after nfc scanning
|
||||
downloadZkey("disclose");
|
||||
|
||||
// TODO: check if the commitment is already registered, if not retry registering it
|
||||
|
||||
@@ -92,7 +96,7 @@ const useUserStore = create<UserState>((set, get) => ({
|
||||
const passportDataCreds = await Keychain.getGenericPassword({ service: "passportData" });
|
||||
|
||||
if (passportDataCreds && passportDataCreds.password) {
|
||||
throw new Error("passportData is already registered, this should never happen")
|
||||
console.log("passportData is already registered, this should never happen in prod")
|
||||
}
|
||||
|
||||
await Keychain.setGenericPassword("passportData", JSON.stringify(passportData), { service: "passportData" });
|
||||
@@ -109,44 +113,58 @@ const useUserStore = create<UserState>((set, get) => ({
|
||||
},
|
||||
|
||||
registerCommitment: async (secret, passportData) => {
|
||||
// just like in handleProve, generate inputs and launch commitment registration
|
||||
const {
|
||||
toast
|
||||
} = useNavigationStore.getState();
|
||||
|
||||
try {
|
||||
// const inputs = generateCircuitInputsRegister(
|
||||
// passportData,
|
||||
// secret,
|
||||
// { developmentMode: false }
|
||||
// );
|
||||
const inputs = generateCircuitInputsRegister(
|
||||
secret,
|
||||
PASSPORT_ATTESTATION_ID,
|
||||
passportData,
|
||||
{ developmentMode: true }
|
||||
);
|
||||
|
||||
// amplitude.track(`Sig alg supported: ${passportData.signatureAlgorithm}`);
|
||||
amplitude.track(`Sig alg supported: ${passportData.signatureAlgorithm}`);
|
||||
|
||||
// Object.keys(inputs).forEach((key) => {
|
||||
// if (Array.isArray(inputs[key as keyof typeof inputs])) {
|
||||
// console.log(key, inputs[key as keyof typeof inputs].slice(0, 10), '...');
|
||||
// } else {
|
||||
// console.log(key, inputs[key as keyof typeof inputs]);
|
||||
// }
|
||||
// });
|
||||
Object.keys(inputs).forEach((key) => {
|
||||
if (Array.isArray(inputs[key as keyof typeof inputs])) {
|
||||
console.log(key, inputs[key as keyof typeof inputs].slice(0, 10), '...');
|
||||
} else {
|
||||
console.log(key, inputs[key as keyof typeof inputs]);
|
||||
}
|
||||
});
|
||||
|
||||
// const start = Date.now();
|
||||
const start = Date.now();
|
||||
|
||||
// const proof = await generateProof(
|
||||
// `Register_${passportData.signatureAlgorithm}`, // TODO format it
|
||||
// inputs,
|
||||
// );
|
||||
const sigAlgFormatted = formatSigAlg(passportData.signatureAlgorithm, passportData.pubKey.exponent);
|
||||
|
||||
// const end = Date.now();
|
||||
// console.log('Total proof time from frontend:', end - start);
|
||||
// amplitude.track('Proof generation successful, took ' + ((end - start) / 1000) + ' seconds');
|
||||
const proof = await generateProof(
|
||||
`register_${sigAlgFormatted}`,
|
||||
inputs,
|
||||
);
|
||||
|
||||
// // TODO send the proof to the relayer
|
||||
console.log('proof:', proof);
|
||||
|
||||
// set({
|
||||
// registered: true,
|
||||
// });
|
||||
const end = Date.now();
|
||||
console.log('Total proof time from frontend:', end - start);
|
||||
amplitude.track('Proof generation successful, took ' + ((end - start) / 1000) + ' seconds');
|
||||
|
||||
const provider = new ethers.JsonRpcProvider(RPC_URL);
|
||||
|
||||
const serverResponse = await sendRegisterTransaction(proof)
|
||||
const txHash = serverResponse?.data.hash;
|
||||
|
||||
const receipt = await provider.waitForTransaction(txHash);
|
||||
console.log('receipt status:', receipt?.status);
|
||||
|
||||
if (receipt?.status === 0) {
|
||||
throw new Error("Transaction failed");
|
||||
}
|
||||
|
||||
set({
|
||||
registered: true,
|
||||
});
|
||||
} catch (error: any) {
|
||||
console.error(error);
|
||||
toast?.show('Error', {
|
||||
@@ -178,7 +196,7 @@ const useUserStore = create<UserState>((set, get) => ({
|
||||
passportNumber: "",
|
||||
dateOfBirth: "",
|
||||
dateOfExpiry: "",
|
||||
}, true),
|
||||
}),
|
||||
}))
|
||||
|
||||
export default useUserStore
|
||||
@@ -34,6 +34,7 @@ export type AppType = {
|
||||
finalButtonAction: () => void;
|
||||
finalButtonText: string;
|
||||
|
||||
scope: string;
|
||||
circuit: CircuitName; // circuit and witness calculator name
|
||||
|
||||
fields: React.FC[];
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
import { ethers } from "ethers";
|
||||
import axios from 'axios';
|
||||
import groth16ExportSolidityCallData from '../../utils/snarkjs';
|
||||
import contractAddresses from "../../deployments/addresses.json";
|
||||
import proofOfPassportArtefact from "../../deployments/ProofOfPassport.json";
|
||||
import { RELAYER_URL } from '../../../common/src/constants/constants';
|
||||
import { Proof } from "../../../common/src/utils/types";
|
||||
|
||||
export const mintSBT = async (
|
||||
proof: Proof,
|
||||
provider: ethers.JsonRpcProvider,
|
||||
chainName: string
|
||||
) => {
|
||||
if (!contractAddresses.ProofOfPassport || !proofOfPassportArtefact.abi) {
|
||||
console.log('contracts addresses or abi not found');
|
||||
return;
|
||||
}
|
||||
|
||||
// Format the proof and publicInputs as calldata for the verifier contract
|
||||
const cd = groth16ExportSolidityCallData(proof.proof, proof.pub_signals);
|
||||
const callData = JSON.parse(`[${cd}]`);
|
||||
console.log('callData', callData);
|
||||
|
||||
try {
|
||||
const proofOfPassportContract = new ethers.Contract(
|
||||
contractAddresses.ProofOfPassport,
|
||||
proofOfPassportArtefact.abi,
|
||||
provider
|
||||
);
|
||||
|
||||
const transactionRequest = await proofOfPassportContract
|
||||
.mint.populateTransaction(...callData);
|
||||
console.log('transactionRequest', transactionRequest);
|
||||
|
||||
const response = await axios.post(RELAYER_URL, {
|
||||
chain: chainName,
|
||||
tx_data: transactionRequest
|
||||
});
|
||||
console.log('response status', response.status);
|
||||
console.log('response data', response.data);
|
||||
return response;
|
||||
} catch (err: any) {
|
||||
console.log('err', err);
|
||||
throw new Error(err);
|
||||
}
|
||||
};
|
||||
@@ -11,7 +11,7 @@ export const generateProof = async (
|
||||
console.log('inputs in App.tsx', inputs);
|
||||
|
||||
const zkey_path = `${RNFS.DocumentDirectoryPath}/${circuit}.zkey`
|
||||
// Example: "/data/user/0/com.proofofpassport/files/proof_of_passport.zkey" on android
|
||||
// Example: "/data/user/0/com.proofofpassport/files/register_sha256WithRSAEncryption_65537.zkey" on android
|
||||
const witness_calculator = circuit;
|
||||
const dat_file_name = circuit
|
||||
|
||||
|
||||
117
app/src/utils/transactions.ts
Normal file
117
app/src/utils/transactions.ts
Normal file
@@ -0,0 +1,117 @@
|
||||
import { ethers } from "ethers";
|
||||
import axios from 'axios';
|
||||
import groth16ExportSolidityCallData from '../../utils/snarkjs';
|
||||
import contractAddresses from "../../deployments/deployed_addresses.json";
|
||||
import registerArtefacts from "../../deployments/artifacts/Deploy_Registry#ProofOfPassportRegister.json";
|
||||
import sbtArtefacts from "../../deployments/artifacts/Deploy_Registry#SBT.json";
|
||||
import { CHAIN_NAME, RELAYER_URL, RPC_URL } from '../../../common/src/constants/constants';
|
||||
import { Proof } from "../../../common/src/utils/types";
|
||||
import { formatCallData_disclose, formatCallData_register } from "../../../common/src/utils/formatCallData";
|
||||
|
||||
export const sendRegisterTransaction = async (
|
||||
proof: Proof,
|
||||
) => {
|
||||
const provider = new ethers.JsonRpcProvider(RPC_URL);
|
||||
|
||||
if (!contractAddresses["Deploy_Registry#ProofOfPassportRegister"] || !registerArtefacts.abi) {
|
||||
console.log('contracts addresses or abi not found');
|
||||
return;
|
||||
}
|
||||
|
||||
// Format the proof and publicInputs as calldata for the verifier contract
|
||||
const cd = groth16ExportSolidityCallData(proof.proof, proof.pub_signals);
|
||||
const callData = JSON.parse(`[${cd}]`);
|
||||
console.log('callData', callData);
|
||||
|
||||
const formattedCallData_register = formatCallData_register(callData)
|
||||
|
||||
console.log('formattedCallData_register', formattedCallData_register);
|
||||
|
||||
try {
|
||||
const registerContract = new ethers.Contract(
|
||||
contractAddresses["Deploy_Registry#ProofOfPassportRegister"],
|
||||
registerArtefacts.abi,
|
||||
provider
|
||||
);
|
||||
|
||||
const transactionRequest = await registerContract
|
||||
.validateProof.populateTransaction(formattedCallData_register, 1);
|
||||
console.log('transactionRequest', transactionRequest);
|
||||
|
||||
const response = await axios.post(RELAYER_URL, {
|
||||
chain: CHAIN_NAME,
|
||||
tx_data: transactionRequest
|
||||
});
|
||||
console.log('response status', response.status);
|
||||
console.log('response data', response.data);
|
||||
return response;
|
||||
} catch (err: any) {
|
||||
console.log('err', err);
|
||||
if (err.isAxiosError && err.response) {
|
||||
const errorMessage = err.response.data.error;
|
||||
console.log('Server error message:', errorMessage);
|
||||
|
||||
// parse blockchain error and show it
|
||||
const match = errorMessage.match(/execution reverted: "([^"]*)"/);
|
||||
if (match && match[1]) {
|
||||
console.log('Parsed blockchain error:', match[1]);
|
||||
throw new Error(match[1]);
|
||||
} else {
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const mintSBT = async (
|
||||
proof: Proof,
|
||||
) => {
|
||||
const provider = new ethers.JsonRpcProvider(RPC_URL);
|
||||
|
||||
if (!contractAddresses["Deploy_Registry#SBT"] || !sbtArtefacts.abi) {
|
||||
console.log('contracts addresses or abi not found');
|
||||
return;
|
||||
}
|
||||
|
||||
// Format the proof and publicInputs as calldata for the verifier contract
|
||||
const cd = groth16ExportSolidityCallData(proof.proof, proof.pub_signals);
|
||||
const parsedCallData_disclose = JSON.parse(`[${cd}]`);
|
||||
console.log('parsedCallData_disclose', parsedCallData_disclose);
|
||||
|
||||
const formattedCallData_disclose = formatCallData_disclose(parsedCallData_disclose);
|
||||
|
||||
try {
|
||||
const proofOfPassportContract = new ethers.Contract(
|
||||
contractAddresses["Deploy_Registry#SBT"],
|
||||
sbtArtefacts.abi,
|
||||
provider
|
||||
);
|
||||
|
||||
const transactionRequest = await proofOfPassportContract
|
||||
.mint.populateTransaction(formattedCallData_disclose);
|
||||
console.log('transactionRequest', transactionRequest);
|
||||
|
||||
const response = await axios.post(RELAYER_URL, {
|
||||
chain: CHAIN_NAME,
|
||||
tx_data: transactionRequest
|
||||
});
|
||||
console.log('response status', response.status);
|
||||
console.log('response data', response.data);
|
||||
return response;
|
||||
} catch (err: any) {
|
||||
console.log('err', err);
|
||||
if (err.isAxiosError && err.response) {
|
||||
const errorMessage = err.response.data.error;
|
||||
console.log('Server error message:', errorMessage);
|
||||
|
||||
// parse blockchain error and show it
|
||||
const match = errorMessage.match(/execution reverted: "([^"]*)"/);
|
||||
if (match && match[1]) {
|
||||
console.log('Parsed blockchain error:', match[1]);
|
||||
throw new Error(match[1]);
|
||||
} else {
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -7,9 +7,8 @@ import useNavigationStore from '../stores/navigationStore';
|
||||
|
||||
// this should not change, instead update the zkey on the bucket
|
||||
const zkeyZipUrls = {
|
||||
register_sha256WithRSAEncryption_65537: "qweqwe",
|
||||
disclose: "qweqwe",
|
||||
proof_of_passport: `https://d8o9bercqupgk.cloudfront.net/proof_of_passport.zkey.zip`,
|
||||
register_sha256WithRSAEncryption_65537: "https://d8o9bercqupgk.cloudfront.net/register_sha256WithRSAEncryption_65537.zkey.zip",
|
||||
disclose: "https://d8o9bercqupgk.cloudfront.net/disclose.zkey.zip",
|
||||
};
|
||||
|
||||
export type CircuitName = keyof typeof zkeyZipUrls;
|
||||
|
||||
@@ -35,9 +35,12 @@ install(TARGETS
|
||||
tests
|
||||
test_platform
|
||||
authV2
|
||||
proof_of_passport
|
||||
witnesscalc_proof_of_passport
|
||||
witnesscalc_proof_of_passportStatic
|
||||
disclose
|
||||
witnesscalc_disclose
|
||||
witnesscalc_discloseStatic
|
||||
register_sha256WithRSAEncryption_65537
|
||||
witnesscalc_register_sha256WithRSAEncryption_65537
|
||||
witnesscalc_register_sha256WithRSAEncryption_65537Static
|
||||
witnesscalc_authV2
|
||||
witnesscalc_authV2Static
|
||||
fr
|
||||
@@ -49,12 +52,14 @@ install(FILES "${GMP_LIB_DIR}/${GMP_LIB_FILE}"
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
|
||||
|
||||
install(FILES
|
||||
src/proof_of_passport.dat
|
||||
src/disclose.dat
|
||||
src/register_sha256WithRSAEncryption_65537.dat
|
||||
src/authV2.dat
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||
|
||||
install(FILES
|
||||
src/witnesscalc.h
|
||||
src/witnesscalc_proof_of_passport.h
|
||||
src/witnesscalc_disclose.h
|
||||
src/witnesscalc_register_sha256WithRSAEncryption_65537.h
|
||||
src/witnesscalc_authV2.h
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
|
||||
|
||||
@@ -83,20 +83,39 @@ target_compile_definitions(witnesscalc_authV2 PUBLIC CIRCUIT_NAME=authV2)
|
||||
target_compile_definitions(witnesscalc_authV2Static PUBLIC CIRCUIT_NAME=authV2)
|
||||
target_compile_definitions(authV2 PUBLIC CIRCUIT_NAME=authV2)
|
||||
|
||||
# proof_of_passport
|
||||
set(PROOFOFPASSPORT_SOURCES ${LIB_SOURCES}
|
||||
proof_of_passport.cpp
|
||||
witnesscalc_proof_of_passport.h
|
||||
witnesscalc_proof_of_passport.cpp
|
||||
# register_sha256WithRSAEncryption_65537
|
||||
set(register_sha256WithRSAEncryption_65537_SOURCES ${LIB_SOURCES}
|
||||
register_sha256WithRSAEncryption_65537.cpp
|
||||
witnesscalc_register_sha256WithRSAEncryption_65537.h
|
||||
witnesscalc_register_sha256WithRSAEncryption_65537.cpp
|
||||
)
|
||||
|
||||
add_library(witnesscalc_proof_of_passport SHARED ${PROOFOFPASSPORT_SOURCES})
|
||||
add_library(witnesscalc_proof_of_passportStatic STATIC ${PROOFOFPASSPORT_SOURCES})
|
||||
set_target_properties(witnesscalc_proof_of_passportStatic PROPERTIES OUTPUT_NAME witnesscalc_proof_of_passport)
|
||||
add_library(witnesscalc_register_sha256WithRSAEncryption_65537 SHARED ${register_sha256WithRSAEncryption_65537_SOURCES})
|
||||
add_library(witnesscalc_register_sha256WithRSAEncryption_65537Static STATIC ${register_sha256WithRSAEncryption_65537_SOURCES})
|
||||
set_target_properties(witnesscalc_register_sha256WithRSAEncryption_65537Static PROPERTIES OUTPUT_NAME witnesscalc_register_sha256WithRSAEncryption_65537)
|
||||
|
||||
add_executable(proof_of_passport main.cpp)
|
||||
target_link_libraries(proof_of_passport witnesscalc_proof_of_passportStatic)
|
||||
add_executable(register_sha256WithRSAEncryption_65537 main.cpp)
|
||||
target_link_libraries(register_sha256WithRSAEncryption_65537 witnesscalc_register_sha256WithRSAEncryption_65537Static)
|
||||
|
||||
target_compile_definitions(witnesscalc_proof_of_passport PUBLIC CIRCUIT_NAME=proof_of_passport)
|
||||
target_compile_definitions(witnesscalc_proof_of_passportStatic PUBLIC CIRCUIT_NAME=proof_of_passport)
|
||||
target_compile_definitions(proof_of_passport PUBLIC CIRCUIT_NAME=proof_of_passport)
|
||||
target_compile_definitions(witnesscalc_register_sha256WithRSAEncryption_65537 PUBLIC CIRCUIT_NAME=register_sha256WithRSAEncryption_65537)
|
||||
target_compile_definitions(witnesscalc_register_sha256WithRSAEncryption_65537Static PUBLIC CIRCUIT_NAME=register_sha256WithRSAEncryption_65537)
|
||||
target_compile_definitions(register_sha256WithRSAEncryption_65537 PUBLIC CIRCUIT_NAME=register_sha256WithRSAEncryption_65537)
|
||||
|
||||
|
||||
# disclose
|
||||
set(disclose_SOURCES ${LIB_SOURCES}
|
||||
disclose.cpp
|
||||
witnesscalc_disclose.h
|
||||
witnesscalc_disclose.cpp
|
||||
)
|
||||
|
||||
add_library(witnesscalc_disclose SHARED ${disclose_SOURCES})
|
||||
add_library(witnesscalc_discloseStatic STATIC ${disclose_SOURCES})
|
||||
set_target_properties(witnesscalc_discloseStatic PROPERTIES OUTPUT_NAME witnesscalc_disclose)
|
||||
|
||||
add_executable(disclose main.cpp)
|
||||
target_link_libraries(disclose witnesscalc_discloseStatic)
|
||||
|
||||
target_compile_definitions(witnesscalc_disclose PUBLIC CIRCUIT_NAME=disclose)
|
||||
target_compile_definitions(witnesscalc_discloseStatic PUBLIC CIRCUIT_NAME=disclose)
|
||||
target_compile_definitions(disclose PUBLIC CIRCUIT_NAME=disclose)
|
||||
594488
app/witnesscalc/src/disclose.cpp
Normal file
594488
app/witnesscalc/src/disclose.cpp
Normal file
File diff suppressed because it is too large
Load Diff
BIN
app/witnesscalc/src/disclose.dat
Normal file
BIN
app/witnesscalc/src/disclose.dat
Normal file
Binary file not shown.
@@ -3,7 +3,7 @@
|
||||
#include <assert.h>
|
||||
#include "circom.hpp"
|
||||
#include "calcwit.hpp"
|
||||
namespace CIRCUIT_NAME {namespace CIRCUIT_NAME {namespace CIRCUIT_NAME {void Ark_0_create(uint soffset,uint coffset,Circom_CalcWit* ctx,std::string componentName,uint componentFather);
|
||||
namespace CIRCUIT_NAME {void Ark_0_create(uint soffset,uint coffset,Circom_CalcWit* ctx,std::string componentName,uint componentFather);
|
||||
void Ark_0_run(uint ctx_index,Circom_CalcWit* ctx);
|
||||
void Sigma_1_create(uint soffset,uint coffset,Circom_CalcWit* ctx,std::string componentName,uint componentFather);
|
||||
void Sigma_1_run(uint ctx_index,Circom_CalcWit* ctx);
|
||||
@@ -972298,5 +972298,3 @@ ProofOfPassport_289_run(0,ctx);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1877684
app/witnesscalc/src/register_sha256WithRSAEncryption_65537.cpp
Normal file
1877684
app/witnesscalc/src/register_sha256WithRSAEncryption_65537.cpp
Normal file
File diff suppressed because it is too large
Load Diff
BIN
app/witnesscalc/src/register_sha256WithRSAEncryption_65537.dat
Normal file
BIN
app/witnesscalc/src/register_sha256WithRSAEncryption_65537.dat
Normal file
Binary file not shown.
@@ -1,8 +1,8 @@
|
||||
#include "witnesscalc_proof_of_passport.h"
|
||||
#include "witnesscalc_disclose.h"
|
||||
#include "witnesscalc.h"
|
||||
|
||||
int
|
||||
witnesscalc_proof_of_passport(
|
||||
witnesscalc_disclose(
|
||||
const char *circuit_buffer, unsigned long circuit_size,
|
||||
const char *json_buffer, unsigned long json_size,
|
||||
char *wtns_buffer, unsigned long *wtns_size,
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef WITNESSCALC_PROOFOFPASSPORT_H
|
||||
#define WITNESSCALC_PROOFOFPASSPORT_H
|
||||
#ifndef WITNESSCALC_disclose_H
|
||||
#define WITNESSCALC_disclose_H
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -25,7 +25,7 @@ extern "C" {
|
||||
*/
|
||||
|
||||
int
|
||||
witnesscalc_proof_of_passport(
|
||||
witnesscalc_disclose(
|
||||
const char *circuit_buffer, unsigned long circuit_size,
|
||||
const char *json_buffer, unsigned long json_size,
|
||||
char *wtns_buffer, unsigned long *wtns_size,
|
||||
@@ -33,9 +33,7 @@ witnesscalc_proof_of_passport(
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // WITNESSCALC_PROOFOFPASSPORT_H
|
||||
|
||||
|
||||
#endif // WITNESSCALC_PROOFOFPASSPORT_H
|
||||
#endif // WITNESSCALC_disclose_H
|
||||
@@ -0,0 +1,15 @@
|
||||
#include "witnesscalc_register_sha256WithRSAEncryption_65537.h"
|
||||
#include "witnesscalc.h"
|
||||
|
||||
int
|
||||
witnesscalc_register_sha256WithRSAEncryption_65537(
|
||||
const char *circuit_buffer, unsigned long circuit_size,
|
||||
const char *json_buffer, unsigned long json_size,
|
||||
char *wtns_buffer, unsigned long *wtns_size,
|
||||
char *error_msg, unsigned long error_msg_maxsize)
|
||||
{
|
||||
return CIRCUIT_NAME::witnesscalc(circuit_buffer, circuit_size,
|
||||
json_buffer, json_size,
|
||||
wtns_buffer, wtns_size,
|
||||
error_msg, error_msg_maxsize);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#ifndef WITNESSCALC_register_sha256WithRSAEncryption_65537_H
|
||||
#define WITNESSCALC_register_sha256WithRSAEncryption_65537_H
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define WITNESSCALC_OK 0x0
|
||||
#define WITNESSCALC_ERROR 0x1
|
||||
#define WITNESSCALC_ERROR_SHORT_BUFFER 0x2
|
||||
|
||||
/**
|
||||
*
|
||||
* @return error code:
|
||||
* WITNESSCALC_OK - in case of success.
|
||||
* WITNESSCALC_ERROR - in case of an error.
|
||||
*
|
||||
* On success wtns_buffer is filled with witness data and
|
||||
* wtns_size contains the number bytes copied to wtns_buffer.
|
||||
*
|
||||
* If wtns_buffer is too small then the function returns WITNESSCALC_ERROR_SHORT_BUFFER
|
||||
* and the minimum size for wtns_buffer in wtns_size.
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
witnesscalc_register_sha256WithRSAEncryption_65537(
|
||||
const char *circuit_buffer, unsigned long circuit_size,
|
||||
const char *json_buffer, unsigned long json_size,
|
||||
char *wtns_buffer, unsigned long *wtns_size,
|
||||
char *error_msg, unsigned long error_msg_maxsize);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // WITNESSCALC_register_sha256WithRSAEncryption_65537_H
|
||||
@@ -1702,7 +1702,7 @@
|
||||
"@nodelib/fs.scandir" "2.1.5"
|
||||
fastq "^1.6.0"
|
||||
|
||||
"@react-native-async-storage/async-storage@^1.17.11":
|
||||
"@react-native-async-storage/async-storage@^1.17.11", "@react-native-async-storage/async-storage@^1.23.1":
|
||||
version "1.23.1"
|
||||
resolved "https://registry.yarnpkg.com/@react-native-async-storage/async-storage/-/async-storage-1.23.1.tgz#cad3cd4fab7dacfe9838dce6ecb352f79150c883"
|
||||
integrity sha512-Qd2kQ3yi6Y3+AcUlrHxSLlnBvpdCEMVGFlVBneVOjaFaPU61g1huc38g339ysXspwY1QZA2aNhrk/KlHGO+ewA==
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
export const RELAYER_URL = "https://0pw5u65m3a.execute-api.eu-north-1.amazonaws.com/api-stage/mint"
|
||||
export const COMMITMENT_TREE_TRACKER_URL = "http://34.222.134.21:3000/api/download-merkle-tree"
|
||||
|
||||
export const PUBKEY_TREE_DEPTH = 16
|
||||
export const COMMITMENT_TREE_DEPTH = 16
|
||||
|
||||
// poseidon("E-PASSPORT")
|
||||
export const PASSPORT_ATTESTATION_ID = "8518753152044246090169372947057357973469996808638122125210848696986717482788"
|
||||
|
||||
export const CHAIN_NAME = "optimism"
|
||||
export const RPC_URL = "https://mainnet.optimism.io"
|
||||
|
||||
export enum SignatureAlgorithm {
|
||||
sha256WithRSAEncryption_65537 = 1,
|
||||
sha256WithRSAEncryption_3 = 2,
|
||||
|
||||
26
common/src/utils/formatCallData.ts
Normal file
26
common/src/utils/formatCallData.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
export function formatCallData_register(parsedCallData: any[]){
|
||||
return {
|
||||
commitment: parsedCallData[3][0],
|
||||
nullifier: parsedCallData[3][1],
|
||||
merkle_root: parsedCallData[3][2],
|
||||
attestation_id: parsedCallData[3][3],
|
||||
a: parsedCallData[0],
|
||||
b: [parsedCallData[1][0], parsedCallData[1][1]],
|
||||
c: parsedCallData[2],
|
||||
};;
|
||||
}
|
||||
|
||||
export function formatCallData_disclose(parsedCallData: any[]){
|
||||
return {
|
||||
nullifier: parsedCallData[3][0],
|
||||
revealedData_packed: [parsedCallData[3][1], parsedCallData[3][2], parsedCallData[3][3]],
|
||||
attestation_id: parsedCallData[3][4],
|
||||
merkle_root: parsedCallData[3][5],
|
||||
scope: parsedCallData[3][6],
|
||||
current_date: [parsedCallData[3][7], parsedCallData[3][8], parsedCallData[3][9], parsedCallData[3][10], parsedCallData[3][11], parsedCallData[3][12]],
|
||||
user_identifier: parsedCallData[3][13],
|
||||
a: parsedCallData[0],
|
||||
b: [parsedCallData[1][0], parsedCallData[1][1]],
|
||||
c: parsedCallData[2],
|
||||
};
|
||||
}
|
||||
@@ -51,7 +51,7 @@ const config: HardhatUserConfig = {
|
||||
sepolia: {
|
||||
url: "https://eth-sepolia.public.blastapi.io",
|
||||
accounts: [process.env.PKEY as string],
|
||||
gasPrice: 6 * 10 ** 9, // Optimism uses a different gas mechanism, set to 0 for automatic handling
|
||||
gasPrice: 6 * 10 ** 9,
|
||||
},
|
||||
optimismSepolia: {
|
||||
url: "https://opt-sepolia.g.alchemy.com/v2/t30F1rBnOskwo0M0Q4Re6bXQHQPpW_Sz",
|
||||
|
||||
Reference in New Issue
Block a user