Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ jobs:
run: |
chmod +x circuits/scripts/build/build_cpp.sh && \
./circuits/scripts/build/build_cpp.sh register &&
./circuits/scripts/build/build_cpp.sh register_id &&
./circuits/scripts/build/build_cpp.sh disclose &&
./circuits/scripts/build/build_cpp.sh dsc

Expand Down
31 changes: 23 additions & 8 deletions app/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function extractMRZInfo(mrzString: string) {

//line 1 and line 2 - concated
const TD1_REGEX =
/^(?<documentType>[A-Z0-9<]{2})(?<issuingCountry>[A-Z<]{3})(?<documentNumber>[A-Z0-9<]{9})(?<checkDigitDocumentNumber>[0-9]{1})(?<optionalData1>[A-Z0-9<]{15})(?<dateOfBirth>[0-9]{6})(?<checkDigitDateOfBirth>[0-9]{1})(?<sex>[MF<]{1})(?<dateOfExpiry>[0-9]{6})(?<checkDigitDateOfExpiry>[0-9]{1})(?<nationality>[A-Z<]{3})(?<optionalData2>[A-Z0-9<]{7})/;
/^([A-Z0-9<]{2})([A-Z<]{3})([A-Z0-9<]{9})([0-9]{1})([A-Z0-9<]{15})([0-9]{6})([0-9]{1})([MF<]{1})([0-9]{6})([0-9]{1})([A-Z<]{3})([A-Z0-9<]{7})/;
const TD3_line_2_REGEX = /^([A-Z0-9<]{9})([0-9ILDSOG])([A-Z<]{3})/;

const isTD1 = TD1_REGEX.test(mrzLines[0]) || mrzLines[0].startsWith('I');
Expand Down Expand Up @@ -46,15 +46,30 @@ export function extractMRZInfo(mrzString: string) {
};
}

// Function to format date from 'YYYY-MM-DD 00:00:00 +0000' to 'YYMMDD'
// Function to ensure date is in YYMMDD format
// On iOS, dates come as YYMMDD (6 chars), on Android they come as YYYY-MM-DD 00:00:00 +0000
export function formatDateToYYMMDD(inputDate: string) {
// Extract the date components directly from the input string
const year = inputDate.substring(2, 4); // Get YY part
const month = inputDate.substring(5, 7); // Get MM part
const day = inputDate.substring(8, 10); // Get DD part
if (!inputDate) {
throw new Error('Invalid date format: input string cannot be empty');
}

// If the date is already in YYMMDD format (6 characters), return it as is
if (inputDate.length === 6) {
return inputDate;
}

// If the date is in YYYY-MM-DD format (at least 10 characters), convert it
if (inputDate.length >= 10) {
// Extract the date components directly from the input string
const year = inputDate.substring(2, 4); // Get YY part
const month = inputDate.substring(5, 7); // Get MM part
const day = inputDate.substring(8, 10); // Get DD part

// Concatenate components into YYMMDD format
return year + month + day;
}

// Concatenate components into YYMMDD format
return year + month + day;
throw new Error('Invalid date format: expected YYMMDD (6 chars) or YYYY-MM-DD format (10+ chars)');
}

export function checkScannedInfo(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pragma circom 2.1.9;

include "../register.circom";

component main { public [ merkle_root ] } = REGISTER(256, 224, 44, 32, 7, 512, 128);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pragma circom 2.1.9;

include "../register_id.circom";

component main { public [ merkle_root ] } = REGISTER_ID(160, 160, 27, 32, 7, 384, 128);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pragma circom 2.1.9;

include "../register_id.circom";

component main { public [ merkle_root ] } = REGISTER_ID(160, 160, 7, 64, 4, 384, 128);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pragma circom 2.1.9;

include "../register_id.circom";

component main { public [ merkle_root ] } = REGISTER_ID(160, 160, 3, 120, 35, 384, 128);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pragma circom 2.1.9;

include "../register_id.circom";

component main { public [ merkle_root ] } = REGISTER_ID(160, 256, 1, 120, 35, 384, 128);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pragma circom 2.1.9;

include "../register_id.circom";

component main { public [ merkle_root ] } = REGISTER_ID(224, 224, 30, 32, 7, 512, 128);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pragma circom 2.1.9;

include "../register_id.circom";

component main { public [ merkle_root ] } = REGISTER_ID(256, 224, 44, 32, 7, 512, 128);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pragma circom 2.1.9;

include "../register.circom";

component main { public [ merkle_root ] } = REGISTER(256, 224, 44, 32, 7, 512, 128);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pragma circom 2.1.9;

include "../register_id.circom";

component main { public [ merkle_root ] } = REGISTER_ID(256, 256, 21, 64, 4, 512, 128);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pragma circom 2.1.9;

include "../register_id.circom";

component main { public [ merkle_root ] } = REGISTER_ID(256, 256, 37, 64, 6, 512, 128);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pragma circom 2.1.9;

include "../register_id.circom";

component main { public [ merkle_root ] } = REGISTER_ID(256, 256, 8, 64, 4, 512, 128);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pragma circom 2.1.9;

include "../register_id.circom";

component main { public [ merkle_root ] } = REGISTER_ID(256, 256, 23, 64, 6, 512, 128);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pragma circom 2.1.9;

include "../register_id.circom";

component main { public [ merkle_root ] } = REGISTER_ID(256, 256, 13, 120, 35, 512, 128);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pragma circom 2.1.9;

include "../register_id.circom";

component main { public [ merkle_root ] } = REGISTER_ID(256, 256, 43, 120, 35, 512, 128);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pragma circom 2.1.9;

include "../register_id.circom";

component main { public [ merkle_root ] } = REGISTER_ID(256, 256, 4, 120, 35, 512, 128);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pragma circom 2.1.9;

include "../register_id.circom";

component main { public [ merkle_root ] } = REGISTER_ID(256, 256, 19, 120, 35, 512, 128);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pragma circom 2.1.9;

include "../register_id.circom";

component main { public [ merkle_root ] } = REGISTER_ID(256, 256, 46, 120, 35, 512, 128);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pragma circom 2.1.9;

include "../register_id.circom";

component main { public [ merkle_root ] } = REGISTER_ID(384, 384, 22, 64, 6, 768, 256);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pragma circom 2.1.9;

include "../register_id.circom";

component main { public [ merkle_root ] } = REGISTER_ID(384, 384, 38, 64, 8, 768, 256);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pragma circom 2.1.9;

include "../register_id.circom";

component main { public [ merkle_root ] } = REGISTER_ID(384, 384, 9, 64, 6, 768, 256);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pragma circom 2.1.9;

include "../register_id.circom";

component main { public [ merkle_root ] } = REGISTER_ID(384, 384, 45, 120, 35, 768, 256);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pragma circom 2.1.9;

include "../register_id.circom";

component main { public [ merkle_root ] } = REGISTER_ID(512, 512, 10, 120, 35, 896, 256);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pragma circom 2.1.9;

include "../register_id.circom";

component main { public [ merkle_root ] } = REGISTER_ID(512, 512, 29, 64, 8, 896, 256);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pragma circom 2.1.9;

include "../register_id.circom";

component main { public [ merkle_root ] } = REGISTER_ID(512, 512, 41, 66, 8, 896, 256);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pragma circom 2.1.9;

include "../register_id.circom";

component main { public [ merkle_root ] } = REGISTER_ID(512, 512, 15, 120, 35, 896, 256);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pragma circom 2.1.9;

include "../register_id.circom";

component main { public [ merkle_root ] } = REGISTER_ID(512, 512, 42, 120, 35, 896, 256);
56 changes: 47 additions & 9 deletions circuits/scripts/build/build_cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@

# run from root
# first argument should register | dsc | disclose
if [[ $1 != "register" && $1 != "dsc" && $1 != "disclose" ]]; then
echo "first argument should be register | dsc | disclose"
if [[ $1 != "register" && $1 != "dsc" && $1 != "disclose" && $1 != "register_id" ]]; then
echo "first argument should be register | dsc | disclose | register_id"
exit 1
fi

REGISTER_CIRCUITS=(
# passport
"register_sha1_sha1_sha1_ecdsa_brainpoolP224r1:true"
"register_sha1_sha1_sha1_ecdsa_secp256r1:true"
"register_sha1_sha1_sha1_rsa_65537_4096:true"
"register_sha1_sha256_sha256_rsa_65537_4096:true"
"register_sha224_sha224_sha224_ecdsa_brainpoolP224r1:true"
"register_sha256_sha224_sha224_ecdsa_secp224r1:true"
"register_sha256_sha256_sha224_ecdsa_secp224r1:true"
"register_sha256_sha256_sha256_ecdsa_brainpoolP256r1:true"
"register_sha256_sha256_sha256_ecdsa_brainpoolP384r1:true"
"register_sha256_sha256_sha256_ecdsa_secp256r1:true"
Expand All @@ -35,8 +37,39 @@ REGISTER_CIRCUITS=(
"register_sha512_sha512_sha512_rsapss_65537_64_2048:true"
)

REGISTER_ID_CIRCUITS=(
# eu id
"register_id_sha1_sha1_sha1_ecdsa_brainpoolP224r1:true"
"register_id_sha1_sha1_sha1_ecdsa_secp256r1:true"
"register_id_sha1_sha1_sha1_rsa_65537_4096:true"
"register_id_sha1_sha256_sha256_rsa_65537_4096:true"
"register_id_sha224_sha224_sha224_ecdsa_brainpoolP224r1:true"
"register_id_sha256_sha224_sha224_ecdsa_secp224r1:true"
"register_id_sha256_sha256_sha224_ecdsa_secp224r1:true"
"register_id_sha256_sha256_sha256_ecdsa_brainpoolP256r1:true"
"register_id_sha256_sha256_sha256_ecdsa_brainpoolP384r1:true"
"register_id_sha256_sha256_sha256_ecdsa_secp256r1:true"
"register_id_sha256_sha256_sha256_ecdsa_secp384r1:true"
"register_id_sha256_sha256_sha256_rsa_3_4096:true"
"register_id_sha256_sha256_sha256_rsa_65537_4096:true"
"register_id_sha256_sha256_sha256_rsapss_3_32_2048:true"
"register_id_sha256_sha256_sha256_rsapss_65537_32_2048:true"
"register_id_sha256_sha256_sha256_rsapss_65537_32_3072:true"
"register_id_sha256_sha256_sha256_rsapss_65537_64_2048:true"
"register_id_sha384_sha384_sha384_ecdsa_brainpoolP384r1:true"
"register_id_sha384_sha384_sha384_ecdsa_brainpoolP512r1:true"
"register_id_sha384_sha384_sha384_ecdsa_secp384r1:true"
"register_id_sha384_sha384_sha384_rsapss_65537_48_2048:true"
"register_id_sha512_sha512_sha256_rsa_65537_4096:true"
"register_id_sha512_sha512_sha512_ecdsa_brainpoolP512r1:true"
"register_id_sha512_sha512_sha512_ecdsa_secp521r1:true"
"register_id_sha512_sha512_sha512_rsa_65537_4096:true"
"register_id_sha512_sha512_sha512_rsapss_65537_64_2048:true"
)

DISCLOSE_CIRCUITS=(
"vc_and_disclose:true"
"vc_and_disclose_id:true"
)

DSC_CIRCUITS=(
Expand Down Expand Up @@ -66,6 +99,11 @@ if [[ $1 == "register" ]]; then
output="output/register"
mkdir -p $output
basepath="./circuits/circuits/register/instances"
elif [[ $1 == "register_id" ]]; then
allowed_circuits=("${REGISTER_ID_CIRCUITS[@]}")
output="output/register"
mkdir -p $output
basepath="./circuits/circuits/register_id/instances"
elif [[ $1 == "dsc" ]]; then
allowed_circuits=("${DSC_CIRCUITS[@]}")
output="output/dsc"
Expand All @@ -78,7 +116,7 @@ elif [[ $1 == "disclose" ]]; then
basepath="./circuits/circuits/disclose"
fi

pids=()
pids=()
for item in "${allowed_circuits[@]}"; do
filename=$(echo "$item" | cut -d':' -f1)
allowed=$(echo "$item" | cut -d':' -f2)
Expand All @@ -89,7 +127,7 @@ for item in "${allowed_circuits[@]}"; do
fi

while [[ ${#pids[@]} -ge 5 ]]; do
new_pids=()
new_pids=()
for pid in "${pids[@]}"; do
if kill -0 "$pid" 2>/dev/null; then
new_pids+=("$pid")
Expand All @@ -107,13 +145,13 @@ for item in "${allowed_circuits[@]}"; do
circuit_name="${filename%.*}"
(
circom $filepath \
-l "circuits/node_modules" \
-l "circuits/node_modules/@zk-kit/binary-merkle-root.circom/src" \
-l "circuits/node_modules/circomlib/circuits" \
-l "node_modules" \
-l "node_modules/@zk-kit/binary-merkle-root.circom/src" \
-l "node_modules/circomlib/circuits" \
--O1 -c --output $output && \
cd $output/${circuit_name}_cpp && \
make
) &
make
) &
pids+=($!)
done

Expand Down
Loading