github.com/hyperledger/aries-framework-go@v0.3.2/docs/vc_wallet.md (about)

     1  # Verifiable Credential Wallet
     2  
     3  The aries-framework-go project can be used as verifiable credential wallet which can be used to manage credentials and related data models.
     4  
     5  ## Standards
     6  
     7  Here are the major specification followed by aries verifiable credential wallet interfaces,
     8  * [Universal Wallet](https://w3c-ccg.github.io/universal-wallet-interop-spec/) - for wallet data models and interfaces.
     9  * [Verifiable Presentation request Specifications](https://w3c-ccg.github.io/vp-request-spec/) - for credential queries.
    10  * [Presentation Exchange](https://identity.foundation/presentation-exchange/) - for credential queries.
    11  * [WACI Presentation Exchange](https://identity.foundation/waci-presentation-exchange/): Wallet and credential interaction standards using DIDComm.
    12  * [Verifiable Credentials Data Model v1.1](https://www.w3.org/TR/vc-data-model/): For all the verifiable credential data model operations.
    13  * [JSON-LD v1.1](https://w3c.github.io/json-ld-syntax/): For JSON-based Serialization for Linked Data.
    14  * [Linked Data Proofs v1.0](https://w3c-ccg.github.io/ld-proofs/): For generating JSON-LD based linked data proofs.
    15  * [Decentralized Identifiers (DIDs) v1.0](https://w3c.github.io/did-core/): For signing and verifying verifiable credentials and presentations.
    16  * [WebKMS v0.7](https://w3c-ccg.github.io/webkms/): For implementing cryptographic key management systems for the wallet.
    17  * [Decentralized Identifier Resolution (DID Resolution) v0.2](https://w3c-ccg.github.io/did-resolution/): Followed for resolving various decentralized identifiers.
    18  * [Aries RFCS](#aries-rfcs): it follows many aries RFCs features like DIDComm, Out-Of-Band Messaging, Issue Credential Protocol, Present Proof Protocol, Messaging, Mediators etc.
    19  * [DIDComm V2](https://identity.foundation/didcomm-messaging/spec/): Version 2 of DID Communication protocol for secured communication between wallet and issuer/relying party.
    20  * [Credential Manifest](https://identity.foundation/credential-manifest/): Credential Manifests are a resource format that defines preconditional requirements, Issuer style preferences, Credential Style preferences and other facets User Agents utilize to help articulate and select the inputs necessary for processing and issuance of a specified credential.
    21  
    22  
    23  ## How it works
    24  
    25  #### Wallet Profiles
    26  The aries verifiable credential wallet provides multi-tenancy, where all wallet users can use their own storage, keys and key management systems. 
    27  Each wallet user can create their wallet profiles customized to their storage types, keys and key management systems. 
    28  Refer [profile section](#creating-and-updating-wallet-profiles) for more details on how to manage profiles. 
    29  
    30  Note: Each wallet profiles can have their own storage types (like leveldb, couchdb, EDV etc) and KMS (local or remote).
    31  
    32  ![image](https://user-images.githubusercontent.com/29631944/126654261-dc49eb29-5fa9-46cf-b189-b1773064e496.png)
    33  
    34  * Storage - Agent creates new storage for each wallet profile during profile creation. 
    35  Storage type is typically same as agent's storage type, but a profile can also be created using already configured EDV if wallet user wish to use 
    36  EDV.
    37  * Key Management - Each wallet profile uses its own key management system which can be configured during profile creation.
    38      * Local KMS - a wallet profile can be created simply by providing local KMS passphrase where agent will create namespaced local KMS instance for corresponding wallet user. 
    39      Then wallet will use the profile's local KMS instance for all key operations.
    40      * Remote KMS (Web KMS) - a wallet profile can be created using key server URL in case of remote KMS. 
    41      Then wallet will use the profile's remote key server URL for all key operations.
    42  
    43  #### Opening & Closing Wallet
    44  All of the wallet operations involves storage & key management systems and they need to be unlocked to be used. 
    45  So wallet provides mechanism for opening and closing the wallet to unlock and lock storage and key management systems. A wallet can only be opened by authorization parameters like local KMS passphrase, web kms auth, EDV auth etc based on wallet user's profile settings.
    46  More details about how to open a wallet can be found [here](#opening-a-wallet)
    47  
    48  Opening a wallet creates storage and KMS instances using wallet user's profile settings and returns an auth token which can be used for subsequent wallet operations.
    49  When wallet closes or token expires, those storage and KMS instances will be destroyed and performing a wallet operation later on with previous token will return an error.  
    50   
    51  #### Managing Wallet Contents
    52  Wallet contents will be stored in storage provider configured during wallet's profile creation. The aries verifiable credential wallet implements various universal wallet interfaces and data models 
    53  and they will be discussed in detail in data models and interfaces sections below.
    54  
    55  #### Verifiable Credential Operations
    56  The aries verifiable credential wallet provides various verifiable credentials operations based on universal wallet specifications like issue, prove, verify, derive etc.
    57  Refer data models and interfaces sections below for more details.
    58  
    59  #### DIDComm Operations
    60  The aries verifiable credential wallet provides various DIDComm operations to perform secured exchange of credentials and other metadata between wallet and issuer/relying party.
    61  
    62  ## Creating and Updating Wallet Profiles
    63  * A wallet profile with local KMS can be created by providing passphrase or secret lock service option.
    64  * A wallet profile with Remote KMS can be created by providing secret lock service option.
    65  * A wallet profile with EDV as storage type can be created by providing EDV storage options like edv server URL, Vault ID, encryption key ID and mac operation key ID.
    66  This profile will use [aries EDV client implementation](https://github.com/hyperledger/aries-framework-go/blob/main/component/storage/edv) for performing encrypted data vault operations.
    67  
    68  Refer Aries Go Docs for [ProfileOptions](https://github.com/hyperledger/aries-framework-go/blob/main/pkg/wallet/options.go#L33-L69) for different options for creating wallet profiles.
    69  
    70  > Aries Go SDK Sample for creating wallet profile
    71  ```
    72  // creating wallet profile using local KMS passphrase
    73  err := vcwallet.CreateProfile(sampleUserID, ctx, wallet.WithPassphrase(samplePassPhrase))
    74  
    75  // creating wallet profile using local KMS secret lock service
    76  err = vcwallet.CreateProfile(sampleUserID, ctx, wallet.WithSecretLockService(mySecretLockSvc}))
    77  
    78  // createing wallet profile using remote KMS & EDV
    79  err := vcwallet.CreateProfile(sampleUserID, ctx,
    80  wallet.WithKeyServerURL(keyServerURL), 
    81  wallet.WithEDVStorage(edvServerURL, vaultID, encryptionKID,macKID))
    82  ```
    83  
    84  Aries wallet APIs also provides ``UpdateProfile`` functions for updating wallet profiles. Care should be taken while using this function wallet might lose existing contents or keys by changing storage or key management systems.
    85  
    86  ## Opening a Wallet
    87  
    88  Wallet can be opened by parameters related to profile settings of the wallet user.
    89  
    90  For example,
    91  * A wallet can be unlocked by local KMS passphrase or secret service only if wallet profile is configured to use local KMS for its key operations.
    92  * A wallet user has to provide EDV unlock auth if wallet profile is configured to use EDV as a content store.
    93  
    94  Opening a wallet returns a auth token which expires when wallet is closed or when life time of the token passes.
    95  
    96  > Aries Go SDK Sample for opening a wallet for profile using local KMS settings - 1.
    97  ```
    98  // creating vcwallet instance for user with local KMS settings.
    99  myWallet, err := vcwallet.New(sampleUserID, ctx)
   100  
   101  // opening a wallet with local KMS passphrase and getting a token for subsequent use.
   102  err = myWallet.Open(wallet.WithUnlockByPassphrase(samplePassPhrase))
   103  
   104  ```
   105  
   106  > Aries Go SDK Sample for opening a wallet with expiry for profile using local KMS settings.
   107  ```
   108  // creating vcwallet instance for user with local KMS settings.
   109  myWallet, err := vcwallet.New(sampleUserID, ctx)
   110  
   111  // opening a wallet with local KMS secret lock service and getting a token for subsequent use.
   112  err = myWallet.Open(wallet.WithUnlockBySecretLockService(mySecretLockSvc), wallet.WithUnlockExpiry(10 * time.Second))
   113  
   114  ```
   115  
   116  > Aries Go SDK Sample for opening a wallet for profile using web KMS.
   117  ```
   118  // creating vcwallet instance for user with web KMS settings.
   119  myWallet, err := vcwallet.New(sampleUserID, ctx)
   120  
   121  // opening a wallet with web kms auth options and getting a token for subsequent use.
   122  err = myWallet.Open(wallet.WithUnlockWebKMSOptions(opts...))
   123  
   124  ```
   125  
   126  > Aries Go SDK Sample for opening a wallet for profile using web KMS & EDV.
   127  ```
   128  // creating vcwallet instance for user with web KMS settings.
   129  myWallet, err := vcwallet.New(sampleUserID, ctx)
   130  
   131  // opening a wallet with web kms auth options and getting a token for subsequent use.
   132  err = myWallet.Open(wallet.WithUnlockWebKMSOptions(opts...), wallet.WithUnlockEDVOptions(opts...))
   133  
   134  ```
   135  
   136  Refer Go Docs for [UnlockOptions](https://github.com/hyperledger/aries-framework-go/blob/main/pkg/wallet/options.go#L92-L140) various wallet unlock options.
   137  
   138  
   139  ## Closing a Wallet
   140  
   141  A wallet can be closed by simply calling ``Close`` function on wallet. It returns `true` when wallet is closed or `false` if wallet is already closed.
   142  
   143  > Aries Go SDK Sample for closing a wallet.
   144  ```
   145  // creating vcwallet instance for user with local KMS settings.
   146  myWallet, err := vcwallet.New(sampleUserID, ctx)
   147  
   148  // opening a wallet with local KMS passphrase and getting a token for subsequent use.
   149  err = myWallet.Open(wallet.WithUnlockByPassphrase(samplePassPhrase))
   150  
   151  //... perform your operation
   152  
   153  // close the wallet,
   154  ok := myWallet.Close() // returns true
   155  
   156  ```
   157  
   158  
   159  ## Supported Data Models
   160  Currently aries verifiable credential wallet supports following data models from universal wallet,
   161  * [Collection](https://w3c-ccg.github.io/universal-wallet-interop-spec/#Collection) - used for grouping wallet contents. Once added to the wallet content store, the collection ID can be used to map a content of any type. 
   162  So a customized request can be sent to the wallet to get list of all the contents mapped to a given collection ID and content type. 
   163  For example, getting list of credentials from wallet for a collection called 'My Financial Credentials'. 
   164  * [Credential](https://w3c-ccg.github.io/universal-wallet-interop-spec/#Credential) - a verifiable credential data model. Once saved, the ID of the credential can be used directly for various operations verify, prove, derive etc.
   165  * [DIDResolutionResponse](https://w3c-ccg.github.io/universal-wallet-interop-spec/#DIDResolutionResponse) - a DID document resolution data model which can be saved in wallet for subsequent use for issue, prove, derive, verify operations.
   166  Wallet will use DID document resolution data model from content store while resolving DIDs and it falls back to agent's VDR only if it is not found. This model will be very handy for offline usage of wallet. 
   167  * [Metadata](https://w3c-ccg.github.io/universal-wallet-interop-spec/#metadata) - can be used to save any wallet implementation specific custom data. 
   168  For example, saving user's default signing profile info like signature type, controller, verification method.
   169  * [Connection](https://w3c-ccg.github.io/universal-wallet-interop-spec/#connection) - used for saving DIDComm connections.
   170  * [Key](https://w3c-ccg.github.io/universal-wallet-interop-spec/#Key) - key data model, once added to wallet private key from this data model will be imported into wallet profile's key management system. 
   171  Supports both JWK (all curve types supported by aries framework go) & Base58 (Ed25519Signature2018 and Bls12381G1Key2020 key types). This data model is useful in importing keys into wallet.
   172  
   173  ## Wallet Interfaces
   174  The aries verifiable credential wallet provides provides various wallet interfaces including the ones implemented from universal wallet specifications.
   175  
   176  #### [Add](https://w3c-ccg.github.io/universal-wallet-interop-spec/#add)
   177  This interface to be used for adding a data model to the wallet. Except `Key` data model all the data models will be added wallet content store. 
   178  In case of `Key` data model, private key from data model gets imported into wallet profile's key management system.
   179  
   180  Params,
   181  * content type - type of the data model
   182  * content - raw content
   183  * options - like collection ID
   184  
   185  Returns,
   186  * error - if operation fails.
   187  
   188  
   189   > Aries Go SDK Sample for adding a content to wallet.
   190   ```
   191   // creating vcwallet instance.
   192   myWallet, err := vcwallet.New(sampleUserID, ctx)
   193   
   194   // open wallet.
   195   err = myWallet.Open(...)
   196   
   197   // add credential to wallet.
   198   err = myWallet.Add(wallet.Credential, rawCredential)
   199   
   200   // add credential to wallet with collection ID.
   201   err = myWallet.Add(wallet.Credential, sampleCredential,  wallet.AddByCollection(collectionID))
   202   
   203   // add a DID Document.
   204   err = myWallet.Add(wallet.DIDResolutionResponse, resolvedDID)
   205   
   206   // close wallet.
   207   ok = myWallet.Close()
   208    
   209   ```
   210  Note: It is always recommended that a data model which is being added to wallet content store has an ID. If a data model does not have an ID then wallet will use UUID as a key (for remove, get operations).
   211  User `GetAll` interface to list wallet contents and their keys.
   212  
   213  
   214  #### [Remove](https://w3c-ccg.github.io/universal-wallet-interop-spec/#remove)
   215  Removes wallet content by ID from wallet content store. This interface is not supported for `Key` data model since aries KMS doesn't support key remove operations.
   216  
   217  Params,
   218  * content type - type of the data model
   219  * content ID - ID of the wallet content. For example, credential ID in case of credential data model.
   220  
   221  Returns,
   222  * error - if operation fails.
   223  
   224   > Aries Go SDK Sample for removing a content from wallet.
   225   ```
   226   // creating vcwallet instance.
   227   myWallet, err := vcwallet.New(sampleUserID, ctx)
   228   
   229   // open wallet.
   230   err = myWallet.Open(...)
   231   
   232   // remove a credential from wallet.
   233   err = myWallet.Remove(wallet.Credential, credentialID)
   234   
   235   // remove a Metadata from wallet.
   236   err = myWallet.Remove(wallet.Metadata, metadata)
   237   
   238   // close wallet.
   239   ok = myWallet.Close()
   240    
   241   ```
   242   
   243  #### Get
   244  Gets a wallet content by ID from wallet content store. This interface is not supported for `Key` data model.
   245  
   246  Params,
   247  * content type - type of the data model
   248  * content ID - ID of the wallet content. For example, credential ID in case of credential data model.
   249  
   250  Returns,
   251  * json.RawMessage - raw wallet content.
   252  * error - if operation fails or if data not found.
   253  
   254   > Aries Go SDK Sample for getting a content by ID from wallet.
   255   ```
   256   // creating vcwallet instance.
   257   myWallet, err := vcwallet.New(sampleUserID, ctx)
   258   
   259   // open wallet.
   260   err = myWallet.Open(...)
   261   
   262   // get a credential from wallet.
   263   credential, err = myWallet.Get(wallet.Credential, credentialID)
   264   
   265   // get a connection from wallet.
   266   connection, err = myWallet.Get(wallet.Connection, connectionID)
   267   
   268   // close wallet.
   269   ok = myWallet.Close()
   270    
   271   ```
   272   
   273  #### GetAll
   274  Gets all content from wallet content store for given content type. This interface is not supported for `Key` data model.
   275  
   276  Params,
   277  * content type - type of the data model
   278  * options - collection ID to filter results by collection ID
   279  
   280  Returns,
   281  * map[string]json.RawMessage - map of content keys to raw contents.
   282  * error - if operation fails.
   283  
   284   > Aries Go SDK Sample for getting all contents from wallet for given content type.
   285   ```
   286   // creating vcwallet instance.
   287   myWallet, err := vcwallet.New(sampleUserID, ctx)
   288   
   289   // open wallet.
   290   err = myWallet.Open(...)
   291   
   292   // get all credentials from wallet for given collection ID.
   293   credentials, err = myWallet.GetAll(wallet.Credential, wallet.FilterByCollection(collectionID))
   294   
   295   // get all connections from wallet.
   296   connections, err = myWallet.Get(wallet.Connection)
   297   
   298   // close wallet.
   299   ok = myWallet.Close()
   300    
   301   ```
   302  
   303  #### [Issue](https://w3c-ccg.github.io/universal-wallet-interop-spec/#issue)
   304  Adds proof to a credential and returns verifiable credential as a response. 
   305  
   306  Params,
   307  * credential - raw credential to which proof has to be added.
   308  * options - proof options.
   309      * controller - DID to be for signing.
   310      * verification method (optional) - is the URI of the verificationMethod used for the proof. By default controller public key matching 'assertion'. 
   311      * created (optional) - created date of the proof. By default, current system date will be used.
   312      * domain (optional) - is operational domain of a digital proof.
   313      * challenge (optional) -  is a random or pseudo-random value option for generating digital proof.
   314      * proof type (optional) - is signature type used for signing. Default, Ed25519Signature2018.
   315      * proof representation (optional) -  is type of proof data expected. Default, "proofValue".
   316  
   317  Returns,
   318  * *verifiable.Credential - credential issued.
   319  * error - if operation fails.
   320  
   321   > Aries Go SDK Sample for issuing a credential from wallet.
   322   ```
   323   // creating vcwallet instance.
   324   myWallet, err := vcwallet.New(sampleUserID, ctx)
   325   
   326   // open wallet.
   327   err = myWallet.Open(...)
   328   
   329   // Adding proof to raw credential using controller.
   330   vc, err := myWallet.Issue(rawCredential, &wallet.ProofOptions{
   331                                     			Controller: myDID,
   332                                     		})
   333   
   334   // close wallet.
   335   ok = myWallet.Close()
   336    
   337   ``` 
   338  
   339  #### [Verify](https://w3c-ccg.github.io/universal-wallet-interop-spec/#verify)
   340  Verifies a given verifiable credential or verifiable presentation.
   341  
   342  Params,
   343  * options - proof options.
   344      * store credential  - ID of the stored credential from wallet.
   345      * raw credential  - raw JSON bytes of verifiable credential.
   346      * raw presentation  - raw JSON bytes of verifiable presentation.
   347  
   348  Returns,
   349  * bool - true if verified.
   350  * error - if verification fails.
   351  
   352   > Aries Go SDK Sample for issuing a credential using wallet.
   353   ```
   354   // creating vcwallet instance.
   355   myWallet, err := vcwallet.New(sampleUserID, ctx)
   356   
   357   // open wallet.
   358   err = myWallet.Open(...)
   359   
   360   // Verifying a credential from wallet content store.
   361   verified, err := myWallet.Verify(wallet.WithStoredCredentialToVerify("http://example.edu/credentials/1872"))
   362   
   363   // Verifying a raw credential.
   364   verified, err = myWallet.Verify(wallet.WithRawCredentialToVerify(credentialBytes))
   365   
   366   // Verifying a raw presentation.
   367   verified, err = myWallet.Verify(wallet.WithRawPresentationToVerify(rawPresentation))
   368     
   369   // close wallet.
   370   ok = myWallet.Close()
   371    
   372   ``` 
   373  
   374  #### [Prove](https://w3c-ccg.github.io/universal-wallet-interop-spec/#prove)
   375  Produces a Verifiable Presentation.
   376  
   377  Params,
   378  * credential options - various options to present credentials.
   379      * stored credentials - list of credential IDs from wallet. 
   380      * raw credentials - list of raw JSON bytes of credentials. 
   381      * credentials - list of aries verifiable credential data models.
   382      * presentation - aries verifiable presentation data model.
   383      * raw presentation  - raw JSON bytes of verifiable presentation.
   384  * options - proof options.
   385      * controller - DID to be for signing.
   386      * verification method (optional) - is the URI of the verificationMethod used for the proof. By default controller public key matching 'authentication'. 
   387      * created (optional) - created date of the proof. By default, current system date will be used.
   388      * domain (optional) - is operational domain of a digital proof.
   389      * challenge (optional) -  is a random or pseudo-random value option for generating digital proof.
   390      * proof type (optional) - is signature type used for signing. Default, Ed25519Signature2018.
   391      * proof representation (optional) -  is type of proof data expected. Default, "proofValue".
   392  Refer [Go Docs](https://github.com/hyperledger/aries-framework-go/blob/main/pkg/wallet/options.go#L157-L197) for more details.
   393  
   394  Returns,
   395  * *verifiable.Presentation - presentation produced of aries verifiable presentation data model type.
   396  * error - if operation fails.
   397  
   398   > Aries Go SDK Sample for proving credentials using wallet.
   399   ```
   400   // creating vcwallet instance.
   401   myWallet, err := vcwallet.New(sampleUserID, ctx)
   402   
   403   // open wallet.
   404   err = myWallet.Open(...)
   405   
   406   // Producing a presentation using credentials in wallet content store.
   407   vp, err := myWallet.Prove(&wallet.ProofOptions{Controller: myDID}, wallet.WithStoredCredentialsToProve(id1, id2, id3, id4))
   408   
   409   // Producing a presentation using raw credentials.
   410   vp, err := myWallet.Prove(&wallet.ProofOptions{Controller: myDID}, wallet.WithRawCredentialsToProve(raw1, raw2))
   411   
   412   // Producing a presentation using mixed options.
   413   vp, err := myWallet.Prove(&wallet.ProofOptions{Controller: myDID}, 
   414                                 wallet.WithStoredCredentialsToProve(id1, id2, id3, id4), 
   415                                 wallet.WithRawCredentialsToProve(raw1, raw2),
   416                              )
   417     
   418   // close wallet.
   419   ok = myWallet.Close()
   420    
   421   ``` 
   422  
   423  #### [Derive](https://w3c-ccg.github.io/universal-wallet-interop-spec/#derive)
   424  Derives a credential and returns response credential.
   425  
   426  Params,
   427  * credential to derive - various options to provide credential to be derived from.
   428      * store credential  - ID of the stored credential from wallet.
   429      * raw credential  - raw JSON bytes of verifiable credential.
   430      * credential  - aries verifiable credential data model.
   431  * derive options - options to derive.
   432      * frame - JSON-LD frame used for deriving (selective disclosure).
   433      * nonce -  to prove uniqueness or freshness of the proof. 
   434  
   435  Returns,
   436  * *verifiable.Credential - credential derived of aries verifiable credential data model type.
   437  * error - if operation fails.
   438  
   439   > Aries Go SDK Sample for deriving credentials using wallet.
   440   ```
   441   // creating vcwallet instance.
   442   myWallet, err := vcwallet.New(sampleUserID, ctx)
   443   
   444   // open wallet.
   445   err = myWallet.Open(...)
   446   
   447   // Derive a credential from wallet content store.
   448   derivedVC, err := myWallet.Derive(wallet.FromStoredCredential("http://example.edu/credentials/1872"),
   449                              			&wallet.DeriveOptions{
   450                              				Nonce: nonce,
   451                              				Frame: frameDoc,
   452                              			})
   453   
   454   // Derive a credential from a raw credential.
   455   derivedVC, err := myWallet.Derive(wallet.FromRawCredential(rawCredential),
   456                              			&wallet.DeriveOptions{
   457                              				Nonce: nonce,
   458                              				Frame: frameDoc,
   459                              			})
   460   
   461   // Derive a credential from credential object.
   462   derivedVC, err := myWallet.Derive(wallet.FromCredential(credentialObj),
   463                              			&wallet.DeriveOptions{
   464                              				Nonce: nonce,
   465                              				Frame: frameDoc,
   466                              			})
   467     
   468   // close wallet.
   469   ok = myWallet.Close()
   470    
   471   ``` 
   472  
   473  #### CreateKeyPair
   474  Creates key pair inside a wallet, imports private key into wallet and returns key ID and public key bytes.
   475  
   476  Params,
   477  * key Type - all supported [key types](https://github.com/hyperledger/aries-framework-go/blob/34ff560ed041fd9d3255a0c8c7f99c584c1c0a74/pkg/kms/api.go#L125-L171) by aries.
   478  
   479  Returns,
   480  * KeyPair - key pair result.
   481      * Key ID
   482      * Public Key
   483  * error - if operation fails.
   484  
   485   > Aries Go SDK Sample for creating key pair using wallet.
   486   ```
   487   // creating vcwallet instance.
   488   myWallet, err := vcwallet.New(sampleUserID, ctx)
   489   
   490   // open wallet.
   491   err = myWallet.Open(...)
   492   
   493   // Create ED52519 key pair.
   494   keyPair, err := myWallet.CreateKeyPair(kms.ED52519)
   495     
   496   // close wallet.
   497   ok = myWallet.Close()
   498    
   499   ``` 
   500  
   501  #### [Query](https://w3c-ccg.github.io/universal-wallet-interop-spec/#query)
   502  Performs credential query in the wallet.
   503  
   504  Supported query types 
   505  * [QueryByExample](https://w3c-ccg.github.io/vp-request-spec/#query-by-example)
   506  * [QueryByFrame](https://github.com/w3c-ccg/vp-request-spec/issues/8)
   507  * [PresentationExchange](https://identity.foundation/presentation-exchange/)
   508  * [DIDAuth](https://w3c-ccg.github.io/vp-request-spec/#did-authentication-request)
   509  
   510  Params,
   511  * queries - in vp-request-spec query list format. Supports mutliple queries
   512   > Sample queries
   513  ```
   514    query: [{
   515        type: 'APopularQueryType',
   516        // query details ...
   517      }, {
   518        type: 'AnotherQueryType',
   519        // query details ...
   520      }]
   521    
   522   ``` 
   523   
   524   Returns,
   525   * []*verifiable.Presentation - list of verifiable presentations. 
   526   Typically returns single presentation, but if PresentaionExchange is mixed with other query types then response may contain multiple presentations ([scenario explaind here](https://github.com/w3c-ccg/universal-wallet-interop-spec/issues/85)).
   527   
   528    > Aries Go SDK Sample for querying credentials from wallet.
   529    ```
   530    // creating vcwallet instance.
   531    myWallet, err := vcwallet.New(sampleUserID, ctx)
   532    
   533    // open wallet.
   534    err = myWallet.Open(...)
   535    
   536    // Query using QueryByExample.
   537    results, err := myWallet.Query([]*wallet.QueryParams{{Type: "QueryByExample", Query: exampleQuery}})
   538    
   539    // Query using QueryByFrame.
   540    results, err = myWallet.Query([]*wallet.QueryParams{{Type: "QueryByFrame", Query: frameQuery}})
   541    
   542    // Query using PresentationExchange.
   543    results, err = myWallet.Query([]*wallet.QueryParams{{Type: "PresentationExchange", Query: presentationDefn}})
   544    
   545    // Multiple QueryByExample queries.
   546    results, err = myWallet.Query([]*wallet.QueryParams{
   547      {Type: "QueryByExample", Query: exampleQuery1}},
   548      {Type: "QueryByExample", Query: exampleQuery2}},
   549      {Type: "QueryByExample", Query: exampleQuery3}},
   550    )
   551      
   552    // Mixed queries.
   553    results, err = myWallet.Query([]*wallet.QueryParams{
   554      {Type: "QueryByExample", Query: exampleQuery1}},
   555      {Type: "QueryByFrame", Query: exampleQuery2}},
   556      {Type: "QueryByExample", Query: exampleQuery3}},
   557    )
   558        
   559    // close wallet.
   560    ok = myWallet.Close()
   561     
   562    ``` 
   563  
   564  #### [Connect](https://github.com/hyperledger/aries-rfcs/blob/master/features/0434-outofband/README.md)
   565  Performs out of band DID exchange from wallet by accepting out of band invitation.
   566  
   567  Params,
   568  * invitation - out of band invitation from inviter.
   569  * connect options - for out of band accept invitation.
   570      * MyLabel - label to be shared with the other agent during the subsequent did-exchange.
   571      * RouterConnections - option to provide for router connections to be used.
   572      * ReuseConnection -  option to provide DID to be used when reusing a connection.
   573      * ReuseAnyConnection - option to use any recognized DID in the services array for a reusable connection.
   574      * Timeout - option to provide timeout to wait for connection status to be completed.
   575  
   576  Returns,
   577  * connectionID - ID of the connection established.
   578  * error - if operation fails.
   579  
   580   > Aries Go SDK Sample for performing DID connect from wallet.
   581   ```
   582   // creating vcwallet instance.
   583   myWallet, err := vcwallet.New(sampleUserID, ctx)
   584   
   585   // open wallet.
   586   err = myWallet.Open(...)
   587   
   588   // accept an invitation from wallet, perform DID connect and return connection ID.
   589   connectionID, err := myWallet.Connect(oobInvitation, wallet.WithConnectTimeout(30 * time.Second), wallet.WithMyLabel("alice wallet"))
   590     
   591   // close wallet.
   592   ok = myWallet.Close()
   593    
   594   ``` 
   595  
   596  #### [ProposePresentation](https://w3c-ccg.github.io/universal-wallet-interop-spec/#proposepresentation)
   597  Proposing presentation from wallet to initiate WACI share flow.
   598  
   599  Params,
   600  * invitation - out of band invitation from inviter.
   601  * options - for sending propose presentation message.
   602      * FromDID - option to provide customized from DID for sending propose presentation message.
   603      * Timeout - option to provide timeout duration to wait for request presentation response from relying party.
   604  
   605  Returns,
   606  * DIDCommMsg - request presentation message from relying party.
   607  * error - if operation fails.
   608  
   609   > Aries Go SDK Sample for sending propose presentation message from wallet to relying party.
   610   ```
   611   // creating vcwallet instance.
   612   myWallet, err := vcwallet.New(sampleUserID, ctx)
   613   
   614   // open wallet.
   615   err = myWallet.Open(...)
   616   
   617   // accept an invitation from wallet, perform DID connect, send propose presentation message, wait and 
   618   // return request presentation message response from relying party.
   619   connectionID, err := myWallet.ProposePresentation(oobInvitation, wallet.WithInitiateTimeout(80 * time.Second), wallet.WithFromDID("did:example:wallet"))
   620     
   621   // close wallet.
   622   ok = myWallet.Close()
   623    
   624   ``` 
   625   
   626   #### [PresentProof](https://w3c-ccg.github.io/universal-wallet-interop-spec/#presentproof)
   627   Presenting proof to relying party from wallet for WACI share flow.
   628   
   629   Params,
   630   * threadID - thread ID of ongoing credential interaction with a relying party.
   631   * presentation - presentation to be sent to relying party.
   632   
   633   Returns,
   634   * error - if operation fails.
   635   
   636   ######TODO: support for ack message from relying party to be added for wallet redirects.
   637   
   638    > Aries Go SDK Sample for sending present proof message from wallet to relying party.
   639    ```
   640    // creating vcwallet instance.
   641    myWallet, err := vcwallet.New(sampleUserID, ctx)
   642    
   643    // open wallet.
   644    err = myWallet.Open(...)
   645    
   646    // send presentation to relying party as present proof message attachment for ongoing credential interaction.
   647    connectionID, err := myWallet.PresenProof(threadID, presentation)
   648      
   649    // close wallet.
   650    ok = myWallet.Close()
   651     
   652    ``` 
   653  
   654  #### [ProposeCredential](https://w3c-ccg.github.io/universal-wallet-interop-spec/#proposecredential)
   655  Sends propose credential message from wallet to issuer, waits for offer credential message from issuer and returns incoming message.
   656  
   657  Params,
   658  * invitation - out of band invitation from inviter.
   659  * options - for sending propose presentation message.
   660    * FromDID - option to provide customized from DID for sending propose presentation message.
   661    * ConnectOptions - customized options for accepting invitation..
   662    * Timeout - option to provide timeout duration to wait for offer credential message from issuer.
   663  
   664  Returns,
   665  * DIDCommMsg - offer credential message from issuer.
   666  * error - if operation fails.
   667  
   668  > Aries Go SDK Sample for sending propose credential message from wallet to issuer.
   669   ```
   670   // creating vcwallet instance.
   671   myWallet, err := vcwallet.New(sampleUserID, ctx)
   672   
   673   // open wallet.
   674   err = myWallet.Open(...)
   675   
   676   // accept an invitation from wallet, perform DID connect, send propose credential message, wait and 
   677   // return offer credential message response from issuer.
   678   connectionID, err := myWallet.ProposeCredential(oobInvitation, wallet.WithInitiateTimeout(80 * time.Second), wallet.WithFromDID("did:example:wallet"))
   679     
   680   // close wallet.
   681   ok = myWallet.Close()
   682    
   683   ``` 
   684  
   685  
   686  #### [RequestCredential](https://w3c-ccg.github.io/universal-wallet-interop-spec/#requestcredential)
   687  Sends request credential message from wallet to issuer and optionally waits for credential response.
   688  
   689  Params:
   690  * thID: thread ID (action ID) of offer credential message previously received.
   691  * concludeInteractionOptions: options to conclude interaction like presentation to be shared etc.
   692    * rawPresentation - requesting credential from raw credential.
   693    * presentation presenting proof or requesting credential from verifiable presentation instance. This option takes precedence when provided with other options.
   694    * waitForDone - if provided then wallet will wait till it gets acknowledgement or problem report from other party. 
   695    * timeout - time duration to wait for status to be done or abanoned.
   696  
   697  Returns:
   698  * Credential interaction status containing status, redirectURL.
   699  * error if operation fails.
   700  
   701  > Aries Go SDK Sample for sending request credential message from wallet to issuer.
   702    ```
   703    // creating vcwallet instance.
   704    myWallet, err := vcwallet.New(sampleUserID, ctx)
   705    
   706    // open wallet.
   707    err = myWallet.Open(...)
   708    
   709    // send request credential message to issuer for ongoing credential interaction.
   710    connectionID, err := myWallet.RequestCredential(threadID, wallet.FromPresentation(application))
   711      
   712    // close wallet.
   713    ok = myWallet.Close()
   714     
   715    ``` 
   716  
   717  #### ResolveCredentialManifest
   718  Resolves given credential manifest by credential response or credential.
   719  Supports: https://identity.foundation/credential-manifest/
   720  
   721  Params,
   722  * manifest: Credential manifest data model in raw format.
   723  * resolve: to provide credential response or credential to resolve.
   724  
   725  Returns,
   726  * list of resolved descriptors.
   727  * error if operation fails.
   728  
   729  > Aries Go SDK Sample for resolving credential manifest by response.
   730    ```
   731    // creating vcwallet instance.
   732    myWallet, err := vcwallet.New(sampleUserID, ctx)
   733    
   734    // open wallet.
   735    err = myWallet.Open(...)
   736    
   737    // resolve credential manifest by raw credential response.
   738    connectionID, err := myWallet.ResolveCredentialManifest(threadID, wallet.ResolveRawResponse(response))
   739      
   740    // close wallet.
   741    ok = myWallet.Close()
   742     
   743    ``` 
   744  
   745  ## Controller Bindings
   746  Aries command controller supports all verifiable credential wallet features with many more customization options like Authorization Capabilities (ZCAP-LD) feature for wallet's EDV and WebKMS components.
   747  
   748  Refer [Go Docs](https://github.com/hyperledger/aries-framework-go/blob/main/pkg/controller/command/vcwallet/command.go) for package for more details.
   749  
   750  
   751  #### JavaScript
   752  Aries verifiable credential wallet is [available](https://github.com/hyperledger/aries-framework-go/blob/main/cmd/aries-js-worker/src/aries.js#L1080-L1273) as both Aries JavaScript WebAssembly and REST JS versions.
   753    > Sample Aries JS wallet operations.
   754    ```
   755    
   756  // create agent instance
   757  let agent = new Agent.Framework(agentOpts)
   758  
   759  // create profile
   760  await agent.vcwallet.createProfile({userID, keyStoreURL, edvConfiguration})
   761  
   762  // open wallet
   763  let auth = await agent.vcwallet.open({userID, webKMSAuth, edvUnlocks, expiry})
   764  
   765  // add content
   766  await agent.vcwallet.add({userID, auth, contentType, collectionID, content})
   767  
   768  // get content
   769  let {content} = await agent.vcwallet.get({userID, auth, contentType, contentID})
   770  
   771  // get all content
   772  let {contents} = await agent.vcwallet.getAll({userID, auth, contentType})
   773  
   774  // remove content
   775  let {content} = await agent.vcwallet.remove({userID, auth, contentType, contentID})
   776  
   777  // query by QueryByExample & QueryByFrame
   778  let {results} = await agent.vcwallet.query({userID: this.user, auth, [{
   779          "type": "QueryByFrame",
   780          "credentialQuery": [{
   781              "reason": "Please provide your Passport details.",
   782              "frame": {
   783                  "@context": ["https://www.w3.org/2018/credentials/v1", "https://w3id.org/citizenship/v1", "https://w3id.org/security/bbs/v1"],
   784                  "type": ["VerifiableCredential", "PermanentResidentCard"],
   785                  "@explicit": true,
   786                  "identifier": {},
   787                  "issuer": {},
   788                  "issuanceDate": {},
   789                  "credentialSubject": {"@explicit": true, "name": {}, "spouse": {}}
   790              },
   791              "trustedIssuer": [{"issuer": "did:example:76e12ec712ebc6f1c221ebfeb1f", "required": true}],
   792              "required": true
   793          }]
   794      }, {
   795      "type": "QueryByExample",
   796          "credentialQuery": [{
   797          "reason": "Please present your valid degree certificate.",
   798          "example": {
   799              "@context": ["https://www.w3.org/2018/credentials/v1", "https://www.w3.org/2018/credentials/examples/v1"],
   800              "type": ["UniversityDegreeCredential"],
   801              "trustedIssuer": [
   802                  {"issuer": "urn:some:required:issuer"},
   803                  {
   804                      "required": true,
   805                      "issuer": "did:example:76e12ec712ebc6f1c221ebfeb1f"
   806                  }
   807              ],
   808              "credentialSubject": {"id": "did:example:ebfeb1f712ebc6f1c276e12ec21"}
   809          }
   810      }]
   811  }
   812  ]})
   813  
   814  
   815  // issue credential
   816  let vc = await agent.vcwallet.issue({userID, auth, credential, {controller}})
   817  
   818  // verify credential
   819  let verified = await agent.vcwallet.verify({userID auth, storedCredentialID, rawCredential, presentation})
   820  
   821  // prove credential
   822  let vp = await agent.vcwallet.prove({userID, auth, storedCredentials, rawCredentials, presentation, {controller}})
   823  
   824  // derive credential
   825  let derived = await agent.vcwallet.derive({userID, auth, storedCredentialID, rawCredential, deriveOption})
   826  
   827  // create key pair
   828  let vc = await agent.vcwallet.createKeyPair({userID, auth, keyType})
   829  
   830  // accept invitation and connect
   831  let connection = await agent.vcwallet.connect({userID, auth, invitation})
   832  
   833  // send propose presentation message from wallet for WACI share flow.
   834  let requestPresentationMsg = await agent.vcwallet.proposePresentation({userID, auth, invitation, from})
   835  
   836  // send present proof message from wallet for WACI share flow.
   837  await agent.vcwallet.presentProof({userID, auth, threadID, presentation})
   838  
   839  // accept invitation, send propose credential message and wait for offer presentation.
   840  let offer = await wallet.proposeCredential(invitation, "did:example:holder", someTimeout)
   841  
   842  // send request credential message, wait for ack and return credential response.
   843  let fulfilment = await wallet.requestCredential(thID, presentation, waitForAck, someTimeout)
   844  
   845  // close wallet
   846  await agent.vcwallet.close({userID})
   847    
   848    ```
   849  
   850  #### REST
   851  Refer Aries Open API specifications for ``vcwallet`` operation ID.
   852  
   853  
   854  #### Mobile (Work In Progress)