From d4bfb35d534d230f47efa81bdd6b21b24734e8bc Mon Sep 17 00:00:00 2001 From: 0xturboblitz Date: Mon, 25 Mar 2024 08:25:38 -0700 Subject: [PATCH] handle unsupported number of datagroups --- app/src/utils/prover.ts | 4 ++-- common/src/utils/generateInputs.ts | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/utils/prover.ts b/app/src/utils/prover.ts index 4792e4f44..2a5c42446 100644 --- a/app/src/utils/prover.ts +++ b/app/src/utils/prover.ts @@ -60,11 +60,11 @@ export const prove = async ({ await generateProof(inputs, setProofTime, setProof, setGeneratingProof, setStep, path); const end = Date.now(); console.log('Total proof time from frontend:', end - start); - } catch (error) { + } catch (error: any) { console.error(error); Toast.show({ type: 'error', - text1: "Pubkey not found in the registry", + text1: error.message, }); setStep(Steps.NFC_SCAN_COMPLETED); setGeneratingProof(false); diff --git a/common/src/utils/generateInputs.ts b/common/src/utils/generateInputs.ts index ce7afce7a..939c262e5 100644 --- a/common/src/utils/generateInputs.ts +++ b/common/src/utils/generateInputs.ts @@ -52,12 +52,17 @@ export function generateCircuitInputs( const index = tree.indexOf(leaf) // this index is not the index in public_keys_parsed.json, but the index in the tree console.log(`Index of pubkey in the registry: ${index}`) if (index === -1) { - throw new Error("Pubkey not found in the registry"); + throw new Error("Your public key was not found in the registry"); } const proof = tree.createProof(index) console.log("verifyProof", tree.verifyProof(proof)) + if (passportData.dataGroupHashes.length > MAX_DATAHASHES_LEN) { + console.log(`Data hashes too long. Max length is ${MAX_DATAHASHES_LEN} bytes.`); + throw new Error(`This number of datagroups is currently unsupported. Please contact us so we add support!`); + } + const [messagePadded, messagePaddedLen] = sha256Pad( new Uint8Array(passportData.dataGroupHashes), MAX_DATAHASHES_LEN