import { BlockHash, ConcordiumGRPCClient, CredentialRegistrationId, CryptographicParameters, GenericMembershipStatement, GenericNonMembershipStatement, GenericRangeStatement, Network } from '../../index.js'; import { AccountCommitmentInput, AttributeType, CredentialStatus, DIDString, IdentityCommitmentInput } from '../../web3-id/index.js'; import { VerifiableCredentialV1, VerificationRequestV1 } from './index.js'; import { GivenContextJSON } from './internal.js'; import { RequestedStatement } from './request.js'; import { GivenContext } from './types.js'; /** * Context information for a verifiable presentation proof. * This extends the request context by filling in the requested context * information with actual values provided by the presenter. */ export type Context = { /** Type identifier for the context format */ type: 'ConcordiumContextInformationV1'; /** Context information that was already provided in the request */ given: GivenContext[]; /** Context information that was requested and is now filled with actual values */ requested: GivenContext[]; }; type ContextJSON = Pick & { given: GivenContextJSON[]; requested: GivenContextJSON[]; }; /** * Map the requested statements into statements used as part of the verifiable presentation. * * Statements such as `RevealAttribute` are converted into `AttributeValueStatement` with the value * from the chosen attributes. * * @see {@link noRevealRequestedStatements} when `RevealAttribute` statements are not supported. * * @param statements - The requested statements to prove for the account credential. * @param chosenAttributes - The list of attributes in the ID object. * @returns The atomic statements to be used in a verifiable presentation * @throws If requested statements contains reveal attribute for attribute tag not found in chosen * attributes. */ export declare function revealRequestedStatements(statements: RequestedStatement[], chosenAttributes: Partial>): AtomicStatementV1[]; /** * Map the requested statements into statements used as part of the verifiable presentation, but * assume `RevealAttribute` are not requested. * * @see {@link revealRequestedStatements} for support of `RevealAttribute` statements. * * @param statements - The requested statements to prove for the account credential. * @returns The atomic statements to be used in a verifiable presentation * @throws If requested statements includes a reveal attribute request. */ export declare function noRevealRequestedStatements(statements: RequestedStatement[]): AtomicStatementV1[]; /** * Claims to be proven about an account credential. * Contains the account credential DID and atomic statements about account attributes. */ export type AccountClaims = { type: ['ConcordiumSubjectClaimsV1', 'ConcordiumAccountBasedSubjectClaims']; /** Account registration id. */ id: DIDString; /** Identity provider which issued the credentials. */ issuer: DIDString; /** Attribute statements. */ statement: AtomicStatementV1[]; }; /** * Create claims about an account based credential * * @param network - The network the account credential exists on. * @param credRegId - The credential registration ID of the account. * @param issuer - Identity provider which issued the credentials. * @param statement - The atomic statements to prove for the account credential. * @returns The account claims to be used in the presentation input for the verifiable credential. */ export declare function createAccountClaims(network: Network, credRegId: CredentialRegistrationId.Type, issuer: number, statement: AtomicStatementV1[]): AccountClaims; /** * Claim to be proven about attributes from an identity credential issued by a specified identity provider. * Contains the identity DID and atomic statements about identity attributes. */ export type IdentityClaims = { type: ['ConcordiumSubjectClaimsV1', 'ConcordiumIdBasedSubjectClaims']; /** Identity provider which issued the credentials. */ issuer: DIDString; /** Attribute statements. */ statement: AtomicStatementV1[]; }; /** * Create claims about an identity based credential * * @param network - The network of the identity provider used to create the identity. * @param idpIndex - The on-chain index of the identity provider used to create the identity. * @param statement - The atomic statements to prove for the identity credential. * @returns The identity claims to be used in the presentation input for the verifiable credential. */ export declare function createIdentityClaims(network: Network, idpIndex: number, statement: AtomicStatementV1[]): IdentityClaims; /** * Union type representing all supported subject claims types in a verifiable presentation. */ export type SubjectClaims = IdentityClaims | AccountClaims; export declare function isAccountClaims(claim: SubjectClaims): claim is AccountClaims; export declare function isIdentityClaims(claim: SubjectClaims): claim is AccountClaims; /** * Creates a proof context by filling in the requested context from a presentation request. * * This function validates that all requested context information has been provided * and creates a complete context for generating the verifiable presentation proof. * * @param requestContext - The original request context with labels for requested data * @param filledRequestedContext - The actual context data filling the requested labels * * @returns A complete context for proof generation * @throws Error if not all requested context is provided or if there's a mismatch */ export declare function createContext(requestContext: VerificationRequestV1.Context, filledRequestedContext: GivenContext[]): Context; /** * A proof that establishes that the owner of the credential has indeed created * the presentation. At present this is a list of signatures. */ export type WeakLinkingProof = { /** When the statement was created, serialized as an ISO string */ created: string; /** The proof value */ proofValue: string; /** The proof type */ type: 'ConcordiumWeakLinkingProofV1'; }; /** * A verifiable presentation containing zero-knowledge proofs of credential statements. * This class represents a complete response to a verifiable presentation request, * including the context, credentials, and cryptographic proofs. */ declare class VerifiablePresentationV1 { readonly presentationContext: Context; readonly verifiableCredential: VerifiableCredentialV1.Type[]; readonly proof: WeakLinkingProof; /** * Creates a new verifiable presentation. * * @param presentationContext - The complete context for this presentation * @param verifiableCredential - Array of verifiable credentials with proofs * @param proof - Weak linking proof */ constructor(presentationContext: Context, verifiableCredential: VerifiableCredentialV1.Type[], proof: WeakLinkingProof); /** * Serializes the verifiable presentation to a JSON representation. * * @returns The JSON representation of this presentation */ toJSON(): JSON; } /** * A verifiable presentation containing zero-knowledge proofs of credential statements. * This class represents a complete response to a verifiable presentation request, * including the context, credentials, and cryptographic proofs. */ export type Type = VerifiablePresentationV1; /** * JSON representation of a verifiable presentation. * Used for serialization and network transmission of presentation data. */ export type JSON = { type: ['VerifiablePresentation', 'ConcordiumVerifiablePresentationV1']; /** The presentation context with serialized context information */ presentationContext: ContextJSON; /** Array of verifiable credentials with their proofs */ verifiableCredential: VerifiableCredentialV1.Type[]; /** Optional weak linking proof for account-based credentials */ proof: WeakLinkingProof; }; /** * Deserializes a verifiable presentation from its JSON representation. * * This function reconstructs the presentation object from JSON data, handling * the conversion of serialized context information back to proper types. * * @param value - The JSON representation to deserialize * @returns The deserialized verifiable presentation */ export declare function fromJSON(value: JSON): VerifiablePresentationV1; export type Request = { context: Context; subjectClaims: SubjectClaims[]; }; /** * Union type of all commitment input types used for generating zero-knowledge proofs. * These inputs contain the secret information needed to create proofs without revealing * the actual credential data. */ export type CommitmentInput = IdentityCommitmentInput | AccountCommitmentInput; /** * Creates a verifiable presentation from an anchored {@linkcode VerificationRequestV1}. * * This function retrieves the presentation request anchor from the blockchain, * verifies its integrity, and creates a verifiable presentation with the * requested statements and proofs. It automatically includes blockchain * context (block hash) in the presentation. * * @param grpc - Concordium GRPC client for blockchain interaction * @param verificationRequest - The anchored verification request * @param claims - The claims to prove for the corresponding subject * @param inputs - The credential inputs for generating proofs corresponding to the `claims` * @param additionalContext - Additional context information beyond block hash * * @returns Promise resolving to the created verifiable presentation * @throws Error if anchor verification fails or blockchain interaction errors */ export declare function createFromAnchor(grpc: ConcordiumGRPCClient, verificationRequest: VerificationRequestV1.Type, claims: SubjectClaims[], inputs: CommitmentInput[], additionalContext: GivenContext[]): Promise; /** * Creates a verifiable presentation with the specified statements, inputs, and context. * * This function generates zero-knowledge proofs for the requested credential statements * using the provided commitment inputs and proof context. It handles different types * of credentials (identity-based, account-based) and creates appropriate * proofs for each. * * @param presentationRequest - The presenation request describing the credentials * @param inputs - The commitment inputs for generating proofs * @param globalContext - Concordium network cryptographic parameters * * @returns The created verifiable presentation with all proofs */ export declare function create({ context, subjectClaims }: Request, inputs: CommitmentInput[], globalContext: CryptographicParameters): VerifiablePresentationV1; /** * Describes the result of a verifiable presentation verification, which can either succeed * or fail with an associated {@linkcode Error} */ export type VerificationResult = { type: 'success'; result: T; } | { type: 'failed'; error: Error; }; /** * Get all public metadata of the {@linkcode VerifiablePresentationV1}. The metadata is verified as part of this. * * @param presentation - The verifiable presentation to verify * @param grpc - The {@linkcode ConcordiumGRPCClient} to use for querying * @param network - The target network * @param [blockHash] - The block to verify the proof at. If not specified, the last finalized block is used. * * @returns The corresponding list of {@linkcode CredentialWithMetadata} if successful. * @throws If credential metadata could not be successfully verified */ export declare function getPublicData(presentation: VerifiablePresentationV1, grpc: ConcordiumGRPCClient, network: Network, blockHash?: BlockHash.Type): Promise; /** * Verifies a verifiable presentation against its corresponding request. * * This function validates the cryptographic proofs in the presentation, * checks that they match the original request, and verifies them against * the provided public data and cryptographic parameters. * * @param presentation - The verifiable presentation to verify * @param cryptographicParameters - Concordium network cryptographic parameters * @param publicData - Public credential data for verification * * @returns a {@linkcode VerificationResult} contiaining the {@linkcode Request}. * @throws If presentation could not be successfully verified */ export declare function verify(presentation: VerifiablePresentationV1, cryptographicParameters: CryptographicParameters, publicData: VerifiableCredentialV1.VerificationMaterial[]): VerificationResult; /** * Verifies a verifiable presentation using a Concordium node. * * This function performs verification by querying a Concordium node for * the necessary cryptographic parameters and public data, then validates * the presentation proofs against the blockchain state. * * @param presentation - The verifiable presentation to verify * @param grpc - Concordium GRPC client for node communication * @param network - The Concordium network to verify against * @param [blockHash] - The block to verify the proof at. If not specified, the last finalized block is used. * * @returns Promise resolving to a {@linkcode VerificationResult} contiaining the {@linkcode Request} and a * list of statuses for each credential in the presentation. * * @throws If presentation could not be successfully verified * @throws If credential metadata could not be successfully verified */ export declare function verifyWithNode(presentation: VerifiablePresentationV1, grpc: ConcordiumGRPCClient, network: Network, blockHash?: BlockHash.Type): Promise>; /** * For the case where the verifier wants the user to prove that an attribute is equal to a public * value. The statement is that the attribute value is equal to `attributeValue`. */ export type GenericAttributeValueStatement = { type: 'AttributeValue'; /** The attribute that the verifier wants the user to prove equal to a value. */ attributeTag: TagType; /** The value the attribute must be proven equal to. */ attributeValue: ValueType; }; /** * The type of statements that can be used in subject claims. */ export type AtomicStatementV1 = GenericAttributeValueStatement | GenericMembershipStatement | GenericNonMembershipStatement | GenericRangeStatement; export {};