@zkportal/zk-verifier
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

zk-verifier

A WebAssembly library for verifying zero-knowledge proofs from zkPortal.

This library is derived from ark-circom.

Proof verification function is exported and compiled into a WebAssembly module using wasm-pack.

Usage

import init, { verify_proof } from '@zkportal/zk-verifier';

async function verify() {
  await init(); // uses bundled WebAssembly module, you can also provide an argument, see API section of the README
  const verifyingKey = Uint8Array.from(...);
  const proof = Uint8Array.from(...);
  const publicInputs = Uint8Array.from(...);
  const success = verify_proof(verifyingKey, proof, publicInputs);
}

API

Function Description Arguments Return Other
init Initialize the module One of:
  • undefined to use bundled WebAssembly module
  • string with WebAssembly module URL
  • URL
  • Fetch API Request
  • Fetch API Response
  • BufferSource
  • WebAssembly.Module
  • Promise of any type above
Promise<any> Default export
verify_proof Verify a proof using a proof, verifying key, and public inputs
  • verifying_keyUint8Array
  • proofUint8Array
  • public_inputsUint8Array
boolean - verification success Destructured export

Examples

Examples provide the following files:

  • proof.json - contains serialized decimal bytes of a zero-knowledge proof
  • public_inputs.json - contains serialized decimal bytes of public inputs you need to supply to verify the proof

If you use a bundler, then you can import those files, then create Uint8Array arrays from them and supply to verify_proof function.

  • Banlist This directory contains JSON files with serialized inputs you can use to verify that supplied country code "NL" is not in the list of banned countries "KP RU IR SO".
  • Minimum age This directory contains JSON files with serialized inputs you can use to verify that supplied user's date of birth is earlier than the date of minimum age.

/@zkportal/zk-verifier/

    Package Sidebar

    Install

    npm i @zkportal/zk-verifier

    Weekly Downloads

    0

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    232 kB

    Total Files

    8

    Last publish

    Collaborators

    • whyamiroot
    • zkportal-admin