βœ…How to consume proofs?

β˜‘οΈ Easiest & Most Reliable Way: Use the ID-Mask App

The recommended way to consume proofs is through the ID-Mask app:

  1. Open idmask.xyz on your device. Go to 'Verify' > 'QR Code'.

  2. Optionally precompile the proofs you're about to consume in the settings.

  3. Use the built-in scanner to scan the user’s pass QR code from their wallet.

  4. The app handles all cryptographic verification and ensures the pass actually belongs to the user by checking their passkey signature.

This is the only method that guarantees:

  • The proof is cryptographically valid.

  • The pass is truly owned by the person presenting it.

πŸ§‘β€πŸ’» Advanced: Programmatic Proof Verification

npm i idmask-zk-programs

To verify user provided JSON proof:

import { verify } from 'o1js'
import { proofOfAge } from 'idmask-zk-programs'

// this is a user supplied JSON proof
const proof = {
  publicInput: ["21"],
  publicOutput: [...],
  maxProofsVerified: 0,
  proof: "KChzdGF...KSkpKSkp"
}
const { verificationKey } = await proofOfAge.compile()
const isProofValid = await verify(proof, verificationKey)

console.log(
  `Is proof valid? ${isProofValid}`,
  `Proof of age of at least ${proof.publicInput[0]} years`
)

πŸ§‘β€πŸ’» Advanced: Check if provided public address has an associated proof

// user Mina address
const address = 'B62qqgtZqqnDr7BzyNnYguqnHQnpMDyTSEYfWj4r1qkEYcfvszkp8zt' 
const graphQLArchiveNodeUrl = 'https://berkeley.graphql.minaexplorer.com/'
const zkAppAddress = 'B62qqpAFkz374qJpuFKYZPjT1KxSmnLoY4zEc878FaW4DSxgYNXZiny'

const response = await fetch(graphQLArchiveNodeUrl, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    query: `
      query MyQuery {
        events(query: {
          zkAppCommandHash: {
            zkappCommand: {
              accountUpdates: {
                body: {publicKey: "${zkAppAddress}"}
              },
              feePayer: {
                body: {
                  publicKey: "${address}"
                }
              }
            }
          },
          canonical: true
        }) {
          dateTime
          event
          zkAppCommandHash {
            zkappCommand {
              feePayer {
                body {
                  publicKey
                }
              }
            }
          }
        }
      }
    `,
  }),
})
const response_ = await response.json()

const hasProof = response_.data.events.length > 0

console.log(
  `Address has an asocaited proof? ${hasProof}`,
  `Age of at least ${response_.data.events[0].event[0]}`
)

Last updated