2.0.0 • Published 1 year ago

@zkportal/zk-verifier v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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

FunctionDescriptionArgumentsReturnOther
initInitialize the moduleOne of: undefined to use bundled WebAssembly modulestring with WebAssembly module URLURLFetch API RequestFetch API ResponseBufferSourceWebAssembly.ModulePromise of any type abovePromise<any>Default export
verify_proofVerify a proof using a proof, verifying key, and public inputsverifying_key:  Uint8Arrayproof:  Uint8Arraypublic_inputs:  Uint8Arrayboolean - verification successDestructured 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.