From cb2ef9137e64d07e98e9200490ac5052270d7fae Mon Sep 17 00:00:00 2001 From: turnoffthiscomputer <98749896+remicolin@users.noreply.github.com> Date: Wed, 25 Jun 2025 14:06:17 -0400 Subject: [PATCH 1/3] merge dev into main (#683) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * remove sdk/tests (#622) * remove sdk/tests * chore: update yarn.lock --------- Co-authored-by: Ayman * fix: add range check on paddedInLength of shaBytesDynamic (#623) * fix ci (#626) * implement self uups upgradeable (#592) * implement self uups upgradeable * small changes in identityVerificationHubImplV2 * delete aderyn.toml * chore: add custom verifier * chnage return output * feat: use self structs and a Generic output struct * feat: add userIdentifier, nullifier, forbiddencountries to returned output * add root view functions from registry * fix: build and compilation errors * add userDefined data into selfVerificationRoot * "resolve conflicts" * fix compilation problem * fix how to register verification config * test: CustomVerifier * fix verification root and hub integration * add scope check in hub impl * replace poseidon hash to ripemd+sha256 * add todo list * feat: refactor and add test cases for generic formatter * add performUserIdentifierCheck in basicVerification * change how to handle additionalData and fix stack too deep * start adding test codes * fix dependency problems in monorepo * fix: forbidden countries (#612) LGTM! * able to run test code * pass happy path * delete unused codes * change error code name, add caller address validation and add scripts to run test and build in monorepo * add all test cases in vcAndDisclose flow * remove comment out * chore: use actual user identifier outputs * success in registration tests * cover all cases * pass contractVersion instead of circuitVersion * fix disclose test * chore: add natspecs for ImplHubV2, CustomVerifier and GenericFormatter * change val name and remove unused lines * add val name change * remove userIdentifier from return data * feat: use GenericDiscloseOutput struct in verfication hook fix test cases for user identifier * chore: change the function order for Hub Impl V2 (#625) * fix nat specs * add nat spec in SelfStructs --------- Co-authored-by: Ayman Co-authored-by: Nesopie <87437291+Nesopie@users.noreply.github.com> * prettier (#629) * CAN auth - android (#613) * add missed files * add NFCMethodSelectionScreen * bump android build --------- Co-authored-by: Justin Hernandez * feat: add MRZ correction method to NFCMethodSelectionScreen (#627) * add npm auth token env (#632) * bump sdk version (#633) * publish npm package when merging on dev * bump common sdk version * replace yarn publish by npm publish * update common package version * Simplify dev mode gesture (#635) * Simplify developer mode gesture * Enable dev mode on MockData screen with five taps * add build smt function to common sdk * update vc_and_disclose_id test (dev branch) (#641) * fix: vc_and_disclose_id test * chore: yarn prettier * Show modal on NFC scan error (#642) * Add help button and error modal actions * fix the screen management * yarn nice * Bump build v2.5.4: ios 132; android 71 (#631) * bump version and build numbers * remove tamagui/toast * fix marketing version * fix: update TD1 and TD3 checks (#643) * bum yarn.lock * Bump build: ios 133; android 72 and build fixes (#654) * update gesture version and bump android build * bump and fix ios build * update lock files * fixes * fix fotoapparat library source * Update example contracts to include EUID usage (#656) * refactor: update HappyBirthday contract to V2 with support for E-Passport and EUID cards, introduce bonus multipliers, and enhance verification logic * refactor: update Airdrop contract to V2 with support for E-Passport and EU ID Card attestations * refactor: remove BASIS_POINTS constant from Airdrop contract * feat: introduce SelfIdentityERC721 contract for issuing NFTs based on verified identity credentials, replacing SelfPassportERC721 * fix: update verification functions in Airdrop, HappyBirthday, and SelfIdentityERC721 contracts to use customVerificationHook * cherry pick commit from add-test-self-verification... * block non-dev pr to main branch * audit fixes (#645) * merge dev branch into main (#624) * remove sdk/tests (#622) * remove sdk/tests * chore: update yarn.lock --------- Co-authored-by: Ayman * fix: add range check on paddedInLength of shaBytesDynamic (#623) * fix ci (#626) --------- Co-authored-by: Ayman Co-authored-by: Vishalkulkarni45 <109329073+Vishalkulkarni45@users.noreply.github.com> * update contracts (#628) * remove sdk/tests (#622) * remove sdk/tests * chore: update yarn.lock --------- Co-authored-by: Ayman * fix: add range check on paddedInLength of shaBytesDynamic (#623) * fix ci (#626) * implement self uups upgradeable (#592) * implement self uups upgradeable * small changes in identityVerificationHubImplV2 * delete aderyn.toml * chore: add custom verifier * chnage return output * feat: use self structs and a Generic output struct * feat: add userIdentifier, nullifier, forbiddencountries to returned output * add root view functions from registry * fix: build and compilation errors * add userDefined data into selfVerificationRoot * "resolve conflicts" * fix compilation problem * fix how to register verification config * test: CustomVerifier * fix verification root and hub integration * add scope check in hub impl * replace poseidon hash to ripemd+sha256 * add todo list * feat: refactor and add test cases for generic formatter * add performUserIdentifierCheck in basicVerification * change how to handle additionalData and fix stack too deep * start adding test codes * fix dependency problems in monorepo * fix: forbidden countries (#612) LGTM! * able to run test code * pass happy path * delete unused codes * change error code name, add caller address validation and add scripts to run test and build in monorepo * add all test cases in vcAndDisclose flow * remove comment out * chore: use actual user identifier outputs * success in registration tests * cover all cases * pass contractVersion instead of circuitVersion * fix disclose test * chore: add natspecs for ImplHubV2, CustomVerifier and GenericFormatter * change val name and remove unused lines * add val name change * remove userIdentifier from return data * feat: use GenericDiscloseOutput struct in verfication hook fix test cases for user identifier * chore: change the function order for Hub Impl V2 (#625) * fix nat specs * add nat spec in SelfStructs --------- Co-authored-by: Ayman Co-authored-by: Nesopie <87437291+Nesopie@users.noreply.github.com> * prettier (#629) --------- Co-authored-by: Ayman Co-authored-by: Vishalkulkarni45 <109329073+Vishalkulkarni45@users.noreply.github.com> Co-authored-by: nicoshark Co-authored-by: Nesopie <87437291+Nesopie@users.noreply.github.com> * fix: vc_and_disclose_id test (#640) * fix: vc_and_disclose_id test * chore: yarn prettier * fix: check if a config id exists * chore: change the function where the config not set verification is happening * fix: add await * feat: add getConfigId function in SelfVerificationRoot (#650) * feat: add getConfigId function in SelfVerificationRoot * update comment --------- Co-authored-by: motemotech * chore: fix ofac end index in eu id cards * chore: fix tests * fix: example contracts and tests --------- Co-authored-by: turnoffthiscomputer <98749896+remicolin@users.noreply.github.com> Co-authored-by: Vishalkulkarni45 <109329073+Vishalkulkarni45@users.noreply.github.com> Co-authored-by: nicoshark * Update deployment module for Identity Verification Hub V2 with detailed documentation and library linkage for CustomVerifier. Update initialization process to reflect changes in V2 implementation, ensuring proper setup for proxy deployment. (#658) * publish npm-package (#651) * App/eu id updates (#638) * fix build issues * generate disclosure proof with euids * generate disclosure proof with euids * Eu id updates 2 (#648) * update vc_and_disclose_id test (dev branch) (#641) * fix: vc_and_disclose_id test * chore: yarn prettier * Show modal on NFC scan error (#642) * Add help button and error modal actions * fix the screen management * yarn nice * Bump build v2.5.4: ios 132; android 71 (#631) * bump version and build numbers * remove tamagui/toast * fix marketing version * fix: update TD1 and TD3 checks (#643) * bum yarn.lock * add version and user defined data --------- Co-authored-by: Vishalkulkarni45 <109329073+Vishalkulkarni45@users.noreply.github.com> Co-authored-by: Justin Hernandez Co-authored-by: Seshanth.S🐺 <35675963+seshanthS@users.noreply.github.com> * remove the mock user define data * get the useridentifier as a hash from the user defined data * chore: add version and userDefinedData * feat: use the version in register / dsc proofs as well * update calculateUserIdentifierHash * yarn nice * refactor: consolidate user context data handling and update payload structure * fix typing issues on sha1 * remove console.log(sha1) * fix sha1 import * refactor: streamline userDefinedData handling and adjust payload type for circuit * refactor: update sha1 usage and enhance logging in calculateUserIdentifierHash * yarn nice * yarn lint common * use ts-ignore for sha1 import * fix app ci tests * fix typing issue * remove unused ts-ignore * cast uuid before calling generateinputs * bump qrcode version * add tsup on the qrcode sdk * fix: exports on selfxyz/qrcode * update how we define config.version * fix yarn imports * yarn format --------- Co-authored-by: Vishalkulkarni45 <109329073+Vishalkulkarni45@users.noreply.github.com> Co-authored-by: Justin Hernandez Co-authored-by: Seshanth.S🐺 <35675963+seshanthS@users.noreply.github.com> Co-authored-by: Ayman * Hotfix contract compile error (#660) * Fix previous rebase error * Refactor deployment module for Identity Verification Hub V2. * Fix/sdk (#652) * fix: sdk build configs * chore: SelfBackendVerifier (WIP) * feat: add custom verification * feat: consider destination chain in user defined data * chore: export attestation id * chore: export attestation id * chore: export config storage * chore: don't throw an error if the proof is not valid * chore: trim abi and rm typechain types * refactor * chore: rm unnecessary exports * šŸ“ Add docstrings to `fix/sdk` (#653) Docstrings generation was requested by @remicolin. * https://github.com/selfxyz/self/pull/652#issuecomment-2992046545 The following files were modified: * `sdk/core/src/utils/hash.ts` * `sdk/core/src/utils/proof.ts` * `sdk/core/src/utils/utils.ts` Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * review fixes * chore: fix package.json cjs types * chore: add minor changes to checks * feat: add InMemoryConfigStore, allIds constant and verificationResult type * chore: export Verification config * feat: change the verification config types * fix: throw issues early if verification config is null * fix: update yarn.lock file * chore: lint * fix: rm ts expect error directive * fix: contract tests * use excluded countries instead forbidden countries list * chore: change types in constnats --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update npm-publish workflow and bump core package version to 1.0.0 (#661) * update import * Update get verification config visibility (#664) * Update deployment module for Identity Verification Hub V2 to correct file paths and module name for deployment commands. * Add troubleshooting documentation for verification issues in deployHubV2.ts. Include manual verification steps and common failure reasons to assist users during deployment. * Change visibility of getVerificationConfigV2 function from internal to public in IdentityVerificationHubImplV2 contract to allow external access. * Apply BUSL v1.1 license headers to app (#665) * Add BSL license headers to app sources * prettier * fix license reference - https://spdx.org/licenses/BUSL-1.1.html * bump build: android 73 (#659) * Contracts/deploy staging (#668) * update scripts * deploy vc and disclose id * fix the deployment scripts on staging * update yarn.lock * bump ios build and version (#669) * configure coderabbitai (#670) * tweak coderabbit * bump * more thorough test spec * Apply BSL to app codebase (#639) * Clean up root license wording * Simplify SPDX header * simplify license and rename BSL to BUSL * fix merge issues * fix missing method --------- Co-authored-by: Justin Hernandez * SEL-423 apply xcode build suggestions (#671) * apply recommended app settings from xcode * stick to portrait orientation and update target settings * remove app clip references * Circuit audit fixes (#644) * feat: add range checks before use of LessEqThan and SelectSubArray * fix: Num2Bits_strict to constrain virtualKey * bump core version * bump core version and fix ci * chore: use npm_auth_token in yarnrc * chroe: rm yarnrc changes * chore: update npm publish * chore: run npm publish manually * chore: change hub contract address (#675) * Update npm-publish.yml * chore: use proper secret when publishing * feat: enable publishing if workflow was triggered manually * Contracts/update verifier (#673) * update hardhat config * update vc and disclose verifier * update vc and disclose verifier script and run it * update test self verification root * update verifier * bump sdk version and use new hub address * chore: update zk-kit binary merkle root dep (#674) * refactor deployment scripts (#678) * feat: add register eu id instances (#682) * feat: add register eu id instances * feat: add new instances * chore: update scripts * chore: fix sig alg * chore: rm circuits --------- Co-authored-by: Ayman Co-authored-by: Vishalkulkarni45 <109329073+Vishalkulkarni45@users.noreply.github.com> Co-authored-by: nicoshark Co-authored-by: Nesopie <87437291+Nesopie@users.noreply.github.com> Co-authored-by: Seshanth.S🐺 <35675963+seshanthS@users.noreply.github.com> Co-authored-by: Justin Hernandez Co-authored-by: Justin Hernandez Co-authored-by: Kevin Lin <86810837+kevinsslin@users.noreply.github.com> Co-authored-by: kevinsslin Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Eric Nakagawa --- .github/workflows/artifacts.yml | 1 + ...ha256_sha256_sha224_ecdsa_secp224r1.circom | 5 + ...ha1_sha1_sha1_ecdsa_brainpoolP224r1.circom | 5 + ...r_id_sha1_sha1_sha1_ecdsa_secp256r1.circom | 5 + ...er_id_sha1_sha1_sha1_rsa_65537_4096.circom | 5 + ...d_sha1_sha256_sha256_rsa_65537_4096.circom | 5 + ...sha224_sha224_ecdsa_brainpoolP224r1.circom | 5 + ...ha256_sha224_sha224_ecdsa_secp224r1.circom | 5 + ...ha256_sha256_sha224_ecdsa_secp224r1.circom | 5 + ...sha256_sha256_ecdsa_brainpoolP256r1.circom | 5 + ...sha256_sha256_ecdsa_brainpoolP384r1.circom | 5 + ...ha256_sha256_sha256_ecdsa_secp256r1.circom | 5 + ...ha256_sha256_sha256_ecdsa_secp384r1.circom | 5 + ..._id_sha256_sha256_sha256_rsa_3_4096.circom | 5 + ...a256_sha256_sha256_rsapss_3_32_2048.circom | 5 + ..._sha256_sha256_rsapss_65537_32_2048.circom | 5 + ..._sha256_sha256_rsapss_65537_32_3072.circom | 5 + ..._sha256_sha256_rsapss_65537_64_2048.circom | 5 + ...sha384_sha384_ecdsa_brainpoolP384r1.circom | 5 + ...sha384_sha384_ecdsa_brainpoolP512r1.circom | 5 + ...ha384_sha384_sha384_ecdsa_secp384r1.circom | 5 + ..._sha384_sha384_rsapss_65537_48_2048.circom | 5 + ...sha512_sha512_sha256_rsa_65537_4096.circom | 5 + ...sha512_sha512_ecdsa_brainpoolP512r1.circom | 5 + ...ha512_sha512_sha512_ecdsa_secp521r1.circom | 5 + ...sha512_sha512_sha512_rsa_65537_4096.circom | 5 + ..._sha512_sha512_rsapss_65537_64_2048.circom | 5 + circuits/scripts/build/build_cpp.sh | 56 +- circuits/scripts/build/build_r1cs_wasm.sh | 158 +++++ .../modules/scripts/updateRegistryHubV2.ts | 63 +- .../modules/verifiers/deployAllVerifiers.ts | 2 +- contracts/ignition/readme.md | 48 ++ contracts/scripts/constants.ts | 75 +++ contracts/scripts/setHubV2.ts | 234 +------ contracts/scripts/setVerifiersV2.ts | 583 ++++++------------ 35 files changed, 711 insertions(+), 639 deletions(-) create mode 100644 circuits/circuits/register/instances/register_sha256_sha256_sha224_ecdsa_secp224r1.circom create mode 100644 circuits/circuits/register_id/instances/register_id_sha1_sha1_sha1_ecdsa_brainpoolP224r1.circom create mode 100644 circuits/circuits/register_id/instances/register_id_sha1_sha1_sha1_ecdsa_secp256r1.circom create mode 100644 circuits/circuits/register_id/instances/register_id_sha1_sha1_sha1_rsa_65537_4096.circom create mode 100644 circuits/circuits/register_id/instances/register_id_sha1_sha256_sha256_rsa_65537_4096.circom create mode 100644 circuits/circuits/register_id/instances/register_id_sha224_sha224_sha224_ecdsa_brainpoolP224r1.circom create mode 100644 circuits/circuits/register_id/instances/register_id_sha256_sha224_sha224_ecdsa_secp224r1.circom create mode 100644 circuits/circuits/register_id/instances/register_id_sha256_sha256_sha224_ecdsa_secp224r1.circom create mode 100644 circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_ecdsa_brainpoolP256r1.circom create mode 100644 circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_ecdsa_brainpoolP384r1.circom create mode 100644 circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_ecdsa_secp256r1.circom create mode 100644 circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_ecdsa_secp384r1.circom create mode 100644 circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_rsa_3_4096.circom create mode 100644 circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_rsapss_3_32_2048.circom create mode 100644 circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_rsapss_65537_32_2048.circom create mode 100644 circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_rsapss_65537_32_3072.circom create mode 100644 circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_rsapss_65537_64_2048.circom create mode 100644 circuits/circuits/register_id/instances/register_id_sha384_sha384_sha384_ecdsa_brainpoolP384r1.circom create mode 100644 circuits/circuits/register_id/instances/register_id_sha384_sha384_sha384_ecdsa_brainpoolP512r1.circom create mode 100644 circuits/circuits/register_id/instances/register_id_sha384_sha384_sha384_ecdsa_secp384r1.circom create mode 100644 circuits/circuits/register_id/instances/register_id_sha384_sha384_sha384_rsapss_65537_48_2048.circom create mode 100644 circuits/circuits/register_id/instances/register_id_sha512_sha512_sha256_rsa_65537_4096.circom create mode 100644 circuits/circuits/register_id/instances/register_id_sha512_sha512_sha512_ecdsa_brainpoolP512r1.circom create mode 100644 circuits/circuits/register_id/instances/register_id_sha512_sha512_sha512_ecdsa_secp521r1.circom create mode 100644 circuits/circuits/register_id/instances/register_id_sha512_sha512_sha512_rsa_65537_4096.circom create mode 100644 circuits/circuits/register_id/instances/register_id_sha512_sha512_sha512_rsapss_65537_64_2048.circom create mode 100755 circuits/scripts/build/build_r1cs_wasm.sh create mode 100644 contracts/ignition/readme.md create mode 100644 contracts/scripts/constants.ts diff --git a/.github/workflows/artifacts.yml b/.github/workflows/artifacts.yml index 8c434c7ec..2ac0d73f8 100644 --- a/.github/workflows/artifacts.yml +++ b/.github/workflows/artifacts.yml @@ -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 diff --git a/circuits/circuits/register/instances/register_sha256_sha256_sha224_ecdsa_secp224r1.circom b/circuits/circuits/register/instances/register_sha256_sha256_sha224_ecdsa_secp224r1.circom new file mode 100644 index 000000000..40734f947 --- /dev/null +++ b/circuits/circuits/register/instances/register_sha256_sha256_sha224_ecdsa_secp224r1.circom @@ -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); diff --git a/circuits/circuits/register_id/instances/register_id_sha1_sha1_sha1_ecdsa_brainpoolP224r1.circom b/circuits/circuits/register_id/instances/register_id_sha1_sha1_sha1_ecdsa_brainpoolP224r1.circom new file mode 100644 index 000000000..61952a2aa --- /dev/null +++ b/circuits/circuits/register_id/instances/register_id_sha1_sha1_sha1_ecdsa_brainpoolP224r1.circom @@ -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); \ No newline at end of file diff --git a/circuits/circuits/register_id/instances/register_id_sha1_sha1_sha1_ecdsa_secp256r1.circom b/circuits/circuits/register_id/instances/register_id_sha1_sha1_sha1_ecdsa_secp256r1.circom new file mode 100644 index 000000000..3d400d751 --- /dev/null +++ b/circuits/circuits/register_id/instances/register_id_sha1_sha1_sha1_ecdsa_secp256r1.circom @@ -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); \ No newline at end of file diff --git a/circuits/circuits/register_id/instances/register_id_sha1_sha1_sha1_rsa_65537_4096.circom b/circuits/circuits/register_id/instances/register_id_sha1_sha1_sha1_rsa_65537_4096.circom new file mode 100644 index 000000000..53beaf39d --- /dev/null +++ b/circuits/circuits/register_id/instances/register_id_sha1_sha1_sha1_rsa_65537_4096.circom @@ -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); \ No newline at end of file diff --git a/circuits/circuits/register_id/instances/register_id_sha1_sha256_sha256_rsa_65537_4096.circom b/circuits/circuits/register_id/instances/register_id_sha1_sha256_sha256_rsa_65537_4096.circom new file mode 100644 index 000000000..c0c7df893 --- /dev/null +++ b/circuits/circuits/register_id/instances/register_id_sha1_sha256_sha256_rsa_65537_4096.circom @@ -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); \ No newline at end of file diff --git a/circuits/circuits/register_id/instances/register_id_sha224_sha224_sha224_ecdsa_brainpoolP224r1.circom b/circuits/circuits/register_id/instances/register_id_sha224_sha224_sha224_ecdsa_brainpoolP224r1.circom new file mode 100644 index 000000000..b65011637 --- /dev/null +++ b/circuits/circuits/register_id/instances/register_id_sha224_sha224_sha224_ecdsa_brainpoolP224r1.circom @@ -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); \ No newline at end of file diff --git a/circuits/circuits/register_id/instances/register_id_sha256_sha224_sha224_ecdsa_secp224r1.circom b/circuits/circuits/register_id/instances/register_id_sha256_sha224_sha224_ecdsa_secp224r1.circom new file mode 100644 index 000000000..0154b91db --- /dev/null +++ b/circuits/circuits/register_id/instances/register_id_sha256_sha224_sha224_ecdsa_secp224r1.circom @@ -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); \ No newline at end of file diff --git a/circuits/circuits/register_id/instances/register_id_sha256_sha256_sha224_ecdsa_secp224r1.circom b/circuits/circuits/register_id/instances/register_id_sha256_sha256_sha224_ecdsa_secp224r1.circom new file mode 100644 index 000000000..40734f947 --- /dev/null +++ b/circuits/circuits/register_id/instances/register_id_sha256_sha256_sha224_ecdsa_secp224r1.circom @@ -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); diff --git a/circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_ecdsa_brainpoolP256r1.circom b/circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_ecdsa_brainpoolP256r1.circom new file mode 100644 index 000000000..693fd4a36 --- /dev/null +++ b/circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_ecdsa_brainpoolP256r1.circom @@ -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); \ No newline at end of file diff --git a/circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_ecdsa_brainpoolP384r1.circom b/circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_ecdsa_brainpoolP384r1.circom new file mode 100644 index 000000000..d11893f18 --- /dev/null +++ b/circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_ecdsa_brainpoolP384r1.circom @@ -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); \ No newline at end of file diff --git a/circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_ecdsa_secp256r1.circom b/circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_ecdsa_secp256r1.circom new file mode 100644 index 000000000..a80ccb932 --- /dev/null +++ b/circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_ecdsa_secp256r1.circom @@ -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); \ No newline at end of file diff --git a/circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_ecdsa_secp384r1.circom b/circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_ecdsa_secp384r1.circom new file mode 100644 index 000000000..98fb5e2a2 --- /dev/null +++ b/circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_ecdsa_secp384r1.circom @@ -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); \ No newline at end of file diff --git a/circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_rsa_3_4096.circom b/circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_rsa_3_4096.circom new file mode 100644 index 000000000..ec5fc557d --- /dev/null +++ b/circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_rsa_3_4096.circom @@ -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); \ No newline at end of file diff --git a/circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_rsapss_3_32_2048.circom b/circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_rsapss_3_32_2048.circom new file mode 100644 index 000000000..6a4bbd897 --- /dev/null +++ b/circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_rsapss_3_32_2048.circom @@ -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); \ No newline at end of file diff --git a/circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_rsapss_65537_32_2048.circom b/circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_rsapss_65537_32_2048.circom new file mode 100644 index 000000000..c6f3a8fb1 --- /dev/null +++ b/circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_rsapss_65537_32_2048.circom @@ -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); \ No newline at end of file diff --git a/circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_rsapss_65537_32_3072.circom b/circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_rsapss_65537_32_3072.circom new file mode 100644 index 000000000..4fc7274d6 --- /dev/null +++ b/circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_rsapss_65537_32_3072.circom @@ -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); \ No newline at end of file diff --git a/circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_rsapss_65537_64_2048.circom b/circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_rsapss_65537_64_2048.circom new file mode 100644 index 000000000..4f351ae21 --- /dev/null +++ b/circuits/circuits/register_id/instances/register_id_sha256_sha256_sha256_rsapss_65537_64_2048.circom @@ -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); \ No newline at end of file diff --git a/circuits/circuits/register_id/instances/register_id_sha384_sha384_sha384_ecdsa_brainpoolP384r1.circom b/circuits/circuits/register_id/instances/register_id_sha384_sha384_sha384_ecdsa_brainpoolP384r1.circom new file mode 100644 index 000000000..5455f829e --- /dev/null +++ b/circuits/circuits/register_id/instances/register_id_sha384_sha384_sha384_ecdsa_brainpoolP384r1.circom @@ -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); \ No newline at end of file diff --git a/circuits/circuits/register_id/instances/register_id_sha384_sha384_sha384_ecdsa_brainpoolP512r1.circom b/circuits/circuits/register_id/instances/register_id_sha384_sha384_sha384_ecdsa_brainpoolP512r1.circom new file mode 100644 index 000000000..e4ef4f6e6 --- /dev/null +++ b/circuits/circuits/register_id/instances/register_id_sha384_sha384_sha384_ecdsa_brainpoolP512r1.circom @@ -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); \ No newline at end of file diff --git a/circuits/circuits/register_id/instances/register_id_sha384_sha384_sha384_ecdsa_secp384r1.circom b/circuits/circuits/register_id/instances/register_id_sha384_sha384_sha384_ecdsa_secp384r1.circom new file mode 100644 index 000000000..fa74c0050 --- /dev/null +++ b/circuits/circuits/register_id/instances/register_id_sha384_sha384_sha384_ecdsa_secp384r1.circom @@ -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); \ No newline at end of file diff --git a/circuits/circuits/register_id/instances/register_id_sha384_sha384_sha384_rsapss_65537_48_2048.circom b/circuits/circuits/register_id/instances/register_id_sha384_sha384_sha384_rsapss_65537_48_2048.circom new file mode 100644 index 000000000..8fab0aa93 --- /dev/null +++ b/circuits/circuits/register_id/instances/register_id_sha384_sha384_sha384_rsapss_65537_48_2048.circom @@ -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); \ No newline at end of file diff --git a/circuits/circuits/register_id/instances/register_id_sha512_sha512_sha256_rsa_65537_4096.circom b/circuits/circuits/register_id/instances/register_id_sha512_sha512_sha256_rsa_65537_4096.circom new file mode 100644 index 000000000..a692c86ac --- /dev/null +++ b/circuits/circuits/register_id/instances/register_id_sha512_sha512_sha256_rsa_65537_4096.circom @@ -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); diff --git a/circuits/circuits/register_id/instances/register_id_sha512_sha512_sha512_ecdsa_brainpoolP512r1.circom b/circuits/circuits/register_id/instances/register_id_sha512_sha512_sha512_ecdsa_brainpoolP512r1.circom new file mode 100644 index 000000000..fb3fb15af --- /dev/null +++ b/circuits/circuits/register_id/instances/register_id_sha512_sha512_sha512_ecdsa_brainpoolP512r1.circom @@ -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); \ No newline at end of file diff --git a/circuits/circuits/register_id/instances/register_id_sha512_sha512_sha512_ecdsa_secp521r1.circom b/circuits/circuits/register_id/instances/register_id_sha512_sha512_sha512_ecdsa_secp521r1.circom new file mode 100644 index 000000000..c8e024d0d --- /dev/null +++ b/circuits/circuits/register_id/instances/register_id_sha512_sha512_sha512_ecdsa_secp521r1.circom @@ -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); \ No newline at end of file diff --git a/circuits/circuits/register_id/instances/register_id_sha512_sha512_sha512_rsa_65537_4096.circom b/circuits/circuits/register_id/instances/register_id_sha512_sha512_sha512_rsa_65537_4096.circom new file mode 100644 index 000000000..e173a80b4 --- /dev/null +++ b/circuits/circuits/register_id/instances/register_id_sha512_sha512_sha512_rsa_65537_4096.circom @@ -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); diff --git a/circuits/circuits/register_id/instances/register_id_sha512_sha512_sha512_rsapss_65537_64_2048.circom b/circuits/circuits/register_id/instances/register_id_sha512_sha512_sha512_rsapss_65537_64_2048.circom new file mode 100644 index 000000000..fab36a7dd --- /dev/null +++ b/circuits/circuits/register_id/instances/register_id_sha512_sha512_sha512_rsapss_65537_64_2048.circom @@ -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); \ No newline at end of file diff --git a/circuits/scripts/build/build_cpp.sh b/circuits/scripts/build/build_cpp.sh index 6e2b5f4b9..1890ca0cb 100755 --- a/circuits/scripts/build/build_cpp.sh +++ b/circuits/scripts/build/build_cpp.sh @@ -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" @@ -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=( @@ -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" @@ -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) @@ -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") @@ -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 diff --git a/circuits/scripts/build/build_r1cs_wasm.sh b/circuits/scripts/build/build_r1cs_wasm.sh new file mode 100755 index 000000000..b0c42ce79 --- /dev/null +++ b/circuits/scripts/build/build_r1cs_wasm.sh @@ -0,0 +1,158 @@ +#!/bin/bash + +# run from root +# first argument should 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" + "register_sha256_sha256_sha256_ecdsa_secp384r1:true" + "register_sha256_sha256_sha256_rsa_3_4096:true" + "register_sha256_sha256_sha256_rsa_65537_4096:true" + "register_sha256_sha256_sha256_rsapss_3_32_2048:true" + "register_sha256_sha256_sha256_rsapss_65537_32_2048:true" + "register_sha256_sha256_sha256_rsapss_65537_32_3072:true" + "register_sha256_sha256_sha256_rsapss_65537_64_2048:true" + "register_sha384_sha384_sha384_ecdsa_brainpoolP384r1:true" + "register_sha384_sha384_sha384_ecdsa_brainpoolP512r1:true" + "register_sha384_sha384_sha384_ecdsa_secp384r1:true" + "register_sha384_sha384_sha384_rsapss_65537_48_2048:true" + "register_sha512_sha512_sha256_rsa_65537_4096:true" + "register_sha512_sha512_sha512_ecdsa_brainpoolP512r1:true" + "register_sha512_sha512_sha512_ecdsa_secp521r1:true" + "register_sha512_sha512_sha512_rsa_65537_4096:true" + "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=( + "dsc_sha1_ecdsa_brainpoolP256r1:true" + "dsc_sha1_ecdsa_secp256r1:true" + "dsc_sha1_rsa_65537_4096:true" + "dsc_sha256_ecdsa_brainpoolP256r1:true" + "dsc_sha256_ecdsa_brainpoolP384r1:true" + "dsc_sha256_ecdsa_secp256r1:true" + "dsc_sha256_ecdsa_secp384r1:true" + "dsc_sha256_ecdsa_secp521r1:true" + "dsc_sha256_rsa_65537_4096:true" + "dsc_sha256_rsapss_3_32_3072:true" + "dsc_sha256_rsapss_65537_32_3072:true" + "dsc_sha256_rsapss_65537_32_4096:true" + "dsc_sha384_ecdsa_brainpoolP384r1:true" + "dsc_sha384_ecdsa_brainpoolP512r1:true" + "dsc_sha384_ecdsa_secp384r1:true" + "dsc_sha512_ecdsa_brainpoolP512r1:true" + "dsc_sha512_ecdsa_secp521r1:true" + "dsc_sha512_rsa_65537_4096:true" + "dsc_sha512_rsapss_65537_64_4096:true" +) + +if [[ $1 == "register" ]]; then + allowed_circuits=("${REGISTER_CIRCUITS[@]}") + 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" + mkdir -p $output + basepath="./circuits/circuits/dsc/instances" +elif [[ $1 == "disclose" ]]; then + allowed_circuits=("${DISCLOSE_CIRCUITS[@]}") + output="output/disclose" + mkdir -p $output + basepath="./circuits/circuits/disclose" +fi + +pids=() +for item in "${allowed_circuits[@]}"; do + filename=$(echo "$item" | cut -d':' -f1) + allowed=$(echo "$item" | cut -d':' -f2) + + if [[ $allowed == 'false' ]]; then + echo "Skipping $filename (not in allowed circuits)" + continue + fi + + while [[ ${#pids[@]} -ge 5 ]]; do + new_pids=() + for pid in "${pids[@]}"; do + if kill -0 "$pid" 2>/dev/null; then + new_pids+=("$pid") + else + echo "Process $pid finished" + fi + done + pids=("${new_pids[@]}") + sleep 1 + done + + echo $filename $allowed + filepath=${basepath}/${filename}.circom + circom_pid=$! + circuit_name="${filename%.*}" + ( + circom $filepath \ + -l "node_modules" \ + -l "node_modules/@zk-kit/binary-merkle-root.circom/src" \ + -l "node_modules/circomlib/circuits" \ + --O1 --r1cs --wasm --output $output + ) & + pids+=($!) +done + +echo "Waiting for all circuits to compile..." +wait "${pids[@]}" +echo "All circuits compiled successfully!" diff --git a/contracts/ignition/modules/scripts/updateRegistryHubV2.ts b/contracts/ignition/modules/scripts/updateRegistryHubV2.ts index 6a85a58af..038fb9d2d 100644 --- a/contracts/ignition/modules/scripts/updateRegistryHubV2.ts +++ b/contracts/ignition/modules/scripts/updateRegistryHubV2.ts @@ -1,50 +1,47 @@ import { buildModule } from "@nomicfoundation/hardhat-ignition/modules"; import hre from "hardhat"; -import fs from "fs"; -import path from "path"; +import { getSavedRepo, getDeployedAddresses, getContractAddress, log } from "../../../scripts/constants"; module.exports = buildModule("UpdateRegistryHubV2", (m) => { - const repo = hre.network.config.chainId === 42220 ? "prod" : "staging"; - const deployedAddressesPath = path.join(__dirname, `../../deployments/${repo}/deployed_addresses.json`); + const chainId = hre.network.config.chainId; + const networkName = hre.network.name; - console.log(`Reading deployed addresses from: ${deployedAddressesPath}`); - const deployedAddresses = JSON.parse(fs.readFileSync(deployedAddressesPath, "utf8")); + log.info(`Network: ${networkName}, Chain ID: ${chainId}`); - const registryAddress = deployedAddresses["DeployRegistryModule#IdentityRegistry"]; - const registryIdCardAddress = deployedAddresses["DeployIdCardRegistryModule#IdentityRegistryIdCard"]; - const hubAddress = deployedAddresses["DeployHubV2#IdentityVerificationHub"]; + const repoName = getSavedRepo(networkName); + const deployedAddresses = getDeployedAddresses(repoName); - // Validate addresses - if (!registryAddress) { - throw new Error("IdentityRegistry address not found in deployed addresses"); - } - if (!registryIdCardAddress) { - throw new Error("IdentityRegistryIdCard address not found in deployed addresses"); - } - if (!hubAddress) { - throw new Error("IdentityVerificationHub address not found in deployed addresses"); - } + log.info(`Using repo: ${repoName}`); - console.log(`Registry address: ${registryAddress}`); - console.log(`Registry ID Card address: ${registryIdCardAddress}`); - console.log(`Hub address: ${hubAddress}`); + try { + const registryAddress = getContractAddress("DeployRegistryModule#IdentityRegistry", deployedAddresses); + const registryIdCardAddress = getContractAddress("DeployIdCardRegistryModule#IdentityRegistryIdCard", deployedAddresses); + const hubAddress = getContractAddress("DeployHubV2#IdentityVerificationHub", deployedAddresses); - const deployedRegistryInstance = m.contractAt("IdentityRegistryImplV1", registryAddress); - const deployedRegistryIdCardInstance = m.contractAt("IdentityRegistryIdCardImplV1", registryIdCardAddress); + log.info(`Registry address: ${registryAddress}`); + log.info(`Registry ID Card address: ${registryIdCardAddress}`); + log.info(`Hub address: ${hubAddress}`); - console.log("āœ“ Created registry contract instances"); + const deployedRegistryInstance = m.contractAt("IdentityRegistryImplV1", registryAddress); + const deployedRegistryIdCardInstance = m.contractAt("IdentityRegistryIdCardImplV1", registryIdCardAddress); + + log.success("Created registry contract instances"); // Execute the updateHub calls - console.log("Updating hub address on IdentityRegistry..."); - m.call(deployedRegistryInstance, "updateHub", [hubAddress]); + log.step("Updating hub address on IdentityRegistry..."); + m.call(deployedRegistryInstance, "updateHub", [hubAddress]); - console.log("Updating hub address on IdentityRegistryIdCard..."); - m.call(deployedRegistryIdCardInstance, "updateHub", [hubAddress]); + log.step("Updating hub address on IdentityRegistryIdCard..."); + m.call(deployedRegistryIdCardInstance, "updateHub", [hubAddress]); - console.log("āœ“ Hub update calls initiated successfully"); + log.success("Hub update calls initiated successfully"); return { - deployedRegistryInstance, - deployedRegistryIdCardInstance - }; + deployedRegistryInstance, + deployedRegistryIdCardInstance + }; + } catch (error) { + log.error(`Failed to update registry hub: ${error}`); + throw error; + } }); diff --git a/contracts/ignition/modules/verifiers/deployAllVerifiers.ts b/contracts/ignition/modules/verifiers/deployAllVerifiers.ts index f27009bd6..3db2c4079 100644 --- a/contracts/ignition/modules/verifiers/deployAllVerifiers.ts +++ b/contracts/ignition/modules/verifiers/deployAllVerifiers.ts @@ -6,7 +6,7 @@ import * as path from "path"; const deployVerifiers = { vcAndDiscloseVerifier: false, - vcAndDiscloseIdVerifier: true, + vcAndDiscloseIdVerifier: false, registerIdVerifier: false, registerVerifier: false, dscVerifier: false, diff --git a/contracts/ignition/readme.md b/contracts/ignition/readme.md new file mode 100644 index 000000000..2e4ce371d --- /dev/null +++ b/contracts/ignition/readme.md @@ -0,0 +1,48 @@ +how to deploy and update the protocol + +Main contracts: +- Hub +- Registries + - Passports + - ID cards + +Hub and Registries are following an upgradeable proxy pattern. +Use only the Proxy address for everything. + +Secondary contracts: +- vc_and_disclose verifiers +- vc_and_disclose_id verifiers +- register verifiers' +- register id verifiers +- dsc verifiers + +How to update the protocol: + + +### Deploy the Hub V2 and the Identity registry + +``` +yarn deploy:hub:v2 +``` + +``` +deploy:registry:idcard +``` + +### Set the registries address in the hub + +```` +yarn set:hub:v2 +```` + +Set the verifiers in the hub + +``` +yarn set:verifiers:v2 +``` + +### Update the registries + +```` +yarn set:registry:hub:v2 +``` diff --git a/contracts/scripts/constants.ts b/contracts/scripts/constants.ts new file mode 100644 index 000000000..bf4eae24b --- /dev/null +++ b/contracts/scripts/constants.ts @@ -0,0 +1,75 @@ +import * as path from "path"; +import * as fs from "fs"; + +export const ATTESTATION_ID = { + E_PASSPORT: '0x0000000000000000000000000000000000000000000000000000000000000001', + EU_ID_CARD: '0x0000000000000000000000000000000000000000000000000000000000000002', +}; + +export const ATTESTATION_TO_REGISTRY = { + E_PASSPORT: 'DeployRegistryModule#IdentityRegistry', + EU_ID_CARD: 'DeployIdCardRegistryModule#IdentityRegistryIdCard', +} + +export const NETWORK_TO_CHAIN_ID: Record = { + localhost: '31337', + hardhat: '31337', + alfajores: '44787', + celoAlfajores: '44787', + celo: '42220', + mainnet: '42220', + staging: '44787', +}; + +export const CHAIN_ID_TO_SAVED_REPO: Record = { + '42220' : 'prod', + '44787' : 'staging' +}; + +export const getChainId = (network: string): string => { + const chainId = NETWORK_TO_CHAIN_ID[network]; + console.log(`Network '${network}' mapped to Chain ID: ${chainId}`); + return chainId; +}; + +export const getSavedRepo = (network: string): string => { +const repoName = CHAIN_ID_TO_SAVED_REPO[NETWORK_TO_CHAIN_ID[network]]; +return repoName; +}; + + +export const getDeployedAddresses = (repoName: string): any => { + const addresses_path = path.join(__dirname, `../ignition/deployments/${repoName}/deployed_addresses.json`); + return JSON.parse(fs.readFileSync(addresses_path, "utf-8")); +} +export const getContractAbi = (repoName: string, deploymentArtifactName: string): any => { + const abi_path = path.join(__dirname, `../ignition/deployments/${repoName}/artifacts/${deploymentArtifactName}.json`); + return JSON.parse(fs.readFileSync(abi_path, "utf-8")).abi; +} + +export function getContractAddress(exactName: string, deployedAddresses : any): any { + if (exactName in deployedAddresses) { + return deployedAddresses[exactName]; + } + throw Error(`No contract address found for ${exactName}`) +} + +// Console colors +const colors = { + reset: '\x1b[0m', + red: '\x1b[31m', + green: '\x1b[32m', + yellow: '\x1b[33m', + blue: '\x1b[34m', + magenta: '\x1b[35m', + cyan: '\x1b[36m', + white: '\x1b[37m' +}; + +export const log = { + info: (msg: string) => console.log(`${colors.blue}[INFO]${colors.reset} ${msg}`), + success: (msg: string) => console.log(`${colors.green}[SUCCESS]${colors.reset} ${msg}`), + warning: (msg: string) => console.log(`${colors.yellow}[WARNING]${colors.reset} ${msg}`), + error: (msg: string) => console.log(`${colors.red}[ERROR]${colors.reset} ${msg}`), + step: (msg: string) => console.log(`${colors.magenta}[STEP]${colors.reset} ${msg}`) +}; diff --git a/contracts/scripts/setHubV2.ts b/contracts/scripts/setHubV2.ts index 25d5a5070..84209b2c3 100644 --- a/contracts/scripts/setHubV2.ts +++ b/contracts/scripts/setHubV2.ts @@ -1,105 +1,38 @@ import { ethers } from "ethers"; import * as dotenv from "dotenv"; -import * as fs from "fs"; -import * as path from "path"; -import { RegisterVerifierId, DscVerifierId } from "@selfxyz/common"; +import { getDeployedAddresses, getContractAbi, getSavedRepo, getContractAddress, ATTESTATION_TO_REGISTRY, ATTESTATION_ID } from "./constants"; dotenv.config(); -// Environment configuration -const NETWORK = process.env.NETWORK || "localhost"; // Default to staging -const RPC_URL_KEY = NETWORK === "celo" ? "CELO_RPC_URL" : "CELO_ALFAJORES_RPC_URL"; -const PRIVATE_KEY = process.env.PRIVATE_KEY; - -// Network to Chain ID mapping -const NETWORK_TO_CHAIN_ID: Record = { - localhost: "31337", - hardhat: "31337", - alfajores: "44787", - celoAlfajores: "44787", - celo: "42220", - mainnet: "42220", - staging: "44787", // Default staging to alfajores -}; - -// Get chain ID from network name -const getChainId = (network: string): string => { - const chainId = NETWORK_TO_CHAIN_ID[network] || NETWORK_TO_CHAIN_ID["alfajores"]; - console.log(`Network "${network}" mapped to Chain ID: ${chainId}`); - return chainId; -}; - -const CHAIN_ID = getChainId(NETWORK); - -// Define AttestationId constants directly based on values from AttestationId.sol -const AttestationId = { - // Pad with zeros to create full 32 bytes length - E_PASSPORT: "0x0000000000000000000000000000000000000000000000000000000000000001", - EU_ID_CARD: "0x0000000000000000000000000000000000000000000000000000000000000002", -}; +const setHubV2 = { + 'E_PASSPORT' : false, + 'EU_ID_CARD' : false, +} -const repo = CHAIN_ID === "42220" ? "prod" : "staging"; +const NETWORK = process.env.NETWORK; +const RPC_URL = process.env.RPC_URL; +const PRIVATE_KEY = process.env.PRIVATE_KEY; -// Dynamic paths based on chain ID -const deployedAddressesPath = path.join(__dirname, `../ignition/deployments/${repo}/deployed_addresses.json`); -const contractAbiPath = path.join( - __dirname, - `../ignition/deployments/${repo}/artifacts/DeployV2#IdentityVerificationHubImplV2.json`, -); +if (!NETWORK){ + throw new Error('One of the following parameter is null: NETWORK, RPC_URL, PRIVATE_KEY') +} -// Debug logs for paths and files +const repoName = getSavedRepo(NETWORK); +const deployedAddresses = getDeployedAddresses(repoName); console.log("Network:", NETWORK); -console.log("Chain ID:", CHAIN_ID); +console.log("Repo:", repoName) console.log("Current directory:", __dirname); -console.log("Deployed addresses path:", deployedAddressesPath); -console.log("Contract ABI path:", contractAbiPath); - -// Debug logs for environment variables (redacted for security) -console.log(`${RPC_URL_KEY} configured:`, !!process.env[RPC_URL_KEY]); -console.log("PRIVATE_KEY configured:", !!PRIVATE_KEY); try { - const deployedAddresses = JSON.parse(fs.readFileSync(deployedAddressesPath, "utf-8")); console.log("Deployed addresses loaded:", deployedAddresses); - - const identityVerificationHubAbiFile = fs.readFileSync(contractAbiPath, "utf-8"); - console.log("ABI file loaded"); - - const identityVerificationHubAbi = JSON.parse(identityVerificationHubAbiFile).abi; - console.log("ABI parsed"); - - function getContractAddressByPartialName(partialName: string): string | unknown { - for (const [key, value] of Object.entries(deployedAddresses)) { - if (key.includes(partialName)) { - return value; - } - } - return undefined; - } - - function getContractAddressByExactName(exactName: string): string | unknown { - if (exactName in deployedAddresses) { - return deployedAddresses[exactName]; - } - return undefined; - } - - function getAttestationIdBytes32(attestationIdName: string): string { - return AttestationId[attestationIdName as keyof typeof AttestationId]; - } + const hubABI = getContractAbi(repoName,'DeployHubV2#IdentityVerificationHubImplV2') async function main() { - const provider = new ethers.JsonRpcProvider(process.env[RPC_URL_KEY] as string); - console.log("Provider created"); - + const provider = new ethers.JsonRpcProvider(RPC_URL); const wallet = new ethers.Wallet(PRIVATE_KEY as string, provider); console.log("Wallet created"); - // Get hub address from deployment files (PROXY, not implementation) - const hubAddress = (getContractAddressByExactName("DeployV2#IdentityVerificationHub") || // ← PROXY - getContractAddressByExactName("DeployHubV2#IdentityVerificationHub") || - getContractAddressByExactName("DeployHub#IdentityVerificationHub") || - getContractAddressByPartialName("IdentityVerificationHub")) as string; + const hubAddress = (getContractAddress("DeployHubV2#IdentityVerificationHub", deployedAddresses)) as string; console.log("Hub address:", hubAddress); @@ -108,20 +41,16 @@ try { throw new Error("Hub address not found in deployed_addresses.json. Available contracts listed above."); } - const identityVerificationHub = new ethers.Contract(hubAddress, identityVerificationHubAbi, wallet); + const identityVerificationHub = new ethers.Contract(hubAddress, hubABI, wallet); console.log("Contract instance created"); - // Update registry addresses for different attestation types - const attestationTypes = ["E_PASSPORT", "EU_ID_CARD"]; + const attestationTypes = ["E_PASSPORT", "EU_ID_CARD"] as const; for (const attestationType of attestationTypes) { - let registryName: any; - if (attestationType == "E_PASSPORT") { - registryName = "DeployRegistryModule#IdentityRegistry"; - } else if (attestationType == "EU_ID_CARD") { - registryName = "DeployIdCardRegistryModule#IdentityRegistryIdCard"; - } - - const registryAddress = getContractAddressByExactName(registryName); + if (setHubV2[attestationType]){ + const registryName = ATTESTATION_TO_REGISTRY[attestationType] as any + console.log('registry name:', registryName); + const registryAddress = getContractAddress(registryName, deployedAddresses); + console.log('registry address:', registryAddress); if (!registryAddress) { console.log(`Skipping registry update for ${attestationType} because no deployed address was found.`); @@ -129,8 +58,7 @@ try { } console.log(`Updating registry for ${attestationType}`); - const attestationId = getAttestationIdBytes32(attestationType); - + const attestationId = ATTESTATION_ID[attestationType]; try { const tx = await identityVerificationHub.updateRegistry(attestationId, registryAddress); const receipt = await tx.wait(); @@ -139,117 +67,11 @@ try { console.error(`Error updating registry for ${attestationType}:`, error); } } - - // Update VC and Disclose circuit verifiers for different attestation types - for (const attestationType of attestationTypes) { - let verifierName: any; - if (attestationType == "E_PASSPORT") { - verifierName = "DeployAllVerifiers#Verifier_vc_and_disclose"; - } else if (attestationType == "EU_ID_CARD") { - verifierName = "DeployAllVerifiers#Verifier_vc_and_disclose_id"; - } - const verifierAddress = getContractAddressByExactName(verifierName); - - if (!verifierAddress) { - console.log( - `Skipping VC and Disclose circuit update for ${attestationType} because no deployed address was found.`, - ); - continue; - } - - console.log(`Updating VC and Disclose circuit for ${attestationType}`); - const attestationId = getAttestationIdBytes32(attestationType); - - try { - const tx = await identityVerificationHub.updateVcAndDiscloseCircuit(attestationId, verifierAddress); - const receipt = await tx.wait(); - console.log(`VC and Disclose circuit for ${attestationType} updated with tx: ${receipt.hash}`); - } catch (error) { - console.error(`Error updating VC and Disclose circuit for ${attestationType}:`, error); - } - } - - // Batch update register circuit verifiers - const registerVerifierKeys = Object.keys(RegisterVerifierId).filter((key) => isNaN(Number(key))); - - for (const attestationType of attestationTypes) { - const attestationId = getAttestationIdBytes32(attestationType); - const registerCircuitVerifierIds: number[] = []; - const registerCircuitVerifierAddresses: string[] = []; - - for (const key of registerVerifierKeys) { - const verifierName = `Verifier_${key}`; - const verifierAddress = getContractAddressByPartialName(verifierName); - - if (!verifierAddress) { - console.log(`Skipping ${verifierName} because no deployed address was found.`); - continue; - } - - const verifierId = RegisterVerifierId[key as keyof typeof RegisterVerifierId]; - registerCircuitVerifierIds.push(verifierId); - registerCircuitVerifierAddresses.push(verifierAddress as string); - } - - if (registerCircuitVerifierIds.length > 0) { - console.log(`Batch updating register circuit verifiers for ${attestationType}`); - - try { - const attestationIds = Array(registerCircuitVerifierIds.length).fill(attestationId); - const tx = await identityVerificationHub.batchUpdateRegisterCircuitVerifiers( - attestationIds, - registerCircuitVerifierIds, - registerCircuitVerifierAddresses, - ); - const receipt = await tx.wait(); - console.log(`Register circuit verifiers for ${attestationType} updated with tx: ${receipt.hash}`); - } catch (error) { - console.error(`Error batch updating register circuit verifiers for ${attestationType}:`, error); - } - } - } - - // Batch update DSC circuit verifiers - const dscKeys = Object.keys(DscVerifierId).filter((key) => isNaN(Number(key))); - - for (const attestationType of attestationTypes) { - const attestationId = getAttestationIdBytes32(attestationType); - const dscCircuitVerifierIds: number[] = []; - const dscCircuitVerifierAddresses: string[] = []; - - for (const key of dscKeys) { - const verifierName = `Verifier_${key}`; - const verifierAddress = getContractAddressByPartialName(verifierName); - - if (!verifierAddress) { - console.log(`Skipping ${verifierName} because no deployed address was found.`); - continue; - } - - const verifierId = DscVerifierId[key as keyof typeof DscVerifierId]; - dscCircuitVerifierIds.push(verifierId); - dscCircuitVerifierAddresses.push(verifierAddress as string); - } - - if (dscCircuitVerifierIds.length > 0) { - console.log(`Batch updating DSC circuit verifiers for ${attestationType}`); - - try { - const attestationIds = Array(dscCircuitVerifierIds.length).fill(attestationId); - const tx = await identityVerificationHub.batchUpdateDscCircuitVerifiers( - attestationIds, - dscCircuitVerifierIds, - dscCircuitVerifierAddresses, - ); - const receipt = await tx.wait(); - console.log(`DSC circuit verifiers for ${attestationType} updated with tx: ${receipt.hash}`); - } catch (error) { - console.error(`Error batch updating DSC circuit verifiers for ${attestationType}:`, error); - } - } + else { + console.log(`Skipping registry update for ${attestationType}`); } } - + } main().catch((error) => { console.error("Execution error:", error); process.exitCode = 1; diff --git a/contracts/scripts/setVerifiersV2.ts b/contracts/scripts/setVerifiersV2.ts index 935e8c4d2..0d8ae58ae 100644 --- a/contracts/scripts/setVerifiersV2.ts +++ b/contracts/scripts/setVerifiersV2.ts @@ -1,464 +1,267 @@ import { ethers } from "ethers"; import * as dotenv from "dotenv"; -import * as fs from "fs"; -import * as path from "path"; import { RegisterVerifierId, DscVerifierId } from "@selfxyz/common"; +import { + getContractAbi, + getDeployedAddresses, + getSavedRepo, + getContractAddress, + ATTESTATION_ID, + log +} from "./constants"; dotenv.config(); -// Define AttestationId constants directly based on values from AttestationId.sol -const AttestationId = { - // Pad with zeros to create full 32 bytes length - E_PASSPORT: "0x0000000000000000000000000000000000000000000000000000000000000001", - EU_ID_CARD: "0x0000000000000000000000000000000000000000000000000000000000000002", +// Configuration for which verifiers to set +const setVerifiers = { + vcAndDisclose: true, // VC and Disclose verifier for E_PASSPORT + vcAndDiscloseId: true, // VC and Disclose ID verifier for EU_ID_CARD + register: true, // Register verifiers for E_PASSPORT + registerId: true, // Register ID verifiers for EU_ID_CARD + dsc: true, // DSC verifiers for both E_PASSPORT and EU_ID_CARD }; -console.log("šŸš€ Starting setVerifiersV2 script..."); -console.log("================================"); - -// Debug logs for paths and files -console.log("šŸ“ File paths:"); -console.log(" Current directory:", __dirname); -console.log( - " Deployed addresses path:", - path.join(__dirname, "../ignition/deployments/staging/deployed_addresses.json"), -); -console.log( - " Contract ABI path:", - path.join(__dirname, "../ignition/deployments/staging/artifacts/DeployV2#IdentityVerificationHubImplV2.json"), -); - -// Debug logs for environment variables (redacted for security) -console.log("šŸ” Environment variables:"); -console.log(" CELO_RPC_URL configured:", !!process.env.CELO_ALFAJORES_RPC_URL); -console.log(" PRIVATE_KEY configured:", !!process.env.PRIVATE_KEY); -console.log(" Network:", process.env.NETWORK || "not set"); -try { - console.log("\nšŸ“‹ Loading deployment data..."); - const deployedAddresses = JSON.parse( - fs.readFileSync(path.join(__dirname, "../ignition/deployments/staging/deployed_addresses.json"), "utf-8"), - ); - console.log("āœ… Deployed addresses loaded successfully"); - console.log(` Found ${Object.keys(deployedAddresses).length} deployed contracts`); - - // Log all available contracts for debugging - console.log("\nšŸ“¦ Available deployed contracts:"); - Object.keys(deployedAddresses).forEach((key, index) => { - console.log(` ${index + 1}. ${key} -> ${deployedAddresses[key]}`); - }); +const NETWORK = process.env.NETWORK; +const RPC_URL = process.env.RPC_URL; +const PRIVATE_KEY = process.env.PRIVATE_KEY; + +if (!NETWORK){ + throw new Error('One of the following parameter is null: NETWORK, RPC_URL, PRIVATE_KEY') +} + +const repoName = getSavedRepo(NETWORK); +const deployedAddresses = getDeployedAddresses(repoName); - const identityVerificationHubAbiFile = fs.readFileSync( - path.join(__dirname, "../ignition/deployments/staging/artifacts/DeployV2#IdentityVerificationHubImplV2.json"), - "utf-8", - ); - console.log("āœ… ABI file loaded successfully"); +log.info(`Network: ${NETWORK}, Repo: ${repoName}`); - const identityVerificationHubAbi = JSON.parse(identityVerificationHubAbiFile).abi; - console.log("āœ… ABI parsed successfully"); +try { + const hubABI = getContractAbi(repoName,'DeployHubV2#IdentityVerificationHubImplV2') - function getContractAddressByPartialName(partialName: string): string | unknown { + function getContractAddressByPartialName(partialName: string): string | undefined { console.log(`šŸ” Searching for contract with partial name: "${partialName}"`); for (const [key, value] of Object.entries(deployedAddresses)) { if (key.includes(partialName)) { console.log(` āœ… Found match: ${key} -> ${value}`); - return value; + return value as string; } } console.log(` āŒ No match found for: "${partialName}"`); return undefined; } - function getContractAddressByExactName(exactName: string): string | unknown { - console.log(`šŸŽÆ Looking for exact contract name: "${exactName}"`); - if (exactName in deployedAddresses) { - console.log(` āœ… Found: ${exactName} -> ${deployedAddresses[exactName]}`); - return deployedAddresses[exactName]; - } - console.log(` āŒ Not found: "${exactName}"`); - return undefined; - } - - function getAttestationIdBytes32(attestationIdName: string): string { - const id = AttestationId[attestationIdName as keyof typeof AttestationId]; - console.log(`šŸ†” Attestation ID for ${attestationIdName}: ${id}`); - return id; - } - async function main() { - console.log("\n🌐 Setting up blockchain connection..."); - const provider = new ethers.JsonRpcProvider(process.env.CELO_ALFAJORES_RPC_URL as string); - console.log("āœ… Provider created"); - - const wallet = new ethers.Wallet(process.env.PRIVATE_KEY as string, provider); - console.log("āœ… Wallet created"); - console.log(` Wallet address: ${wallet.address}`); - - console.log("\nšŸ¢ Setting up hub contract..."); - const hubAddress = deployedAddresses["DeployHubV2#IdentityVerificationHub"]; - console.log("šŸ” Hub address lookup result:", hubAddress); + const provider = new ethers.JsonRpcProvider(RPC_URL as string); + const wallet = new ethers.Wallet(PRIVATE_KEY as string, provider); + console.log(`Wallet address: ${wallet.address}`); + const hubAddress = getContractAddress("DeployHubV2#IdentityVerificationHub", deployedAddresses); if (!hubAddress) { throw new Error("āŒ Hub address not found in deployed_addresses.json"); } - - const identityVerificationHub = new ethers.Contract(hubAddress, identityVerificationHubAbi, wallet); - console.log("āœ… Contract instance created"); + const identityVerificationHub = new ethers.Contract(hubAddress, hubABI, wallet); console.log(` Hub contract address: ${hubAddress}`); - // Update registry addresses for different attestation types - console.log("\nšŸ“ STEP 1: Updating registry addresses..."); - console.log("=========================================="); - const attestationTypes = ["E_PASSPORT", "EU_ID_CARD"]; - for (const attestationType of attestationTypes) { - console.log(`\nšŸ”„ Processing registry for ${attestationType}:`); - - let registryName: any; - if (attestationType == "E_PASSPORT") { - registryName = "DeployRegistryModule#IdentityRegistry"; - } else if (attestationType == "EU_ID_CARD") { - registryName = "DeployIdCardRegistryModule#IdentityRegistryIdCard"; - } - - console.log(` Registry name to search: ${registryName}`); - - const registryAddress = getContractAddressByExactName(registryName); - - if (!registryAddress) { - console.log(` āš ļø Skipping registry update for ${attestationType} because no deployed address was found.`); - continue; - } + let totalUpdates = 0; + let successfulUpdates = 0; - console.log(` šŸ“ Registry address found: ${registryAddress}`); - const attestationId = getAttestationIdBytes32(attestationType); + // Update VC and Disclose verifier for E_PASSPORT + if (setVerifiers.vcAndDisclose) { + log.step("Updating VC and Disclose verifier for E_PASSPORT"); try { - console.log(` šŸ“¤ Sending updateRegistry transaction...`); - const tx = await identityVerificationHub.updateRegistry(attestationId, registryAddress); - console.log(` ā³ Transaction sent: ${tx.hash}`); - console.log(` ā³ Waiting for confirmation...`); - const receipt = await tx.wait(); - console.log(` āœ… Registry for ${attestationType} updated successfully!`); - console.log(` Transaction hash: ${receipt.hash}`); - console.log(` Gas used: ${receipt.gasUsed}`); - } catch (error) { - console.error(` āŒ Error updating registry for ${attestationType}:`, error); - } - } - - // Update VC and Disclose circuit verifiers for different attestation types - console.log("\nšŸ“ STEP 2: Updating VC and Disclose circuit verifiers..."); - console.log("======================================================="); - for (const attestationType of attestationTypes) { - console.log(`\nšŸ”„ Processing VC verifier for ${attestationType}:`); - - let verifierName: any; - if (attestationType == "E_PASSPORT") { - verifierName = "DeployAllVerifiers#Verifier_vc_and_disclose"; - } else if (attestationType == "EU_ID_CARD") { - verifierName = "DeployAllVerifiers#Verifier_vc_and_disclose_id"; - } - - console.log(` Verifier name to search: ${verifierName}`); - const verifierAddress = getContractAddressByExactName(verifierName); - - if (!verifierAddress) { - console.log(` āš ļø Skipping VC and Disclose circuit update for ${attestationType} because no deployed address was found.`); - continue; - } - - console.log(` šŸ“ Verifier address found: ${verifierAddress}`); - const attestationId = getAttestationIdBytes32(attestationType); + const verifierAddress = getContractAddress("DeployAllVerifiers#Verifier_vc_and_disclose", deployedAddresses); + const attestationId = ATTESTATION_ID.E_PASSPORT; - try { - console.log(` šŸ“¤ Sending updateVcAndDiscloseCircuit transaction...`); + totalUpdates++; const tx = await identityVerificationHub.updateVcAndDiscloseCircuit(attestationId, verifierAddress); - console.log(` ā³ Transaction sent: ${tx.hash}`); - console.log(` ā³ Waiting for confirmation...`); const receipt = await tx.wait(); - console.log(` āœ… VC and Disclose circuit for ${attestationType} updated successfully!`); - console.log(` Transaction hash: ${receipt.hash}`); - console.log(` Gas used: ${receipt.gasUsed}`); - } catch (error) { - console.error(` āŒ Error updating VC and Disclose circuit for ${attestationType}:`, error); - } - } - // Batch update register circuit verifiers for E_PASSPORT - console.log("\nšŸ“ STEP 3: Batch updating register circuit verifiers for E_PASSPORT..."); - console.log("====================================================================="); - - console.log("šŸ” Discovering register verifiers..."); - const registerVerifierKeys = Object.keys(RegisterVerifierId).filter((key) => isNaN(Number(key))); - console.log(` Found ${registerVerifierKeys.length} register verifier keys in enum:`, registerVerifierKeys); - - // Filter out register_id keys for E_PASSPORT (they should only be used for EU_ID_CARD) - const regularRegisterKeys = registerVerifierKeys.filter(key => !key.startsWith('register_id_')); - console.log(` Filtered to ${regularRegisterKeys.length} regular register keys (excluding register_id_*):`, regularRegisterKeys); - - const registerAttestationIds: string[] = []; - const registerCircuitVerifierIds: number[] = []; - const registerCircuitVerifierAddresses: string[] = []; - - for (const key of regularRegisterKeys) { - console.log(`\n šŸ”„ Processing register verifier: ${key}`); - const verifierName = `Verifier_${key}`; - console.log(` Searching for: ${verifierName}`); - const verifierAddress = getContractAddressByPartialName(verifierName); - - if (!verifierAddress) { - console.log(` āŒ Skipping ${verifierName} because no deployed address was found.`); - continue; + log.success(`VC verifier for E_PASSPORT updated (tx: ${receipt.hash})`); + successfulUpdates++; + } catch (error) { + log.error(`Failed to update VC verifier for E_PASSPORT: ${error}`); } - - const verifierId = RegisterVerifierId[key as keyof typeof RegisterVerifierId]; - console.log(` āœ… Found verifier: ${verifierName} -> ${verifierAddress}`); - console.log(` šŸ“‹ Verifier ID: ${verifierId} (key: ${key})`); - - registerAttestationIds.push(AttestationId.E_PASSPORT); - registerCircuitVerifierIds.push(verifierId); - registerCircuitVerifierAddresses.push(verifierAddress as string); } - console.log(`\nšŸ“Š Register verifiers summary for E_PASSPORT:`); - console.log(` Total found: ${registerCircuitVerifierIds.length}`); - console.log(` Verifier IDs: [${registerCircuitVerifierIds.join(', ')}]`); - console.log(` Addresses: [${registerCircuitVerifierAddresses.map(addr => addr.slice(0, 10) + '...').join(', ')}]`); + // Update VC and Disclose ID verifier for EU_ID_CARD + if (setVerifiers.vcAndDiscloseId) { + log.step("Updating VC and Disclose ID verifier for EU_ID_CARD"); - if (registerCircuitVerifierIds.length > 0) { try { - console.log(`šŸ“¤ Sending batchUpdateRegisterCircuitVerifiers transaction for E_PASSPORT...`); - const tx = await identityVerificationHub.batchUpdateRegisterCircuitVerifiers( - registerAttestationIds, - registerCircuitVerifierIds, - registerCircuitVerifierAddresses, - ); - console.log(`ā³ Transaction sent: ${tx.hash}`); - console.log(`ā³ Waiting for confirmation...`); + const verifierAddress = getContractAddress("DeployAllVerifiers#Verifier_vc_and_disclose_id", deployedAddresses); + const attestationId = ATTESTATION_ID.EU_ID_CARD; + + totalUpdates++; + const tx = await identityVerificationHub.updateVcAndDiscloseCircuit(attestationId, verifierAddress); const receipt = await tx.wait(); - console.log(`āœ… Register circuit verifiers for E_PASSPORT updated successfully!`); - console.log(` Transaction hash: ${receipt.hash}`); - console.log(` Gas used: ${receipt.gasUsed}`); - } catch (error) { - console.error("āŒ Error batch updating register circuit verifiers for E_PASSPORT:", error); - } - } else { - console.log("āš ļø No register circuit verifiers found for E_PASSPORT"); - } - // Batch update register circuit verifiers for EU_ID_CARD (using register_id verifiers) - console.log("\nšŸ“ STEP 4: Batch updating register circuit verifiers for EU_ID_CARD..."); - console.log("===================================================================="); - - // Function to map register_id circuit names to their corresponding RegisterVerifierId - function getRegisterIdMapping(registerIdCircuitName: string): number | null { - console.log(` šŸ”„ Mapping register_id circuit: ${registerIdCircuitName}`); - - // The register_id circuits should have their own entries in the RegisterVerifierId enum - // Look for exact match first - if (registerIdCircuitName in RegisterVerifierId) { - const verifierId = RegisterVerifierId[registerIdCircuitName as keyof typeof RegisterVerifierId]; - console.log(` āœ… Found direct mapping: ${registerIdCircuitName} (ID: ${verifierId})`); - return verifierId as number; + log.success(`VC ID verifier for EU_ID_CARD updated (tx: ${receipt.hash})`); + successfulUpdates++; + } catch (error) { + log.error(`Failed to update VC ID verifier for EU_ID_CARD: ${error}`); } - - console.warn(` āŒ No RegisterVerifierId mapping found for: ${registerIdCircuitName}`); - return null; } - // Get all register_id verifiers from deployed addresses - console.log("šŸ” Discovering register_id verifiers..."); - const registerIdVerifiers: string[] = []; - for (const key of Object.keys(deployedAddresses)) { - if (key.includes("Verifier_register_id_")) { - const circuitName = key.replace("DeployAllVerifiers#Verifier_", ""); - registerIdVerifiers.push(circuitName); - console.log(` Found register_id verifier: ${circuitName}`); - } - } + // Batch update register circuit verifiers for E_PASSPORT + if (setVerifiers.register) { + log.step("Updating register circuit verifiers for E_PASSPORT"); - console.log(`šŸ“Š Found ${registerIdVerifiers.length} register_id verifier(s): [${registerIdVerifiers.join(', ')}]`); + const registerVerifierKeys = Object.keys(RegisterVerifierId).filter((key) => isNaN(Number(key))); + const regularRegisterKeys = registerVerifierKeys.filter(key => !key.startsWith('register_id_')); - const registerIdAttestationIds: string[] = []; - const registerIdCircuitVerifierIds: number[] = []; - const registerIdCircuitVerifierAddresses: string[] = []; + const registerAttestationIds: string[] = []; + const registerCircuitVerifierIds: number[] = []; + const registerCircuitVerifierAddresses: string[] = []; - for (const registerIdCircuitName of registerIdVerifiers) { - console.log(`\n šŸ”„ Processing register_id verifier: ${registerIdCircuitName}`); - const verifierName = `DeployAllVerifiers#Verifier_${registerIdCircuitName}`; - console.log(` Full verifier name: ${verifierName}`); - const verifierAddress = getContractAddressByExactName(verifierName); + for (const key of regularRegisterKeys) { + const verifierName = `Verifier_${key}`; + const verifierAddress = getContractAddressByPartialName(verifierName); - if (!verifierAddress) { - console.log(` āŒ Skipping ${verifierName} because no deployed address was found.`); - continue; - } + if (!verifierAddress) { + log.warning(`Skipping ${verifierName} - not found`); + continue; + } - const verifierId = getRegisterIdMapping(registerIdCircuitName); - if (verifierId === null) { - console.log(` āŒ Skipping ${registerIdCircuitName} because no RegisterVerifierId mapping was found.`); - continue; + const verifierId = RegisterVerifierId[key as keyof typeof RegisterVerifierId]; + registerAttestationIds.push(ATTESTATION_ID.E_PASSPORT); + registerCircuitVerifierIds.push(verifierId); + registerCircuitVerifierAddresses.push(verifierAddress); } - console.log(` āœ… Using register_id verifier: ${registerIdCircuitName} (ID: ${verifierId}) for EU_ID_CARD`); - console.log(` šŸ“ Address: ${verifierAddress}`); - - registerIdAttestationIds.push(AttestationId.EU_ID_CARD); - registerIdCircuitVerifierIds.push(verifierId); - registerIdCircuitVerifierAddresses.push(verifierAddress as string); - } - - console.log(`\nšŸ“Š Register_id verifiers summary for EU_ID_CARD:`); - console.log(` Total found: ${registerIdCircuitVerifierIds.length}`); - console.log(` Verifier IDs: [${registerIdCircuitVerifierIds.join(', ')}]`); - console.log(` Addresses: [${registerIdCircuitVerifierAddresses.map(addr => addr.slice(0, 10) + '...').join(', ')}]`); - - if (registerIdCircuitVerifierIds.length > 0) { - try { - console.log(`šŸ“¤ Sending batchUpdateRegisterCircuitVerifiers transaction for EU_ID_CARD...`); - const tx = await identityVerificationHub.batchUpdateRegisterCircuitVerifiers( - registerIdAttestationIds, - registerIdCircuitVerifierIds, - registerIdCircuitVerifierAddresses, - ); - console.log(`ā³ Transaction sent: ${tx.hash}`); - console.log(`ā³ Waiting for confirmation...`); - const receipt = await tx.wait(); - console.log(`āœ… Register circuit verifiers for EU_ID_CARD updated successfully!`); - console.log(` Transaction hash: ${receipt.hash}`); - console.log(` Gas used: ${receipt.gasUsed}`); - console.log(` Updated ${registerIdCircuitVerifierIds.length} verifier(s) with IDs: [${registerIdCircuitVerifierIds.join(', ')}]`); - } catch (error) { - console.error("āŒ Error batch updating register circuit verifiers for EU_ID_CARD:", error); + if (registerCircuitVerifierIds.length > 0) { + try { + totalUpdates++; + const tx = await identityVerificationHub.batchUpdateRegisterCircuitVerifiers( + registerAttestationIds, + registerCircuitVerifierIds, + registerCircuitVerifierAddresses, + ); + const receipt = await tx.wait(); + log.success(`Register verifiers for E_PASSPORT updated: ${registerCircuitVerifierIds.length} verifiers (tx: ${receipt.hash})`); + successfulUpdates++; + } catch (error) { + log.error(`Failed to update register verifiers for E_PASSPORT: ${error}`); + } + } else { + log.warning("No register circuit verifiers found for E_PASSPORT"); } - } else { - console.log("āš ļø No register_id circuit verifiers found to update for EU_ID_CARD"); } - // Batch update DSC circuit verifiers for E_PASSPORT - console.log("\nšŸ“ STEP 5: Batch updating DSC circuit verifiers for E_PASSPORT..."); - console.log("==============================================================="); - - console.log("šŸ” Discovering DSC verifiers..."); - const dscKeys = Object.keys(DscVerifierId).filter((key) => isNaN(Number(key))); - console.log(` Found ${dscKeys.length} DSC verifier keys in enum:`, dscKeys); - - const dscAttestationIds: string[] = []; - const dscCircuitVerifierIds: number[] = []; - const dscCircuitVerifierAddresses: string[] = []; - - for (const key of dscKeys) { - console.log(`\n šŸ”„ Processing DSC verifier: ${key}`); - const verifierName = `Verifier_${key}`; - console.log(` Searching for: ${verifierName}`); - const verifierAddress = getContractAddressByPartialName(verifierName); - - if (!verifierAddress) { - console.log(` āŒ Skipping ${verifierName} because no deployed address was found.`); - continue; + // Batch update register circuit verifiers for EU_ID_CARD (using register_id verifiers) + if (setVerifiers.registerId) { + log.step("Updating register_id circuit verifiers for EU_ID_CARD"); + + // Get all register_id verifiers from deployed addresses + const registerIdVerifiers: string[] = []; + for (const key of Object.keys(deployedAddresses)) { + if (key.includes("Verifier_register_id_")) { + const circuitName = key.replace("DeployAllVerifiers#Verifier_", ""); + registerIdVerifiers.push(circuitName); + } } - const verifierId = DscVerifierId[key as keyof typeof DscVerifierId]; - console.log(` āœ… Found verifier: ${verifierName} -> ${verifierAddress}`); - console.log(` šŸ“‹ Verifier ID: ${verifierId}`); - - dscAttestationIds.push(AttestationId.E_PASSPORT); - dscCircuitVerifierIds.push(verifierId); - dscCircuitVerifierAddresses.push(verifierAddress as string); - } - - console.log(`\nšŸ“Š DSC verifiers summary for E_PASSPORT:`); - console.log(` Total found: ${dscCircuitVerifierIds.length}`); - console.log(` Verifier IDs: [${dscCircuitVerifierIds.join(', ')}]`); - console.log(` Addresses: [${dscCircuitVerifierAddresses.map(addr => addr.slice(0, 10) + '...').join(', ')}]`); - - if (dscCircuitVerifierIds.length > 0) { - try { - console.log(`šŸ“¤ Sending batchUpdateDscCircuitVerifiers transaction for E_PASSPORT...`); - const tx = await identityVerificationHub.batchUpdateDscCircuitVerifiers( - dscAttestationIds, - dscCircuitVerifierIds, - dscCircuitVerifierAddresses, - ); - console.log(`ā³ Transaction sent: ${tx.hash}`); - console.log(`ā³ Waiting for confirmation...`); - const receipt = await tx.wait(); - console.log(`āœ… DSC circuit verifiers for E_PASSPORT updated successfully!`); - console.log(` Transaction hash: ${receipt.hash}`); - console.log(` Gas used: ${receipt.gasUsed}`); - } catch (error) { - console.error("āŒ Error batch updating DSC circuit verifiers for E_PASSPORT:", error); + const registerIdAttestationIds: string[] = []; + const registerIdCircuitVerifierIds: number[] = []; + const registerIdCircuitVerifierAddresses: string[] = []; + + for (const registerIdCircuitName of registerIdVerifiers) { + const verifierName = `DeployAllVerifiers#Verifier_${registerIdCircuitName}`; + + try { + const verifierAddress = getContractAddress(verifierName, deployedAddresses); + + // Map circuit name to RegisterVerifierId + if (registerIdCircuitName in RegisterVerifierId) { + const verifierId = RegisterVerifierId[registerIdCircuitName as keyof typeof RegisterVerifierId]; + registerIdAttestationIds.push(ATTESTATION_ID.EU_ID_CARD); + registerIdCircuitVerifierIds.push(verifierId as number); + registerIdCircuitVerifierAddresses.push(verifierAddress); + } else { + log.warning(`No RegisterVerifierId mapping found for: ${registerIdCircuitName}`); + } + } catch (error) { + log.warning(`Skipping ${verifierName} - not found`); + } } - } else { - console.log("āš ļø No DSC circuit verifiers found for E_PASSPORT"); - } - // Batch update DSC circuit verifiers for EU_ID_CARD - console.log("\nšŸ“ STEP 6: Batch updating DSC circuit verifiers for EU_ID_CARD..."); - console.log("==============================================================="); - - const dscIdAttestationIds: string[] = []; - const dscIdCircuitVerifierIds: number[] = []; - const dscIdCircuitVerifierAddresses: string[] = []; - - for (const key of dscKeys) { - console.log(`\n šŸ”„ Processing DSC verifier for EU_ID_CARD: ${key}`); - const verifierName = `Verifier_${key}`; - console.log(` Searching for: ${verifierName}`); - const verifierAddress = getContractAddressByPartialName(verifierName); - - if (!verifierAddress) { - console.log(` āŒ Skipping ${verifierName} because no deployed address was found.`); - continue; + if (registerIdCircuitVerifierIds.length > 0) { + try { + totalUpdates++; + const tx = await identityVerificationHub.batchUpdateRegisterCircuitVerifiers( + registerIdAttestationIds, + registerIdCircuitVerifierIds, + registerIdCircuitVerifierAddresses, + ); + const receipt = await tx.wait(); + log.success(`Register_id verifiers for EU_ID_CARD updated: ${registerIdCircuitVerifierIds.length} verifiers (tx: ${receipt.hash})`); + successfulUpdates++; + } catch (error) { + log.error(`Failed to update register_id verifiers for EU_ID_CARD: ${error}`); + } + } else { + log.warning("No register_id circuit verifiers found for EU_ID_CARD"); } - - const verifierId = DscVerifierId[key as keyof typeof DscVerifierId]; - console.log(` āœ… Found verifier: ${verifierName} -> ${verifierAddress}`); - console.log(` šŸ“‹ Verifier ID: ${verifierId}`); - - dscIdAttestationIds.push(AttestationId.EU_ID_CARD); - dscIdCircuitVerifierIds.push(verifierId); - dscIdCircuitVerifierAddresses.push(verifierAddress as string); } - console.log(`\nšŸ“Š DSC verifiers summary for EU_ID_CARD:`); - console.log(` Total found: ${dscIdCircuitVerifierIds.length}`); - console.log(` Verifier IDs: [${dscIdCircuitVerifierIds.join(', ')}]`); - console.log(` Addresses: [${dscIdCircuitVerifierAddresses.map(addr => addr.slice(0, 10) + '...').join(', ')}]`); - - if (dscIdCircuitVerifierIds.length > 0) { - try { - console.log(`šŸ“¤ Sending batchUpdateDscCircuitVerifiers transaction for EU_ID_CARD...`); - const tx = await identityVerificationHub.batchUpdateDscCircuitVerifiers( - dscIdAttestationIds, - dscIdCircuitVerifierIds, - dscIdCircuitVerifierAddresses, - ); - console.log(`ā³ Transaction sent: ${tx.hash}`); - console.log(`ā³ Waiting for confirmation...`); - const receipt = await tx.wait(); - console.log(`āœ… DSC circuit verifiers for EU_ID_CARD updated successfully!`); - console.log(` Transaction hash: ${receipt.hash}`); - console.log(` Gas used: ${receipt.gasUsed}`); - } catch (error) { - console.error("āŒ Error batch updating DSC circuit verifiers for EU_ID_CARD:", error); + // Batch update DSC circuit verifiers + if (setVerifiers.dsc) { + log.step("Updating DSC circuit verifiers"); + + const dscKeys = Object.keys(DscVerifierId).filter((key) => isNaN(Number(key))); + + // Update for both E_PASSPORT and EU_ID_CARD + const attestationTypes = ["E_PASSPORT", "EU_ID_CARD"] as const; + + for (const attestationType of attestationTypes) { + const dscAttestationIds: string[] = []; + const dscCircuitVerifierIds: number[] = []; + const dscCircuitVerifierAddresses: string[] = []; + + for (const key of dscKeys) { + const verifierName = `Verifier_${key}`; + const verifierAddress = getContractAddressByPartialName(verifierName); + + if (!verifierAddress) { + log.warning(`Skipping ${verifierName} - not found`); + continue; + } + + const verifierId = DscVerifierId[key as keyof typeof DscVerifierId]; + dscAttestationIds.push(ATTESTATION_ID[attestationType]); + dscCircuitVerifierIds.push(verifierId); + dscCircuitVerifierAddresses.push(verifierAddress); + } + + if (dscCircuitVerifierIds.length > 0) { + try { + totalUpdates++; + const tx = await identityVerificationHub.batchUpdateDscCircuitVerifiers( + dscAttestationIds, + dscCircuitVerifierIds, + dscCircuitVerifierAddresses, + ); + const receipt = await tx.wait(); + log.success(`DSC verifiers for ${attestationType} updated: ${dscCircuitVerifierIds.length} verifiers (tx: ${receipt.hash})`); + successfulUpdates++; + } catch (error) { + log.error(`Failed to update DSC verifiers for ${attestationType}: ${error}`); + } + } else { + log.warning(`No DSC circuit verifiers found for ${attestationType}`); + } } - } else { - console.log("āš ļø No DSC circuit verifiers found for EU_ID_CARD"); } - console.log("\nšŸŽ‰ Script execution completed!"); - console.log("==============================="); + log.info(`Verifier update summary: ${successfulUpdates}/${totalUpdates} successful`); } main().catch((error) => { - console.error("šŸ’„ Execution error:", error); - if (error.reason) console.error(" Reason:", error.reason); - if (error.code) console.error(" Code:", error.code); - if (error.transaction) console.error(" Transaction:", error.transaction); + log.error(`Execution failed: ${error}`); + if (error.reason) log.error(`Reason: ${error.reason}`); process.exitCode = 1; }); } catch (error) { - console.error("šŸ’„ Initial setup error:", error); + log.error(`Setup failed: ${error}`); process.exitCode = 1; } From 93e8d5f92c291c71d192e790d0255615d2a843fd Mon Sep 17 00:00:00 2001 From: berZKerk Date: Sat, 16 Aug 2025 09:38:24 +0200 Subject: [PATCH 2/3] Update utils.ts --- app/src/utils/utils.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/utils/utils.ts b/app/src/utils/utils.ts index 24eb492f7..954fb4037 100644 --- a/app/src/utils/utils.ts +++ b/app/src/utils/utils.ts @@ -48,6 +48,11 @@ export function extractMRZInfo(mrzString: string) { // Function to format date from 'YYYY-MM-DD 00:00:00 +0000' to 'YYMMDD' export function formatDateToYYMMDD(inputDate: string) { + // Validate input string length to prevent substring errors + if (!inputDate || inputDate.length < 10) { + throw new Error('Invalid date format: input string must be at least 10 characters long'); + } + // 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 From 6b59e01b3c868a5f0b58276da9d54b8f673dce88 Mon Sep 17 00:00:00 2001 From: berZKerk Date: Tue, 26 Aug 2025 13:11:01 +0200 Subject: [PATCH 3/3] Update utils.ts --- app/src/utils/utils.ts | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/app/src/utils/utils.ts b/app/src/utils/utils.ts index 954fb4037..c36358b85 100644 --- a/app/src/utils/utils.ts +++ b/app/src/utils/utils.ts @@ -6,7 +6,7 @@ export function extractMRZInfo(mrzString: string) { //line 1 and line 2 - concated const TD1_REGEX = - /^(?[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})/; + /^([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'); @@ -46,20 +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) { - // Validate input string length to prevent substring errors - if (!inputDate || inputDate.length < 10) { - throw new Error('Invalid date format: input string must be at least 10 characters long'); + if (!inputDate) { + throw new Error('Invalid date format: input string cannot be empty'); } - // 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 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(