Smart Contracts

Smart contracts of DApps on Galactica are based on the Ethereum Virtual Machine (EVM). So developers can utilize the same libraries, frameworks and IDEs as on Ethereum.

This part of the documentation focuses on how to integrate Galactica specific features into smart contracts.

ZkKYC Integration

Integrating zkKYC in a DApp can be achieved by the following steps:

  1. Check if the user already passed the compliance check: To attest that users already have completed a ZkKYC verification with a DApp, they can receive a Verification SBT. If it is already present and still valid (version and expiration date), the following steps (3. and 4.) can be skipped. Verification SBTs can be queried from the Verification SBT contract.

  2. Call verifier: To verify a ZKP submitted by the user, the following two points need to be done. You can check Example zkKYC AgeProof contract as a reference.

    1. Verification of the ZKP in itself. This is done by the smart contract compiled from the circom2 circuits. It checks that the ZKP submitted by the user is a valid solution for the ZK circuit that generated the verifier. It should look similar to Example ZKP verifier contract.

    2. Check on-chain consistency. Because the ZKP itself has no access to the outside world, the consistency of it's parameters needs to be checked against the on-chain state. The public inputs of the ZKP disclose these parameters. This includes the root of the Merkle tree that supposedly includes the user's zkKYC, public keys of the fraud investigation institutions, and custom selective disclosures.

  3. Create the verification SBT after a successful verification by adding it to the Verification SBT contract. This gives the user an on-chain attestation of passing the checks in step 3. Furthermore the verification SBT can also publish encrypted logs for the Fraud investigation process.

  4. After checking the points above for compliance with zkKYC, the user can proceed with the DApp logic.

Example DApp

The zkKYC repository includes an example smart contract DApp that you can use as a reference. It implements an airdrop use case that requires a zkKYC and age proof from recipients.

Last updated