import { R1CS } from 'crypto-wasm-new'; import { AccumulatorPublicKey } from '../accumulator'; import { BBSSignatureParams } from '../bbs'; import { BBSPlusSignatureParamsG1 } from '../bbs-plus'; import { BBDT16MacParams } from '../bbdt16-mac'; import { BytearrayWrapper } from '../bytearray-wrapper'; import { LegoProvingKey, LegoProvingKeyUncompressed } from '../legosnark'; import { PederCommKey, PederCommKeyUncompressed } from '../ped-com'; import { ParsedR1CSFile } from '../r1cs/file'; import { SaverChunkedCommitmentKey, SaverChunkedCommitmentKeyUncompressed, SaverEncryptionKey, SaverEncryptionKeyUncompressed, SaverProvingKey, SaverProvingKeyUncompressed } from '../saver'; import { BBSBlindedCredentialRequest, BBSPlusBlindedCredentialRequest, BBDT16BlindedCredentialRequest } from './blinded-credential-request'; import { BBSCredential, BBSPlusCredential, PSCredential } from './credential'; import { Presentation } from './presentation'; import { IProverBoundedPseudonymInBlindedCredReq, IProverCircomPredicate, PresentationBuilder } from './presentation-builder'; import { IPresentedAttributeBound, IPresentedAttributeInequality, IPresentedAttributeVE } from './presentation-specification'; import { CredentialSchema } from './schema'; import { AccumulatorWitnessType, AttributeEquality, BlindedAttributeEquality, BlindSignatureType, BoundCheckParamType, BoundType, PublicKey, RevocationStatusProtocol, SignatureParams } from './types-and-consts'; import { Versioned } from './versioned'; type Credential = BBSCredential | BBSPlusCredential | PSCredential; /** * Creates a request for a blinded credential, i.e. where some of the attributes are not known to the signer */ export declare abstract class BlindedCredentialRequestBuilder extends Versioned { /** * Follows semver and must be updated accordingly when the logic of this class changes or the * underlying crypto changes. */ static VERSION: string; /** * The schema of the whole (unblinded credential). This should include all attributes, i.e. blinded and unblinded */ _schema?: CredentialSchema; /** * The attributes of the credential subject that will be blinded (hidden from the issuer) */ _subjectToBlind?: object | object[]; /** * The credential status if blinded */ _statusToBlind?: object; /** * Any top level attributes to blind */ _topLevelAttributesToBlind: Map; protected sigParams?: SignatureParams; /** * A blinded credential request will contain a presentation that will prove predicates about the credential attributes and blinded attributes. */ presentationBuilder: PresentationBuilder; /** * Equalities between blinded and credential attributes */ attributeEqualities: BlindedAttributeEquality[]; /** * Attributes proved inequal to a public value in zero knowledge. An attribute can be proven inequal to any number of values */ attributeInequalities: Map; /** * Bounds on blinded attributes */ bounds: Map; /** * Encryption of blinded attributes */ verifEnc: Map; /** * Circom predicates on blinded attributes */ circomPredicates: IProverCircomPredicate[]; /** * Pseudonyms on blinded and credential attributes */ boundedPseudonyms: IProverBoundedPseudonymInBlindedCredReq[]; constructor(); set subjectToBlind(subject: object | object[]); get subjectToBlind(): object | object[] | undefined; set schema(schema: CredentialSchema); get schema(): CredentialSchema | undefined; /** * Blind some of the credential status values * @param registryId - this won't be blinded * @param revCheck - this won't be blinded * @param memberValue - Only this will be blinded. * @param revType */ statusToBlind(registryId: string, revCheck: string, memberValue: unknown, revType?: RevocationStatusProtocol): void; /** * Blind top level fields. The issuer should not set these blinded fields at all, not even nested. * @param name * @param value */ topLevelAttributesToBlind(name: string, value: unknown): void; /** * Create a commitment to the blinded attributes. * @param encodedSubject - The blinded attributes in encoded (as a field element) form. The key of the map is the index * of the attributes in the flattened attributes list * @param totalAttributes - Total number of attributes (blinded and unblinded) in the credential * @param labelOrParams - Signature params or the label to generate them. */ abstract computeCommitment(encodedSubject: Map, totalAttributes: number, labelOrParams: Uint8Array | SigParams | undefined): Uint8Array; abstract getBlinding(): Uint8Array | undefined; static getSigType(): BlindSignatureType; addCredentialToPresentation(credential: Credential, pk?: PublicKey): number; /** * Reveal attributes of the presented credential * @param credIdx * @param attributeNames */ markCredentialAttributesRevealed(credIdx: number, attributeNames: Set): void; /** * Enforce equality on attributes of the presented credential * @param equality */ enforceCredentialAttributesEqual(...equality: AttributeEquality): void; addAccumInfoForCredStatus(credIdx: number, accumWitness: AccumulatorWitnessType, accumulated: Uint8Array, accumPublicKey: AccumulatorPublicKey, extra?: object): void; enforceInequalityOnCredentialAttribute(credIdx: number, attributeName: string, inEqualTo: any, paramId?: string, param?: PederCommKey | PederCommKeyUncompressed): void; enforceBoundsOnCredentialAttribute(credIdx: number, attributeName: string, min: BoundType, max: BoundType, paramId?: string, param?: BoundCheckParamType): void; verifiablyEncryptCredentialAttribute(credIdx: number, attributeName: string, chunkBitSize: number, commKeyId: string, encryptionKeyId: string, snarkPkId: string, commKey?: SaverChunkedCommitmentKey | SaverChunkedCommitmentKeyUncompressed, encryptionKey?: SaverEncryptionKey | SaverEncryptionKeyUncompressed, snarkPk?: SaverProvingKey | SaverProvingKeyUncompressed): void; enforceCircomPredicateOnCredentialAttribute(credIdx: number, circuitPrivateVars: [string, string | string[]][], circuitPublicVars: [string, Uint8Array | Uint8Array[]][], circuitId: string, provingKeyId: string, r1cs?: R1CS | ParsedR1CSFile, wasmBytes?: Uint8Array, provingKey?: LegoProvingKey | LegoProvingKeyUncompressed): void; enforceCircomPredicateAcrossMultipleCredentials(circuitPrivateVars: [string, [number, string] | [number, string][]][], circuitPublicVars: [string, Uint8Array | Uint8Array[]][], circuitId: string, provingKeyId: string, r1cs?: R1CS | ParsedR1CSFile, wasmBytes?: Uint8Array, provingKey?: LegoProvingKey | LegoProvingKeyUncompressed): void; addUnboundedPseudonym(baseForSecretKey: Uint8Array, secretKey: Uint8Array): number; /** * Add a pseudonym to only credential attributes * @param basesForAttribute * @param attributeNames * @param baseForSecretKey * @param secretKey * @returns */ addPseudonymToCredentialAttributes(basesForAttribute: Uint8Array[], attributeNames: Map, baseForSecretKey?: Uint8Array, secretKey?: Uint8Array): number; /** * Enforce that a blinded attribute is equal to one or more credential attributes * @param equality */ enforceEqualityOnBlindedAttribute(equality: BlindedAttributeEquality): void; /** * Enforce that the blinded attribute `attributeName` is inequal to the public value `inEqualTo` * @param attributeName * @param inEqualTo * @param paramId * @param param */ enforceInequalityOnBlindedAttribute(attributeName: string, inEqualTo: any, paramId?: string, param?: PederCommKey | PederCommKeyUncompressed): void; /** * * @param attributeName - Nested attribute names use the "dot" separator * @param min * @param max * @param paramId * @param param */ enforceBoundsOnBlindedAttribute(attributeName: string, min: BoundType, max: BoundType, paramId?: string, param?: BoundCheckParamType): void; verifiablyEncryptBlindedAttribute(attributeName: string, chunkBitSize: number, commKeyId: string, encryptionKeyId: string, snarkPkId: string, commKey?: SaverChunkedCommitmentKey | SaverChunkedCommitmentKeyUncompressed, encryptionKey?: SaverEncryptionKey | SaverEncryptionKeyUncompressed, snarkPk?: SaverProvingKey | SaverProvingKeyUncompressed): void; enforceCircomPredicateOnBlindedAttribute(circuitPrivateVars: [string, string | string[]][], circuitPublicVars: [string, Uint8Array | Uint8Array[]][], circuitId: string, provingKeyId: string, r1cs?: R1CS | ParsedR1CSFile, wasmBytes?: Uint8Array, provingKey?: LegoProvingKey | LegoProvingKeyUncompressed): void; /** * Add a pseudonym which is bound to 0 or more credential attributes and 0 or more blinded attributes * @param basesForAttributes - The bases at the beginning of array will be used for credential attributes and then in the end for blinded attributes. * @param credentialAttributeNames - Map with key as the credential index and value as an array of attribute to use in pseudonym. * @param blindedAttributeNames - Array of blinded attribute to use in pseudonym * @param baseForSecretKey * @param secretKey */ addPseudonymToCredentialAndBlindedAttributes(basesForAttributes: Uint8Array[], credentialAttributeNames: Map, blindedAttributeNames: string[], baseForSecretKey?: Uint8Array, secretKey?: Uint8Array): void; protected createPresentation(sigParams?: SigParams | Uint8Array): Presentation; } export declare class BBSBlindedCredentialRequestBuilder extends BlindedCredentialRequestBuilder { computeCommitment(encodedSubject: Map, totalAttributes: number, labelOrParams?: Uint8Array | BBSSignatureParams): Uint8Array; /** * Create the request to be sent to the signer * @param sigParams * @returns */ finalize(sigParams?: Uint8Array | BBSSignatureParams): BBSBlindedCredentialRequest; /** * BBS does not use blinding so return undefined * @returns */ getBlinding(): undefined; static getSigType(): BlindSignatureType; } export declare class BBSPlusBlindedCredentialRequestBuilder extends BlindedCredentialRequestBuilder { private readonly blinding; constructor(); /** * Create the request to be sent to the signer and the blinding to be kept to later unblind the credential * @param sigParams * @returns */ finalize(sigParams?: Uint8Array | BBSPlusSignatureParamsG1): [BBSPlusBlindedCredentialRequest, BBSPlusBlinding]; getBlinding(): Uint8Array; computeCommitment(encodedSubject: Map, totalAttributes: number, labelOrParams?: Uint8Array | BBSPlusSignatureParamsG1): Uint8Array; static getSigType(): BlindSignatureType; } export declare class BBDT16BlindedCredentialRequestBuilder extends BlindedCredentialRequestBuilder { private readonly blinding; constructor(); /** * Create the request to be sent to the signer and the blinding to be kept to later unblind the credential * @param sigParams * @returns */ finalize(sigParams?: Uint8Array | BBDT16MacParams): [BBDT16BlindedCredentialRequest, BBDT16Blinding]; getBlinding(): Uint8Array; computeCommitment(encodedSubject: Map, totalAttributes: number, labelOrParams?: Uint8Array | BBDT16MacParams): Uint8Array; static getSigType(): BlindSignatureType; } export declare class BBSPlusBlinding extends BytearrayWrapper { } export declare class BBDT16Blinding extends BytearrayWrapper { } export {}; //# sourceMappingURL=blinded-credential-request-builder.d.ts.map