## cip sub-class
The following readme describes all the functions and their parameters exposed by the `cip` class of the Stakehouse SDK.

## generateAESCredentials function
This function allows users to generate hybrid AES credentials.  

### Using generateAESCredentials function
```js
await sdk.cip.generateAESCredentials();
```

### Return Parameter
Hybrid public key and hybrid private key  

## formAESKeystore function
This function allows users to create hybrid keystore protected by their password.  

### Input Parameters
hybridPrivateKey: hybrid private key to form the keystore  
password: password to protect the keystore  

### Using formAESKeystore function
```js
await sdk.cip.formAESKeystore(hybridPrivateKey, password);
```

### Return Parameter
Returns the keystore  

## formBLSKeystore function
This function allows users to create a BLS keystore, protected by a password, for their BLS signing key.  

### Input Parameters
blsSigningKey: BLS singing key to form the keystore  
password: password to protect the keystore  

### Using formBLSKeystore function
```js
await sdk.cip.formBLSKeystore(blsSigningKey, password);
```

### Return Parameter
Returns the keystore

## unlockBLSKeystore function
This function allows users to unlock their BLS keystore and get the BLS private key and public key.  

### Input Parameters
keystore: BLS keystore  
password: password of BLS Keystore  

### Using unlockBLSKeystore function
```js
await sdk.cip.unlockBLSKeystore(keystore, password);
```

### Return Parameter
Returns the BLS private key and public key  

## validateBLSKeystore function
This function allows users to validate the BLS keystore.  

### Input Parameters
keystore: BLS keystore  
password: password of BLS Keystore  
blsPublicKey: BLS Public Key  

### Using validateBLSKeystore function
```js
await sdk.cip.validateBLSKeystore(keystore, password, blsPublicKey);
```

### Return Parameter
Returns `true` if the provided BLS public key matches the public key of the BLS keystore. If the password is incorrect, it throws error.  

## unlockAESPrivateKey function
This function allows users to unlock AES keystore only if the BLS public key is associated with the AES keystore.  

### Input Parameters
keystore: AES keystore  
password: password of AES Keystore  
blsPublicKey: BLS Public Key  

### Using unlockAESPrivateKey function
```js
await sdk.cip.unlockAESPrivateKey(keystore, password, blsPublicKey);
```

### Return Parameter
Returns the AES private key.  

## formCIPCiphertext function
This function allows users to form ciphertext for CIP procedure.

### Input Parameters
blsPublicKey: BLS Public Key  

### Using formCIPCiphertext function
```js
await sdk.cip.formCIPCiphertext(blsPrivateKey)
```

### Return Parameter
Returns ciphertext.  

## reEncrypt function
This function allows users to form a new ciphertext and encrypt the signing key for the Ethereum network.

### Input Parameters
blsPublicKey: BLS Public Key of the KNOT  
stakehouseAddress: Stakehouse address of the KNOT  
blsKeystore: BLS keystore associated with the blsPublicKey  
blsKeystorePassword: password of the BLS keystore  

### Using reEncrypt function
```js
await sdk.cip.reEncrypt(blsPublicKey, stakehouseAddress, blsKeystore, blsKeystorePassword);
```

### Return Parameter
Returns transaction data.  

## isReEncryptionCompleted function
This function allows users to know the status of re-encryption.  

### Input Parameters
blsPublicKey: BLS Public Key of the KNOT  

### Using isReEncryptionCompleted function
```js
await sdk.cip.isReEncryptionCompleted(blsPublicKey);
```

### Return Parameter
Returns `true` if status is completed, otherwise `false`.  

## applyForDecryption function
This function allows users to apply for the decryption procedure.  

### Input Parameters
blsPublicKey: BLS Public Key of the KNOT  
stakehouseAddress: Stakehouse address of the KNOT  
aesPublicKey: AES public key  

### Using applyForDecryption function
```js
await sdk.cip.applyForDecryption(blsPublicKey, stakehouseAddress, aesPublicKey);
```

### Return Parameter
Returns the transaction data.  

## getRequestAvailabilityBlock function
This function allows users to get the block at which request can be made for the specific BLS public key.  

### Input Parameters
blsPublicKey: BLS Public Key of the KNOT  

### Using getRequestAvailabilityBlock function
```js
await sdk.cip.getRequestAvailabilityBlock(blsPublicKey);
```

### Return Parameter
Returns the block number in case of delay, `0` otherwise.  

## getPartialDecryptionPieces function
This function allows users to fetch partial decryption pieces.  

### Input Parameters
blsPublicKey: BLS Public Key of the KNOT  
aesPublicKey: AES public key  

### Using getPartialDecryptionPieces function
```js
await sdk.cip.getPartialDecryptionPieces(blsPublicKey, aesPublicKey);
```

### Return Parameter
Returns all the decryption pieces.  

## getAllGuardians function
This function allows the users to get all the guardians of the CIP procedure.  

### Using getAllGuardians function
```js
await sdk.cip.getAllGuardians();
```

### Return Parameter
Returns the list of guardians  

## getThreshold function
This function allows users to get the threshold number of guardians required to carry out a successful CIP procedure.  

### Using getThreshold function
```js
await sdk.cip.getThreshold();
```

### Return Parameter
Returns the threshold.  

## getAESPublicKeyfromPrivateKey function
This function allows the users to derive hybrid public key from their hybrid private key.  

### Input Parameters
hybridPrivateKey: hybrid private key

### Using getAESPublicKeyfromPrivateKey function
```js
await sdk.cip.getAESPublicKeyfromPrivateKey(hybridPrivateKey);
```

### Return Parameter
Returns the AES hybrid key  

## aggregateSharedPrivateKeys function
This function allows the users to collect the aggregated partial decryption solutions.  

### Input Parameters
blsPublicKey: BLS Public Key of the KNOT  
hybridPrivateKey: hybrid private key  

### Using aggregateSharedPrivateKeys function
```js
await sdk.cip.aggregateSharedPrivateKeys(hybridPrivateKey, blsPublicKey);
```

### Return Parameter
Returns the decrypted data, or `false` in case of error.  

## getDecryptionState function
This function allows the users to track the stages of decryption process.  

### Input Parameters
blsPublicKey: BLS Public Key of the KNOT 

### Using getDecryptionState function
```js
await sdk.cip.getDecryptionState(blsPublicKey);
```

### Return Parameter
Returns `4` if decryption has completed, `3` if in process, `2` if request available, and `1` if re-encryption needed.  

## getSafeBox function
This function allows users to get contract instance of the Safe Box.  

### Using getSafeBox function
```js
await sdk.cip.getSafeBox();
```

### Return Parameter
Returns the contract instance.  

## decryptionEligibilityChecks function
This function allows users to check the eligibility for decryption.  

### Input Parameters
blsPublicKey: BLS Public Key of the KNOT  
stakehouseAddress: Stakehouse address of the KNOT (Optional parameter).  
safeBox: safeBox contract instance (Optional parameter).

### Using decryptionEligibilityChecks function
```js
await sdk.cip.decryptionEligibilityChecks(blsPublicKey, stakehouseAddress=null, safeBox=null);
```

### Return Parameter
Returns `true` if eligible, otherwise throws `error`  