Hierarchy

  • Versioned
    • PresentationBuilder

Constructors

Properties

_context?: string

This can specify the reason why the proof was created, or date of the proof, or self-attested attributes (as JSON string), etc

_nonce?: Uint8Array

To prevent replay attack

_version: string
attributeEqualities: AttributeEquality[]

Attributes proved equal in zero knowledge

attributeInequalities: Map<number, Map<string, [IPresentedAttributeInequality, Uint8Array][]>>

Attributes proved inequal to a public value in zero knowledge. An attribute can be proven inequal to any number of values The 2nd item, i.e. Uint8Array in the pair is the encoded value of the public value with which inequality is proved

blindCredReq?: {
    attributeInequalities: Map<string, [IPresentedAttributeInequality, Uint8Array][]>;
    attrNameToIndex: Map<string, number>;
    blinding?: Uint8Array;
    bounds: Map<string, IPresentedAttributeBound[]>;
    circPred: IProverCircomPredicate[];
    encodedAttributes: Map<number, Uint8Array>;
    flattenedSchema: FlattenedSchema;
    pseudonyms: IProverBoundedPseudonymInBlindedCredReq[];
    req: IBlindCredentialRequest;
    sigParams: SignatureParams;
    verifEnc: Map<string, IPresentedAttributeVE[]>;
}

Blinded credential request. Stores SignatureParams as appropriately sized params are created by the request builder already so not creating it again

Type declaration

boundedPseudonyms: BoundedPseudonym[]

Arguments required to calculate the attribute bound pseudonyms to be presented

bounds: Map<number, Map<string, IPresentedAttributeBound[]>>

Bounds on attribute. The key of the map is the credential index and for the inner map is the attribute and value of map denotes min, max, an identifier of the setup parameters for the protocol and the protocol name. An attribute can have many bound checks.

circomPredicates: Map<number, IProverCircomPredicate[]>

Predicates expressed as Circom programs over attributes of a single credential. For each credential, store a public, private variables, circuit id (used to fetch R1CS, WASM bytes) and attributes used in circuit

circomPredicatesMultiCred: IProverCircomPredicateMultiCred[]

Predicates expressed as Circom programs over attributes of multiple credentials.

credentials: [Credential, PublicKey?][]

Each credential is referenced by its index in this array

credStatuses: Map<number, [AccumulatorWitnessType, AccumulatorValueType, undefined | AccumulatorPublicKey, object]>

Each credential has only one accumulator for status

predicateParams: Map<string, PredicateParamType>

Parameters for predicates like snark proving key for bound check, verifiable encryption, Circom program

revealedAttributes: Map<number, Set<string>>

Attributes revealed from each credential, key of the map is the credential index

unboundedPseudonyms: UnboundedPseudonym[]

Arguments required to calculate the pseudonyms to be presented

verifEnc: Map<number, Map<string, IPresentedAttributeVE[]>>

Verifiable encryption of attributes. The key of the map is the credential index and for the inner map is the attribute and value of map denotes the setup parameters for the protocol and the protocol name. An attribute can have many verifiable encryptions.

VERSION: string = '0.10.0'

Follows semver and must be updated accordingly when the logic of this class changes or the underlying crypto changes.

Accessors

Methods

  • Parameters

    • basesForAttribute: Uint8Array[]
    • attributeNames: Map<number, string[]>
    • OptionalbaseForSecretKey: Uint8Array
    • OptionalsecretKey: Uint8Array

    Returns number

  • Add a credential to this presentation. This will result in a proof of possession of this credential being created

    Parameters

    • credential: Credential
    • Optionalpk: PublicKey

      Only certain kinds of credentials need a public key for creating presentation

    Returns number

  • Enforce equality between attributes of the credential without revealing them.

    Parameters

    • Rest...equality: AttributeEquality

      Array of reference to attribute where each reference is a pair with 1st item being credential index and 2nd being attribute index in the flattened attribute list.

    Returns void

  • Enforce inequality with a public value on a credential attribute

    Parameters

    • credIdx: number
    • attributeName: string
    • inEqualTo: any

      The public value that the attribute should be unequal to, i.e. value of attribute attributeName != inEqualTo

    • OptionalparamId: string

      If absent, the default commitment key is used

    • Optionalparam: PederCommKeyUncompressed | PederCommKey

    Returns void

  • Enforce bounds on given attribute from given credential index. The attribute value should lie in [min, max)

    Parameters

    • credIdx: number
    • attributeName: string

      Nested attribute names use the "dot" separator

    • min: BoundType
    • max: BoundType
    • OptionalparamId: string

      An identifier, unique in the context of this builder that identifies a param. If absent, transparent range proof (Bulletproofs++) is used

    • Optionalparam: BoundCheckParamType

      This is optional because if the param is already added in previous call to enforceBounds, then it shouldn't be passed. This is done to avoid copying/passing large objects in memory.

    Returns void

  • Enforce a predicate written as a Circom program over a credential's attributes

    Parameters

    • credIdx: number

      The credential index whose attributes are used as witness in the Circom program

    • circuitPrivateVars: [string, string | string[]][]

      Mapping of private variables from Circom program to attribute names. A variable can be a single value or an array and thus can correspond to a single attribute or array of attributes. Is an array of pairs where the first item of pair is the private variable name and the second item is the attribute name(s)

    • circuitPublicVars: [string, Uint8Array | Uint8Array[]][]

      Mapping of public variables from Circom program to publicly known values. Is an array of pairs where the first item of pair is the public variable name and the second item is the value as a bytearray or array of bytearrays

    • circuitId: string
    • provingKeyId: string
    • Optionalr1cs: R1CS | ParsedR1CSFile
    • OptionalwasmBytes: Uint8Array
    • OptionalprovingKey: LegoProvingKeyUncompressed | LegoProvingKey

    Returns void

  • Enforce a predicate written as a Circom program over a many credentials' attributes

    Parameters

    • circuitPrivateVars: [string, [number, string] | [number, string][]][]

      Mapping of private variables from Circom program to pairs where each pair corresponds to a credential attribute. The 1st item of the pair is the credential index and 2nd item is the attribute name in that credential

    • circuitPublicVars: [string, Uint8Array | Uint8Array[]][]

      Mapping of public variables from Circom program to its corresponding values

    • circuitId: string
    • provingKeyId: string
    • Optionalr1cs: R1CS | ParsedR1CSFile
    • OptionalwasmBytes: Uint8Array
    • OptionalprovingKey: LegoProvingKeyUncompressed | LegoProvingKey

    Returns void

  • Parameters

    • credIdx: number
    • attributeName: string

      Nested attribute names use the "dot" separator

    • chunkBitSize: number
    • commKeyId: string

      An identifier, unique in the context of this builder that identifies a commitment key.

    • encryptionKeyId: string

      An identifier, unique in the context of this builder that identifies an encryption key.

    • snarkPkId: string

      An identifier, unique in the context of this builder that identifies a snark proving key.

    • OptionalcommKey: SaverChunkedCommitmentKeyUncompressed | SaverChunkedCommitmentKey

      This is optional because if the commitment key is already added in previous call to verifiablyEncrypt, then it shouldn't be passed. This is done to avoid copying/passing large objects in memory.

    • OptionalencryptionKey: SaverEncryptionKeyUncompressed | SaverEncryptionKey

      This is optional because if the encryption key is already added in previous call to verifiablyEncrypt, then it shouldn't be passed. This is done to avoid copying/passing large objects in memory.

    • OptionalsnarkPk: SaverProvingKeyUncompressed | SaverProvingKey

      This is optional because if the snark proving key is already added in previous call to verifiablyEncrypt, then it shouldn't be passed. This is done to avoid copying/passing large objects in memory.

    Returns void