@@ -24,10 +24,12 @@ import {
2424 AtomicStatementV2 ,
2525 CredentialsInputsAccount ,
2626 CredentialsInputsIdentity ,
27+ CredentialsInputsWeb3 ,
2728 DIDString ,
2829 IdentityCommitmentInput ,
2930 CommitmentInput as OldCommitmentInputs ,
3031 Web3IdProofRequest ,
32+ Web3IssuerCommitmentInput ,
3133} from '../../web3-id/index.js' ;
3234import { getVerifiablePresentation } from '../VerifiablePresentation.js' ;
3335import { GivenContextJSON , givenContextFromJSON , givenContextToJSON } from './internal.js' ;
@@ -60,11 +62,17 @@ export type AccountStatement = { id: DIDString; statement: AtomicStatementV2<Att
6062 */
6163export type IdentityStatement = { id : DIDString ; statement : AtomicStatementV2 < AttributeKey > [ ] } ;
6264
65+ /**
66+ * Statement proving attributes from a Web3 ID credential.
67+ * Contains the Web3 ID DID, atomic statements about Web3 attributes, and credential type information.
68+ */
69+ export type Web3IdStatement = { id : DIDString ; statement : AtomicStatementV2 < string > [ ] ; type : string [ ] } ;
70+
6371/**
6472 * Union type representing all supported statement types in a verifiable presentation.
6573 * Each statement contains proofs about specific credential attributes.
6674 */
67- export type Statement = IdentityStatement | AccountStatement ;
75+ export type Statement = IdentityStatement | Web3IdStatement | AccountStatement ;
6876
6977function isSpecifiedAccountCredentialStatement ( statement : Statement ) : statement is AccountStatement {
7078 return statement . id . includes ( ':cred:' ) ;
@@ -160,13 +168,34 @@ export type AccountBasedCredential = {
160168 issuer : DIDString ;
161169} ;
162170
171+ /**
172+ * A verifiable credential based on Web3 ID smart contract information.
173+ * This credential type contains zero-knowledge proofs about smart contract
174+ * issued credentials and their attributes.
175+ */
176+ export type Web3BasedCredential = {
177+ /** Type identifiers for this credential format */
178+ type : [ 'VerifiableCredential' , 'ConcordiumVerifiableCredentialV1' , 'ConcordiumWeb3BasedCredential' ] ;
179+ /** The credential subject containing Web3 ID statements */
180+ credentialSubject : {
181+ /** The account credential identifier as a DID */
182+ id : DIDString ;
183+ /** Statements about Web3 ID attributes (should match request) */
184+ statement : AtomicStatementV2 < string > [ ] ;
185+ } ;
186+ /** The zero-knowledge proof for attestation */
187+ proof : ZKProofV4 ;
188+ /** The issuer of the ID credential used to open the account credential */
189+ issuer : DIDString ;
190+ } ;
191+
163192/**
164193 * Union type representing all supported verifiable credential formats
165194 * in Concordium verifiable presentations.
166195 *
167196 * The structure is reminiscent of a w3c verifiable credential
168197 */
169- export type Credential = IdentityBasedCredential | AccountBasedCredential ;
198+ export type Credential = IdentityBasedCredential | AccountBasedCredential | Web3BasedCredential ;
170199
171200/**
172201 * A verifiable presentation containing zero-knowledge proofs of credential statements.
@@ -251,7 +280,7 @@ export function fromJSON(value: JSON): VerifiablePresentationV1 {
251280 * These inputs contain the secret information needed to create proofs without revealing
252281 * the actual credential data.
253282 */
254- export type CommitmentInput = IdentityCommitmentInput | AccountCommitmentInput ;
283+ export type CommitmentInput = IdentityCommitmentInput | Web3IssuerCommitmentInput | AccountCommitmentInput ;
255284
256285/**
257286 * Creates a verifiable presentation from an anchored presentation request.
@@ -312,7 +341,7 @@ export async function createFromAnchor(
312341 *
313342 * This function generates zero-knowledge proofs for the requested credential statements
314343 * using the provided commitment inputs and proof context. It handles different types
315- * of credentials (identity-based, account-based) and creates appropriate
344+ * of credentials (identity-based, account-based, Web3-based ) and creates appropriate
316345 * proofs for each.
317346 *
318347 * @param requestStatements - The credential statements to prove
@@ -355,18 +384,21 @@ export function create(
355384 request,
356385 } ) ;
357386 // Map the output to match the format of the V1 protocol.
358- const compatibleCredentials : Credential [ ] = verifiableCredential . map < Credential > ( ( c ) => {
359- const { proof, id , statement } = c . credentialSubject ;
387+ const compatibleCredentials : Credential [ ] = verifiableCredential . map < Credential > ( ( c , i ) => {
388+ const { proof, ... credentialSubject } = c . credentialSubject ;
360389 const { created, type : _type , ...proofValues } = proof ;
390+ const type = isSpecifiedAccountCredentialStatement ( compatibleStatements [ i ] )
391+ ? 'ConcordiumAccountBasedCredential'
392+ : 'ConcordiumWeb3BasedCredential' ;
361393 return {
362394 proof : {
363395 createdAt : created ,
364396 type : 'ConcordiumZKProofV4' ,
365397 proofValue : Buffer . from ( cborEncode ( proofValues ) ) . toString ( 'hex' ) ,
366398 } ,
367399 issuer : c . issuer ,
368- type : [ 'VerifiableCredential' , 'ConcordiumVerifiableCredentialV1' , 'ConcordiumAccountBasedCredential' ] ,
369- credentialSubject : { id , statement : statement as unknown as AtomicStatementV2 < AttributeKey > [ ] } ,
400+ type : [ 'VerifiableCredential' , 'ConcordiumVerifiableCredentialV1' , type ] as any ,
401+ credentialSubject,
370402 } ;
371403 } ) ;
372404 // and add stubbed ID credentials in
@@ -400,7 +432,7 @@ export type VerificationResult = { type: 'success' } | { type: 'failed'; error:
400432 * Union type of all credential input types used for verification.
401433 * These inputs contain the public credential data needed to verify proofs.
402434 */
403- export type CredentialsInputs = CredentialsInputsAccount | CredentialsInputsIdentity ;
435+ export type CredentialsInputs = CredentialsInputsWeb3 | CredentialsInputsAccount | CredentialsInputsIdentity ;
404436
405437/**
406438 * Verifies a verifiable presentation against its corresponding request.
0 commit comments