UnsignedProofGenerator class

This class is defined in ozki-lib, and used by the user (prover) to create a zk-snark proof which is not signed.

The UnsignedProofGenerator is an abstract class which is defined below. This is the type used to generate an unsigned proof.

export abstract class UnsignedProofGenerator<Type> extends BaseProofGenerator<Type> {
  constructor(
      zkpComponentPath: string,
      zkpComponentName: string
      ) {
      super(zkpComponentPath, zkpComponentName);
  }

  // the subclass needs to implement this method 
  // to format caller-specific input parameters
  // protected abstract formatCustomInput(customInput: Type): object

  protected formatRequiredInput(proofTimeStamp: number): object {
    const zkutils = new ZkUtils();
    let obj = {
      ts: zkutils.numberToBytes(proofTimeStamp, 4) // timestamp (4 bytes)
    }
    return obj;
  }

  generateProof = async (
    proofTimeStamp: number,
    customInput: Type
  ): Promise<[string, string]> => {
       ... deleted for clarity...   
  }
}

There are two simple steps to use this class:

  1. Subclass the ProofGenerator class with your own specific <Type> that defines the custom input which you use for the circom prove function. Implement the formatCustomInput method which takes the <Type> object and formats it for the circom prove function.

  2. Instantiate the proof generator subclass, and call the generateProof function to create a zk-snark proof. This method takes 3 params: the digital signature of the input parameters, the proof timestamp, and the custom input specific to your circom function.

Last updated