Interface PCDPackage<C, P, A, I>

Each type of PCD has a corresponding PCDPackage. The PCDPackage of a PCD type defines the code necessary to derive meaning from and operate on the data within a PCD.

Type Param

C the type of PCD.claim for the PCD encapsulated by this PCDPackage

Type Param

P the type of PCD.proof for the PCD encapsulated by this PCDPackage

Type Param

A - the type of the arguments passed into PCDPackage#prove to instantiate a new PCD. It is important that A can be serialized and deserialized using {@code JSON.stringify} {@code JSON.parse}, because these arguments should be able to be passed over the wire trivially. This may cause the type of A to be less convenient that desired. Eg. you may have to pass {@code BigInt}s in as strings, etc. Another important note about A is that each of its fields must implement the Argument interface. This is important because it enables Zupass to introspect the arguments, and to implement useful features like the {@code GenericProveScreen}, which is a screen that automatically builds a UI which lets a user input all the arguments required to instantiate a new instance of a particular PCD based on the request it gets from a third party.

Typeparam

I the type of the arguments passed into PCDPackage#init, if the init function is present to instantiate a new PCD

interface PCDPackage<C, P, A, I> {
    getDisplayOptions?: ((pcd) => DisplayOptions);
    getProveDisplayOptions?: (() => ProveDisplayOptions<A>);
    init?: ((initArgs) => Promise<void>);
    name: string;
    deserialize(seralized): Promise<PCD<C, P>>;
    prove(args): Promise<PCD<C, P>>;
    serialize(pcd): Promise<SerializedPCD<PCD<C, P>>>;
    verify(pcd): Promise<boolean>;
}

Type Parameters

  • C = any
  • P = any
  • A extends Record<string, Argument<any>> = any
  • I = any

Properties

getDisplayOptions?: ((pcd) => DisplayOptions)

Intended for use by Zupass. Given a PCD, returns some information about how this PCD should be displayed to the user within Zupass app.

Type declaration

getProveDisplayOptions?: (() => ProveDisplayOptions<A>)

Given the arguments passed into PCDPackage#prove, returns options on how to render the Prove Screen for this PCDPackage.

Type declaration

init?: ((initArgs) => Promise<void>)

Initializes this PCDPackage so that it can be used in the current context. This is an optional field, because not all packages need to be initialized.

Type declaration

    • (initArgs): Promise<void>
    • Parameters

      • initArgs: I

      Returns Promise<void>

name: string

The unique name identifying the type of PCD this package encapsulates.

Methods

  • This is effectively a factory for instances of the PCD that this PCDPackage encapsulates. It generates a proof and derives a claim from the args, and returns a new PCD instance.

    Parameters

    • args: A

    Returns Promise<PCD<C, P>>

  • Serializes an instance of this package's PCD so that it can be stored on disk or sent over a network.

    More concretely, this function returns a promise of SerializedPCD<PCD<C, P>> and PCDPackage.deserialize takes SerializedPCD<PCD<C, P>>.pcd as a parameter and returns an instance of PCD<C, P>.

    Parameters

    Returns Promise<SerializedPCD<PCD<C, P>>>

  • This function lets consumers of the PCD encapsulated by this PCDPackage verify whether the PCD's PCD#claim corresponds correctly to its PCD#proof.

    Parameters

    Returns Promise<boolean>

Generated using TypeDoc