Skip to content

Submit proof

Important

Before submitting proof, ensure that holder has generated proof.

The generated proof is then submitted to the Receptor Smart Contract using the submitZKPResponse function which allows you to interact with the contract for verification.

To implement the submitZKPResponse add the following code block.

const provider = new ethers.JsonRpcProvider(<Networks_RPC_URL>);
const wallet = new ethers.Wallet(<Wallet_Private_Key>, provider);
const contract = new ethers.Contract(
  <Verifier_Smart_Contract_Address>,
  <Verifier_Smart_Contract_ABI>,
  wallet
);

const tx = await contract.submitZKPResponse(
  proof?.id,
  stringArrayToBigIntArray(proof?.pub_signals),
  stringArrayToBigIntArray([proof?.proof?.pi_a[0], proof.proof?.pi_a[1]]),
  [
    stringArrayToBigIntArray([
      proof.proof?.pi_b[0][1],
      proof.proof?.pi_b[0][0],
    ]),
    stringArrayToBigIntArray([
      proof.proof?.pi_b[1][1],
      proof.proof?.pi_b[1][0],
    ]),
  ],
  stringArrayToBigIntArray([proof.proof?.pi_c[0], proof.proof?.pi_c[1]])
);
await tx.wait();

Next Steps

 const proofStatus = await contract.proofs(wallet.address, proof.id)

Finally, Receptor Smart Contract executes a check for validity and provides verification for the proof submitted and display's if verification is successful or not.