@@ -292,6 +292,10 @@ function getAccountCredentialQualifier(validIdentityProviders: number[]): Identi
292292 } ;
293293}
294294
295+ /**
296+ * Builder class for constructing atomic statements about credential attributes.
297+ * Provides a fluent API for adding range, membership, and reveal statements with validation.
298+ */
295299export class AtomicStatementBuilder < AttributeKey = string > implements InternalBuilder < AttributeKey > {
296300 /** Array of atomic statements being built. */
297301 statements : AtomicStatementV2 < AttributeKey > [ ] ;
@@ -395,6 +399,11 @@ export class AtomicStatementBuilder<AttributeKey = string> implements InternalBu
395399 }
396400}
397401
402+ /**
403+ * Specialized builder for account/identity credential statements.
404+ * Extends AtomicStatementBuilder with convenience methods for common identity attributes
405+ * like age, residency, and document expiry.
406+ */
398407export class AccountStatementBuild extends AtomicStatementBuilder < AttributeKey > {
399408 /**
400409 * Add to the statement that the age is at minimum the given value.
@@ -456,7 +465,11 @@ export class AccountStatementBuild extends AtomicStatementBuilder<AttributeKey>
456465
457466/** Internal type alias for statement builders. */
458467type InternalBuilder < AttributeKey > = StatementBuilder < StatementAttributeType , AttributeKey > ;
459- /** Builder class for constructing credential statements with different credential types. */
468+
469+ /**
470+ * Builder class for constructing credential statements for the original verifiable presentation protocol.
471+ * Supports both Web3 ID credentials and account/identity credentials with issuer qualifiers.
472+ */
460473export class Web3StatementBuilder {
461474 /** Array of credential statements being built. */
462475 private statements : CredentialStatements = [ ] ;
@@ -516,7 +529,14 @@ export class Web3StatementBuilder {
516529}
517530
518531/**
519- * Create a DID string for a web3id credential. Used to build a request for a verifiable credential.
532+ * Creates a DID string for a Web3 ID credential.
533+ * Used to build a request for a verifiable credential issued by a smart contract.
534+ *
535+ * @param network - The Concordium network
536+ * @param publicKey - The public key of the credential holder
537+ * @param index - The contract index
538+ * @param subindex - The contract subindex
539+ * @returns DID string in format: did:ccd:{network}:sci:{index}:{subindex}/credentialEntry/{publicKey}
520540 */
521541export function createWeb3IdDID ( network : Network , publicKey : string , index : bigint , subindex : bigint ) : DIDString {
522542 return (
@@ -532,22 +552,40 @@ export function createWeb3IdDID(network: Network, publicKey: string, index: bigi
532552}
533553
534554/**
535- * Create a DID string for a web3id credential. Used to build a request for a verifiable credential.
555+ * Creates a DID string for an account credential.
556+ * Used to build a request for a verifiable credential based on an account credential.
557+ *
558+ * @param network - The Concordium network
559+ * @param credId - The credential ID (registration ID)
560+ * @returns DID string in format: did:ccd:{network}:cred:{credId}
536561 */
537562export function createAccountDID ( network : Network , credId : string ) : DIDString {
538563 return 'did:ccd:' + network . toLowerCase ( ) + ':cred:' + credId ;
539564}
540565
541566/**
542- * Create a DID string for an identity credential. Used to build a request for a verifiable credential.
567+ * Creates a DID string for an identity credential.
568+ * Used to build a request for a verifiable credential based on an identity object.
569+ *
570+ * @param network - The Concordium network
571+ * @param identityProviderIndex - The index of the identity provider that issued the identity
572+ * @param identityIndex - The index of the identity
573+ * @returns DID string in format: did:ccd:{network}:id:{identityProviderIndex}:{identityIndex}
543574 */
544575// TODO: figure out if this matches the identifier.
545576export function createIdentityDID ( network : Network , identityProviderIndex : number , identityIndex : number ) : DIDString {
546577 return 'did:ccd:' + network . toLowerCase ( ) + ':id:' + identityProviderIndex + ':' + identityIndex ;
547578}
548579
549580/**
550- * Create the commitment input required to create a proof for the given statements, using an account credential.
581+ * Creates the commitment input required to generate a proof for account credential statements.
582+ * The commitment input contains the attribute values and randomness needed for zero-knowledge proofs.
583+ *
584+ * @param statements - The atomic statements to prove
585+ * @param identityProvider - The identity provider index that issued the credential
586+ * @param attributes - The credential holder's attributes
587+ * @param randomness - Randomness values for commitments, keyed by attribute index
588+ * @returns Account commitment input for proof generation
551589 */
552590export function createAccountCommitmentInput (
553591 statements : AtomicStatementV2 [ ] ,
@@ -571,8 +609,16 @@ export function createAccountCommitmentInput(
571609}
572610
573611/**
574- * Create the commitment input required to create a proof for the given statements, using an account credential.
575- * Uses a ConcordiumHdWallet to get randomness needed.
612+ * Creates the commitment input required to generate a proof for account credential statements.
613+ * Uses a ConcordiumHdWallet to derive the necessary randomness values.
614+ *
615+ * @param statements - The atomic statements to prove
616+ * @param identityProvider - The identity provider index that issued the credential
617+ * @param attributes - The credential holder's attributes
618+ * @param wallet - The HD wallet for deriving randomness
619+ * @param identityIndex - The identity index in the wallet
620+ * @param credIndex - The credential index in the wallet
621+ * @returns Account commitment input for proof generation
576622 */
577623export function createAccountCommitmentInputWithHdWallet (
578624 statements : AtomicStatementV2 [ ] ,
@@ -597,7 +643,14 @@ export function createAccountCommitmentInputWithHdWallet(
597643}
598644
599645/**
600- * Create the commitment input required to create a proof for the given statements, using an web3Id credential.
646+ * Creates the commitment input required to generate a proof for Web3 ID credential statements.
647+ * The commitment input contains the attribute values, randomness, and signature needed for proofs.
648+ *
649+ * @param verifiableCredentialPrivateKey - The private key for signing the credential
650+ * @param credentialSubject - The credential subject with attributes
651+ * @param randomness - Randomness values for commitments, keyed by attribute name
652+ * @param signature - The credential signature
653+ * @returns Web3 issuer commitment input for proof generation
601654 */
602655export function createWeb3CommitmentInput (
603656 verifiableCredentialPrivateKey : HexString ,
@@ -615,8 +668,16 @@ export function createWeb3CommitmentInput(
615668}
616669
617670/**
618- * Create the commitment input required to create a proof for the given statements, using an web3Id credential.
619- * Uses a ConcordiumHdWallet to supply the public key and the signing key of the credential.
671+ * Creates the commitment input required to generate a proof for Web3 ID credential statements.
672+ * Uses a ConcordiumHdWallet to derive the credential signing key.
673+ *
674+ * @param wallet - The HD wallet for deriving the signing key
675+ * @param issuer - The contract address of the credential issuer
676+ * @param credentialIndex - The credential index in the wallet
677+ * @param credentialSubject - The credential subject with attributes
678+ * @param randomness - Randomness values for commitments, keyed by attribute name
679+ * @param signature - The credential signature
680+ * @returns Web3 issuer commitment input for proof generation
620681 */
621682export function createWeb3CommitmentInputWithHdWallet (
622683 wallet : ConcordiumHdWallet ,
@@ -635,7 +696,13 @@ export function createWeb3CommitmentInputWithHdWallet(
635696}
636697
637698/**
638- * Create the commitment input required to create a proof for the given statements, using an identity credential.
699+ * Creates the commitment input required to generate a proof for identity credential statements.
700+ * The commitment input contains the identity object and secrets needed for zero-knowledge proofs.
701+ *
702+ * @param identityProvider - The identity provider that issued the identity
703+ * @param idObject - The identity object containing identity information
704+ * @param idObjectUseData - Additional data required for using the identity object
705+ * @returns Identity commitment input for proof generation
639706 */
640707export function createIdentityCommitmentInput (
641708 identityProvider : IdentityProvider ,
@@ -657,8 +724,14 @@ export function createIdentityCommitmentInput(
657724}
658725
659726/**
660- * Create the commitment input required to create a proof for the given statements, using an identity credential.
661- * Uses a ConcordiumHdWallet to get values for the {@linkcode IdObjectUseData}.
727+ * Creates the commitment input required to generate a proof for identity credential statements.
728+ * Uses a ConcordiumHdWallet to derive the identity secrets (PRF key, ID cred secret, randomness).
729+ *
730+ * @param idObject - The identity object containing identity information
731+ * @param identityProvider - The identity provider that issued the identity
732+ * @param identityIndex - The identity index in the wallet
733+ * @param wallet - The HD wallet for deriving identity secrets
734+ * @returns Identity commitment input for proof generation
662735 */
663736export function createIdentityCommitmentInputWithHdWallet (
664737 idObject : IdentityObjectV1 ,
@@ -712,7 +785,12 @@ function isInSet(value: AttributeType, set: AttributeType[]) {
712785}
713786
714787/**
715- * Given an atomic statement and a prover's attributes, determine whether the statement is fulfilled.
788+ * Checks whether a prover can fulfill an atomic statement with their attributes.
789+ * Validates that the prover has the required attribute and that it satisfies the statement constraints.
790+ *
791+ * @param statement - The atomic statement to check
792+ * @param attributes - The prover's attributes
793+ * @returns True if the statement can be proven with the given attributes
716794 */
717795export function canProveAtomicStatement (
718796 statement : AtomicStatementV2 ,
@@ -739,7 +817,12 @@ export function canProveAtomicStatement(
739817}
740818
741819/**
742- * Given a credential statement and a prover's attributes, determine whether the statements are fulfilled.
820+ * Checks whether a prover can fulfill all atomic statements in a credential statement.
821+ * Returns true only if all atomic statements can be proven with the given attributes.
822+ *
823+ * @param credentialStatement - The credential statement containing multiple atomic statements
824+ * @param attributes - The prover's attributes
825+ * @returns True if all statements can be proven with the given attributes
743826 */
744827export function canProveCredentialStatement (
745828 credentialStatement : CredentialStatement ,
0 commit comments