import { StatementBuilder } from '../commonProofTypes.js'; import { AttributeKey, AttributeList, HexString, IdentityObjectV1, IdentityProvider, Network } from '../types.js'; import type * as ContractAddress from '../types/ContractAddress.js'; import { ConcordiumHdWallet } from '../wasm/HdWallet.js'; import { AccountCommitmentInput, AtomicStatementV2, AttributeType, CredentialSchemaSubject, CredentialStatement, CredentialStatements, CredentialSubject, DIDString, IdObjectUseData, IdentityCommitmentInput, StatementAttributeType, Web3IssuerCommitmentInput } from './types.js'; /** Maximum byte length allowed for string attributes. */ export declare const MAX_STRING_BYTE_LENGTH = 31; /** Minimum date in ISO format supported by the system. */ export declare const MIN_DATE_ISO = "-262144-01-01T00:00:00Z"; /** Maximum date in ISO format supported by the system. */ export declare const MAX_DATE_ISO = "+262143-12-31T23:59:59.999999999Z"; /** Minimum date timestamp value supported by the system. */ export declare const MIN_DATE_TIMESTAMP: number; /** Maximum date timestamp value supported by the system. */ export declare const MAX_DATE_TIMESTAMP: number; /** * Check that the given atomic statements are well formed and do not break any rules. * If they do not verify, this throw an error. */ export declare function verifyAtomicStatements(statements: AtomicStatementV2[], schema?: CredentialSchemaSubject): boolean; /** * Builder class for constructing atomic statements about credential attributes. * Provides a fluent API for adding range, membership, and reveal statements with validation. */ export declare class AtomicStatementBuilder implements InternalBuilder { /** Array of atomic statements being built. */ statements: AtomicStatementV2[]; /** Optional schema for validating statements against credential schema. */ schema: CredentialSchemaSubject | undefined; /** * Creates a new AtomicStatementBuilder. * @param schema Optional credential schema for validation */ constructor(schema?: CredentialSchemaSubject); /** * Outputs the built statement. */ getStatement(): AtomicStatementV2[]; /** * This checks whether the given statement may be added to the statement being built. * If the statement breaks any rules, this will throw an error. * @param statement The atomic statement to validate */ private check; /** * Add to the statement, that the given attribute should be in the given range, i.e. that lower <= attribute < upper. * @param attribute the attribute that should be checked * @param lower: the lower end of the range, inclusive. * @param upper: the upper end of the range, exclusive. * @returns the updated builder */ addRange(attribute: AttributeKey, lower: StatementAttributeType, upper: StatementAttributeType): this; /** * Add to the statement, that the given attribute should be one of the values in the given set. * @param attribute the attribute that should be checked * @param set: the set of values that the attribute must be included in. * @returns the updated builder */ addMembership(attribute: AttributeKey, set: StatementAttributeType[]): this; /** * Add to the statement, that the given attribute should _not_ be one of the values in the given set. * @param attribute the attribute that should be checked * @param set: the set of values that the attribute must be included in. * @returns the updated builder */ addNonMembership(attribute: AttributeKey, set: StatementAttributeType[]): this; /** * Add to the statement, that the given attribute should be revealed. * The proof will contain the value. * @param attribute the attribute that should be revealed * @returns the updated builder */ revealAttribute(attribute: AttributeKey): this; } /** * Specialized builder for account/identity credential statements. * Extends AtomicStatementBuilder with convenience methods for common identity attributes * like age, residency, and document expiry. */ export declare class AccountStatementBuild extends AtomicStatementBuilder { /** * Add to the statement that the age is at minimum the given value. * This adds a range statement that the date of birth is between 1st of january 1800 and years ago. * @param age: the minimum age allowed. * @returns the updated builder */ addMinimumAge(age: number): AccountStatementBuild; /** * Add to the statement that the age is at maximum the given value. * This adds a range statement that the date of birth is between years ago and 1st of january 9999. * @param age: the maximum age allowed. * @returns the updated builder */ addMaximumAge(age: number): AccountStatementBuild; /** * Add to the statement that the age is between two given ages. * This adds a range statement that the date of birth is between years ago and years ago. * @param minAge: the maximum age allowed. * @param maxAge: the maximum age allowed. * @returns the updated builder */ addAgeInRange(minAge: number, maxAge: number): AccountStatementBuild; /** * Add to the statement that the user's document expiry is atleast the given date. * This adds a range statement that the idDocExpiresAt is between the given date and 1st of january 9999 . * @param earliestDate: the earliest the document is allow to be expired at, should be a string in YYYYMMDD format. * @returns the updated builder */ documentExpiryNoEarlierThan(earliestDate: string): AccountStatementBuild; /** * Add to the statement that the country of residence is one of the EU countries * @returns the updated builder */ addEUResidency(): AccountStatementBuild; /** * Add to the statement that the nationality is one of the EU countries * @returns the updated builder */ addEUNationality(): AccountStatementBuild; } /** Internal type alias for statement builders. */ type InternalBuilder = StatementBuilder; /** * Builder class for constructing credential statements for the original verifiable presentation protocol. * Supports both Web3 ID credentials and account/identity credentials with issuer qualifiers. */ export declare class Web3StatementBuilder { /** Array of credential statements being built. */ private statements; /** * Add statements for Web3 ID credentials. * * @param validContractAddresses Array of contract addresses that are valid issuers * @param builderCallback Callback function to build the statements using the provided builder * @param schema Optional credential schema for validation * * @returns The updated builder instance */ addForVerifiableCredentials(validContractAddresses: ContractAddress.Type[], builderCallback: (builder: InternalBuilder) => void, schema?: CredentialSchemaSubject): Web3StatementBuilder; /** * Add statements for account credentials. * * @param validIdentityProviders Array of identity provider indices that are valid issuers * @param builderCallback Callback function to build the statements using the provided identity builder * * @returns The updated builder instance */ addForIdentityCredentials(validIdentityProviders: number[], builderCallback: (builder: AccountStatementBuild) => void): Web3StatementBuilder; /** * Get the built credential statements. * @returns Array of credential statements */ getStatements(): CredentialStatements; } /** * Creates a DID string for a Web3 ID credential. * Used to build a request for a verifiable credential issued by a smart contract. * * @param network - The Concordium network * @param publicKey - The public key of the credential holder * @param index - The contract index * @param subindex - The contract subindex * @returns DID string in format: did:ccd:{network}:sci:{index}:{subindex}/credentialEntry/{publicKey} */ export declare function createWeb3IdDID(network: Network, publicKey: string, index: bigint, subindex: bigint): DIDString; /** * Creates a DID string for an account credential. * Used to build a request for a verifiable credential based on an account credential. * * @param network - The Concordium network * @param credId - The credential ID (registration ID) * @returns DID string in format: did:ccd:{network}:cred:{credId} */ export declare function createAccountDID(network: Network, credId: string): DIDString; /** * Creates a DID string for an identity credential statement. * Used to build a request for a verifiable credential based on an identity object. * * @param network - The Concordium network * @param idpIndex - The index of the identity provider as registered on chain * @returns DID string in format: did:ccd:{network}:id */ export declare function createIdentityStatementDID(network: Network, idpIndex: number): DIDString; /** * Creates the commitment input required to generate a proof for account credential statements. * The commitment input contains the attribute values and randomness needed for zero-knowledge proofs. * * @param statements - The atomic statements to prove * @param identityProvider - The identity provider index that issued the credential * @param attributes - The credential holder's attributes * @param randomness - Randomness values for commitments, keyed by attribute index * @returns Account commitment input for proof generation */ export declare function createAccountCommitmentInput(statements: AtomicStatementV2[], identityProvider: number, attributes: AttributeList, randomness: Record): AccountCommitmentInput; /** * Creates the commitment input required to generate a proof for account credential statements. * Uses a ConcordiumHdWallet to derive the necessary randomness values. * * @param statements - The atomic statements to prove * @param identityProvider - The identity provider index that issued the credential * @param attributes - The credential holder's attributes * @param wallet - The HD wallet for deriving randomness * @param identityIndex - The identity index in the wallet * @param credIndex - The credential index in the wallet * @returns Account commitment input for proof generation */ export declare function createAccountCommitmentInputWithHdWallet(statements: AtomicStatementV2[], identityProvider: number, attributes: AttributeList, wallet: ConcordiumHdWallet, identityIndex: number, credIndex: number): AccountCommitmentInput; /** * Creates the commitment input required to generate a proof for Web3 ID credential statements. * The commitment input contains the attribute values, randomness, and signature needed for proofs. * * @param verifiableCredentialPrivateKey - The private key for signing the credential * @param credentialSubject - The credential subject with attributes * @param randomness - Randomness values for commitments, keyed by attribute name * @param signature - The credential signature * @returns Web3 issuer commitment input for proof generation */ export declare function createWeb3CommitmentInput(verifiableCredentialPrivateKey: HexString, credentialSubject: CredentialSubject, randomness: Record, signature: string): Web3IssuerCommitmentInput; /** * Creates the commitment input required to generate a proof for Web3 ID credential statements. * Uses a ConcordiumHdWallet to derive the credential signing key. * * @param wallet - The HD wallet for deriving the signing key * @param issuer - The contract address of the credential issuer * @param credentialIndex - The credential index in the wallet * @param credentialSubject - The credential subject with attributes * @param randomness - Randomness values for commitments, keyed by attribute name * @param signature - The credential signature * @returns Web3 issuer commitment input for proof generation */ export declare function createWeb3CommitmentInputWithHdWallet(wallet: ConcordiumHdWallet, issuer: ContractAddress.Type, credentialIndex: number, credentialSubject: CredentialSubject, randomness: Record, signature: string): Web3IssuerCommitmentInput; /** * Creates the commitment input required to generate a proof for identity credential statements. * The commitment input contains the identity object and secrets needed for zero-knowledge proofs. * * @param identityProvider - The identity provider that issued the identity * @param idObject - The identity object containing identity information * @param idObjectUseData - Additional data required for using the identity object * @returns Identity commitment input for proof generation */ export declare function createIdentityCommitmentInput(identityProvider: IdentityProvider, idObject: IdentityObjectV1, idObjectUseData: IdObjectUseData): IdentityCommitmentInput; /** * Creates the commitment input required to generate a proof for identity credential statements. * Uses a ConcordiumHdWallet to derive the identity secrets (PRF key, ID cred secret, randomness). * * @param idObject - The identity object containing identity information * @param identityProvider - The identity provider that issued the identity * @param identityIndex - The identity index in the wallet * @param wallet - The HD wallet for deriving identity secrets * @returns Identity commitment input for proof generation */ export declare function createIdentityCommitmentInputWithHdWallet(idObject: IdentityObjectV1, identityProvider: IdentityProvider, identityIndex: number, wallet: ConcordiumHdWallet): IdentityCommitmentInput; /** * Checks whether a prover can fulfill an atomic statement with their attributes. * Validates that the prover has the required attribute and that it satisfies the statement constraints. * * @param statement - The atomic statement to check * @param attributes - The prover's attributes * @returns True if the statement can be proven with the given attributes */ export declare function canProveAtomicStatement(statement: AtomicStatementV2, attributes: Record): boolean; /** * Checks whether a prover can fulfill all atomic statements in a credential statement. * Returns true only if all atomic statements can be proven with the given attributes. * * @param credentialStatement - The credential statement containing multiple atomic statements * @param attributes - The prover's attributes * @returns True if all statements can be proven with the given attributes */ export declare function canProveCredentialStatement(credentialStatement: CredentialStatement, attributes: Record): boolean; export {};