From 22711761604a83e9f33338fb5c08668debe9b4d1 Mon Sep 17 00:00:00 2001 From: turnoffthiscomputer Date: Sun, 9 Mar 2025 22:46:34 +0100 Subject: [PATCH] add staging commitment tree url --- app/src/utils/proving/inputs.ts | 2 +- app/src/utils/proving/payload.ts | 2 +- common/src/utils/trees.ts | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/utils/proving/inputs.ts b/app/src/utils/proving/inputs.ts index de7044879..df3d5441e 100644 --- a/app/src/utils/proving/inputs.ts +++ b/app/src/utils/proving/inputs.ts @@ -87,7 +87,7 @@ export async function generateTeeInputsVCAndDisclose( const { passportNoAndNationalitySMT, nameAndDobSMT, nameAndYobSMT } = await getOfacSMTs(); - const serialized_tree = await getCommitmentTree(); + const serialized_tree = await getCommitmentTree(passportData.documentType); const tree = LeanIMT.import((a, b) => poseidon2([a, b]), serialized_tree); console.log('tree', tree); // const commitment = generateCommitment( diff --git a/app/src/utils/proving/payload.ts b/app/src/utils/proving/payload.ts index 504ba043f..3c6a820b3 100644 --- a/app/src/utils/proving/payload.ts +++ b/app/src/utils/proving/payload.ts @@ -206,7 +206,7 @@ export async function isUserRegistered( PASSPORT_ATTESTATION_ID, passportData, ); - const serializedTree = await getCommitmentTree(); + const serializedTree = await getCommitmentTree(passportData.documentType); const tree = LeanIMT.import((a, b) => poseidon2([a, b]), serializedTree); const index = tree.indexOf(BigInt(commitment)); return index !== -1; diff --git a/common/src/utils/trees.ts b/common/src/utils/trees.ts index a2f25900d..0c511b6b2 100644 --- a/common/src/utils/trees.ts +++ b/common/src/utils/trees.ts @@ -8,7 +8,7 @@ import { import { packBytesAndPoseidon } from './hash'; import { DscCertificateMetaData, parseDscCertificateData } from './passports/passport_parsing/parseDscCertificateData'; import { parseCertificateSimple } from './certificate_parsing/parseCertificateSimple'; -import { CSCA_TREE_DEPTH, CSCA_TREE_URL_STAGING, DSC_TREE_DEPTH, DSC_TREE_URL_STAGING, IDENTITY_TREE_URL, max_csca_bytes, OFAC_TREE_LEVELS } from '../constants/constants'; +import { CSCA_TREE_DEPTH, CSCA_TREE_URL_STAGING, DSC_TREE_DEPTH, DSC_TREE_URL_STAGING, IDENTITY_TREE_URL, IDENTITY_TREE_URL_STAGING, max_csca_bytes, OFAC_TREE_LEVELS } from '../constants/constants'; import { CSCA_TREE_URL, DSC_TREE_URL } from '../constants/constants'; import { max_dsc_bytes } from '../constants/constants'; import { IMT } from '@openpassport/zk-kit-imt'; @@ -16,6 +16,7 @@ import { pad } from './passports/passport'; import countries from "i18n-iso-countries"; import en from "i18n-iso-countries/langs/en.json"; import { EndpointType } from './appType'; +import { DocumentType } from './types'; countries.registerLocale(en); export async function getCSCATree(endpointType: EndpointType): Promise { @@ -45,8 +46,9 @@ export async function getDSCTree(endpointType: EndpointType): Promise { return tree; } -export async function getCommitmentTree(): Promise { - const response = await fetch(IDENTITY_TREE_URL); +export async function getCommitmentTree(documentType: DocumentType | null): Promise { + const identityTreeUrl = documentType === null || documentType === 'passport' ? IDENTITY_TREE_URL : IDENTITY_TREE_URL_STAGING; + const response = await fetch(identityTreeUrl); return await response.json().then(data => data.data ? data.data : data); }