Generate and submit ZK proof
/**
* Get prover data (separately loaded because the large json should not slow down initial site loading).
*
* @param path - Path to the prover data json file (relative to the public folder).
* @returns JSON object with the prover data.
*/
export async function getProver(path: string) {
const proverText = await fetch(path);
const parsedFile = JSON.parse(await proverText.text());
return parsedFile;
}const provider = new ethers.providers.Web3Provider(window.ethereum);
// fetch institution pubkey from chain because it is needed as proof input
const institutionContract = new ethers.Contract(
institutionAddresses,
galacticaInstitutionABI.abi,
provider.getSigner(),
);
const institutionPubKeys: [string, string][] = [[
BigNumber.from(await institutionContract.institutionPubKey(0)).toString(),
BigNumber.from(await institutionContract.institutionPubKey(1)).toString(),
]];
const proofInput: any = {
// general zkKYC inputs
currentTime: await getCurrentBlockTime(),
dAppAddress,
investigationInstitutionPubKey: institutionPubKeys,
// specific inputs to prove that the holder is at least 18 years old
currentYear: dateNow.getUTCFullYear().toString(),
currentMonth: (dateNow.getUTCMonth() + 1).toString(),
currentDay: dateNow.getUTCDate().toString(),
ageThreshold: '18',
// the zkKYC itself is not needed here. It is filled by the snap for user privacy.
};Last updated