> For the complete documentation index, see [llms.txt](https://dev-en.omnione.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dev-en.omnione.net/sdk-instruction-guide/core-sdk-guide/java-wallet/iwkeymanager.md).

# IWKeyManager

API - IWKeyManager

## Constructor

```
public IWKeyManagerImpl(String keyFile_pathWithName) throws IWException
```

Description

* please call the constructor by designating the name and path

parameter

| Type   | Name |                                  Description |
| ------ | :--: | -------------------------------------------: |
| String | name | The file name of Wallet (file path included) |

Throws

* IWException

### isUnLock

```
public boolean isUnLock()
```

Description

* Check whether the Wallet status is unlocked or not

### lock

```
public boolean lock()
```

Description

* For the privacy data protection, change wallet to the Lock status

Return

* boolean: true (Locked successfully)

### unLock

```
public void unLock(String pwdOrAlias, OnUnLockListener listener) throws IWException
```

Description

* Changing the status of the Wallet to unlock by using password

Parameter

| Type             |    Name    | Description |
| ---------------- | :--------: | ----------: |
| String           | pwdOrAlias |    Password |
| OnUnLockListener |  listener  |    Callback |

#### OnUnLockListener

* onSuccess()
* onFail(int errCode)

| Type |   Name  |         Description |
| ---- | :-----: | ------------------: |
| int  | errCode | Occuring error code |

* onCancel()

Throws

* IWException

### isExistKey

```
public boolean isExistKey(String keyId) throws IWException
```

Description

* Use Key ID to check whether the corresponding key exists.&#x20;

  Constraint: only works when it is on a unlock status

Parameter

| Type   |  Name | Description |
| ------ | :---: | ----------: |
| String | keyId |      Key ID |

Return

* boolean: true (the corresponding key exists to the Key ID)

Throws

* IWException

### addKey

```
public void addKey(IWKey key) throws IWException
```

Description

* Add Key
* Key Manager operates only on the unlock status

Parameter

| Type  | Name |                         Description |
| ----- | :--: | ----------------------------------: |
| IWKey |  key | Public Key and Private Key to store |

Throws

* IWException

### removeKey

```
public void removeKey(String keyId) throws IWException
```

Description

* Use Key ID to remove the corresponding Key.
* Key Manager operates only on the unlock status.

Parameter

| Type   |  Name |                     Description |
| ------ | :---: | ------------------------------: |
| String | keyId | Key ID of the Key to be removed |

Throws

* IWException

### getKeyIdList

```
public List<String> getKeyIdList() throws IWException
```

Description

* Search the whole list of the Key ID that is stored.

Return

* List< String >  : List of Key ID&#x20;

Throws

* IWException

### getPublicKey

```
public String getPublicKey(String keyId) throws IWException
```

Description

* Use Key ID to search Public key.

Parameter

| Type   |  Name |                 Description |
| ------ | :---: | --------------------------: |
| String | keyId | Key ID of the Key to search |

Return

* String:  Public Key -  \[Base58]

Throws

* IWException

### getSign

```
public byte[] getSign(String keyId, byte[] source) throws IWException
```

Description

* Use Key ID to sign the source.

  Constraint: only works when it is on a unlock status

Parameter

| Type    |  Name  |                              Description |
| ------- | :----: | ---------------------------------------: |
| String  |  keyId | Key Id of the Key to be used for signing |
| byte\[] | source |                       Source for signing |

Return

byte\[] : (Signature) - \[byte array]

Throws

* IWException

### addClaim

```
public boolean addClaim(String claimJSON) throws IWException
```

Description

* Add Claim(JSON)

  Constraint: only works when it is on a unlock status

Parameter

| Type   |     Name    |              Description |
| ------ | :---------: | -----------------------: |
| String | claimJSONtp | Claim(JSON) to be stored |

Return

* boolean: true (Stored successfully)

Throws

* IWException

### getClaims

```
public List<VerifiableClaim> getClaims() throws IWException
```

Description

* search the whole list of claims that are stored

Return

* List< VerifiableClaim >: the whole list of claims that are stored

Throws

* IWException

### Filtering Condition

```
Filter condition has to obey below rules :
space must be included between object, condition, and value
It follows property's name

#object name condition
object must be connnected with dot(.)
like below

claim.id

#bool value action condition
== : equal value

#string object action condition
== : exactly same value
!= : without that value

#number value action condition
== : equal value
!= : not equal value
> : greater than the value
>= : greater than the value or equal
< : less than the value
<= : less than the value or equal


e.g.
"id == somewhat"
```

### getClaims(filter)

```
 public List<VerifiableClaim> getClaims(String filter) throws IWException
```

Description

* Get specific Claims with filtering Condition

Parameter

| Type   |  Name  |             Description |
| ------ | :----: | ----------------------: |
| String | filter | Condition for filtering |

Return

* List< VerifiableClaim >     : Array of Claims

Throws

* IWException

### removeClaim(int) - No indication for exception

```
public void removeClaim(int index) throws IWException
```

Description

* Remove claim by using Index.

  Constraint: Only works when it is on a unlock status

Parameter

| Type |  Name |   Description |
| ---- | :---: | ------------: |
| int  | index | Claim's index |

### removeClaim(VerifiableClaim)

```
 public void removeClaim(VerifiableClaim claim) throws IWException
```

Description

* Search then remove a claim from the list that matches with the inputted claim

Parameter

| Type            |  Name |  Description |
| --------------- | :---: | -----------: |
| VerifiableClaim | claim | Claim object |

Throws

* IWException

### removeClaims(filter)

```
 public void removeClaims(String filter) throws IWException
```

Description

* Use filtering functions to remove a searchable claim&#x20;

Parameter

| Type   |  Name  |         Description |
| ------ | :----: | ------------------: |
| String | filter | filtering condition |

Throws

* IWException

### getECIESEncryptBytes

```
 public byte[] getECIESEncryptBytes(String keyId, byte[] nonce, String publicKey, byte[] source, AESType aesType) throws IWException
```

Description

* Get encrypted data via the Elliptic Curve Integrated Encryption Scheme using AES Encryption &#x20;

  Constraint: Only works when it is on a unlock status

Parameter

| Type    |    Name   |                Description |
| ------- | :-------: | -------------------------: |
| String  |   keyId   |                     Key ID |
| byte\[] |   nonce   |               random value |
| String  | publicKey | public key(Base58 encoded) |
| byte\[] |   source  |      plain text to encrypt |
| AESType |  aesType  |           AES128 or AES256 |

Return

* byte\[]: encrypted data

Throws

* IWException

### getECIESDecryptBytes

```
 public byte[] getECIESDecryptBytes(String keyId, byte[] nonce, String publicKey, byte[] source, AESType aesType) throws IWException
```

Description

* Get decrypted data via Elliptic Curve Integrated Decryption Scheme using AES Decryption &#x20;

  Key Manager status must be at an unlocked state.

Parameter

| Type    |    Name   |                Description |
| ------- | :-------: | -------------------------: |
| String  |   keyId   |                     Key ID |
| byte\[] |   nonce   |               random value |
| String  | publicKey | public key(Base58 encoded) |
| byte\[] |   source  |                 ciphertext |
| AESType |  aesType  |           AES128 or AES256 |

Return

* byte\[]           : Decrypted Data for Success

Throws

* IWException

### readKeyFileHeader

```
public String readKeyFileHeader() throws IWException
```

Description

* Search Wallet's Header with the JSON format.

Return

* String: Wallet's Header (JSON)

Throws

* IWException

### deleteWalletFile - Insufficient

```
public void deleteWalletFile()
```

Description

* Remove the Wallet file. (if exists)

### makeRequestVerifiableClaim

```
public String makeRequestVerifiableClaim(String dId, Privacy privacy)
```

Description

* create a request with full-text(JSON) for issuing the Verifiable Claim

Parameter

| Type    |   Name  |                  Description |
| ------- | :-----: | ---------------------------: |
| String  |   did   |                 Signer's DID |
| Privacy | privacy | Privacy Object of the signer |

Return

* String:  request with full-text(JSON) for issuing the Verifiable Claim

Next Step

> makeProof

### makeRequestVerifiableClaimCopy

```
public String makeRequestVerifiableClaimCopy(String verifiableClaimJSON, Privacy privacy, ServiceProviderProfile spProfile, String expires) throws IWException
```

Description

* Create the Verifiable Claim Copy(JSON)

Parameter

| Type                   |         Name        |             Description |
| ---------------------- | :-----------------: | ----------------------: |
| String                 | verifiableClaimJSON |  Verifiable Claim(JSON) |
| Privacy                |       privacy       | Signer's Privacy Object |
| ServiceProviderProfile |      spProfile      | Service Provider Object |
| String                 |       expires       |             expiry date |

Return

* String: Verifiable Claim Copy JSON String

Throws

* IWException

Next Step

> makeProof

### makeProof

```
 public String makeProof(String verifiableClaimJSON, String signKeyId, byte[] nonce, IWKeyManager keyManager) throws IWException
```

Description

* Create proof for the submission.

Parameter

| Type         |         Name        |                                Description |
| ------------ | :-----------------: | -----------------------------------------: |
| String       | verifiableClaimJSON |                     Verifiable Claim(JSON) |
| String       |      signKeyId      |            Key ID of the Key for signature |
| byte\[]      |        nonce        |                               random value |
| IWKeyManager |      keyManager     | the instance of the IWKeyManager interface |

Return

* String: JSON String consisting of Verifiable Ciam with Proof

Throws

* IWException
