mirror of
https://github.com/selfxyz/self.git
synced 2026-04-05 03:00:53 -04:00
handling pubkey not found in registry
This commit is contained in:
@@ -4,6 +4,7 @@ import { generateCircuitInputs } from '../../../common/src/utils/generateInputs'
|
||||
import { formatProof, formatInputs } from '../../../common/src/utils/utils';
|
||||
import { Steps } from './utils';
|
||||
import { PassportData } from '../../../common/src/utils/types';
|
||||
import Toast from 'react-native-toast-message';
|
||||
|
||||
interface ProverProps {
|
||||
passportData: PassportData | null;
|
||||
@@ -39,25 +40,35 @@ export const prove = async ({
|
||||
// return;
|
||||
// }
|
||||
|
||||
const inputs = generateCircuitInputs(
|
||||
passportData,
|
||||
reveal_bitmap,
|
||||
address,
|
||||
{ developmentMode: false }
|
||||
);
|
||||
try {
|
||||
const inputs = generateCircuitInputs(
|
||||
passportData,
|
||||
reveal_bitmap,
|
||||
address,
|
||||
{ developmentMode: false }
|
||||
);
|
||||
|
||||
Object.keys(inputs).forEach((key) => {
|
||||
if (Array.isArray(inputs[key as keyof typeof inputs])) {
|
||||
console.log(key, inputs[key as keyof typeof inputs].slice(0, 10), '...');
|
||||
} else {
|
||||
console.log(key, inputs[key as keyof typeof inputs]);
|
||||
}
|
||||
});
|
||||
Object.keys(inputs).forEach((key) => {
|
||||
if (Array.isArray(inputs[key as keyof typeof inputs])) {
|
||||
console.log(key, inputs[key as keyof typeof inputs].slice(0, 10), '...');
|
||||
} else {
|
||||
console.log(key, inputs[key as keyof typeof inputs]);
|
||||
}
|
||||
});
|
||||
|
||||
const start = Date.now();
|
||||
await generateProof(inputs, setProofTime, setProof, setGeneratingProof, setStep, path);
|
||||
const end = Date.now();
|
||||
console.log('Total proof time from frontend:', end - start);
|
||||
const start = Date.now();
|
||||
await generateProof(inputs, setProofTime, setProof, setGeneratingProof, setStep, path);
|
||||
const end = Date.now();
|
||||
console.log('Total proof time from frontend:', end - start);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
Toast.show({
|
||||
type: 'error',
|
||||
text1: "Pubkey not found in the registry",
|
||||
});
|
||||
setStep(Steps.NFC_SCAN_COMPLETED);
|
||||
setGeneratingProof(false);
|
||||
}
|
||||
};
|
||||
|
||||
const generateProof = async (
|
||||
|
||||
@@ -51,6 +51,9 @@ 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");
|
||||
}
|
||||
|
||||
const proof = tree.createProof(index)
|
||||
console.log("verifyProof", tree.verifyProof(proof))
|
||||
|
||||
Reference in New Issue
Block a user