description |
---|
Decrypt an AES Key with an RSA Private Key |
The decryptAESKeyWithRSA
performs asymmetric decryption using an RSA Private Key
and the RSA-OAEP
algorithm. The permissions are requested with the help of the Arweave Wallet (Window Object)
in a browser environment if no wallet or use_wallet
is passed. The node environment expects Arweave JWK to be passed.
{% hint style="info" %}
Installation of ArConnect
is suggested for successful use of this function in a browser environment.
{% endhint %}
The function is called as follows:
import { decryptAESKeyWithRSA } from 'arweavekit/encryption';
const decryptedAESKey = await decryptAESKeyWithRSA({params});
The following params are available for this function and they must be passed in as an object:
key: Uint8Array
: The encrypted AES key received from the encryptAESKeyWithRSA function.
wallet: ArWallet
(optional): A value of typeJWKInterface
oruse_wallet
can be passed. Ifuse_wallet
or nothing is passed to this param, it expectsArConnect
to be installed to run the decryption successfully.
Example
// In a browser environment, use_wallet or nothing can be passed.
const wallet = "use_wallet"
// In a node environment, Arweave wallet JWK can be passed.
const wallet = JSON.parse(fs.readFileSync('wallet.json').toString());
const decryptedAESKey = await decryptAESKeyWithRSA({
key: Uint8Array,
});
This decrypts the provided AES Key
using the RSA-OAEP
algorithm.
The function call returns the following data:
{
decryptedKey: string,
}
decryptedKey: string
: TheAES
key decrypted using anRSA Public Key
returned as aBase64 string
.