Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compressing removed from sdk on v7, replaced with uint8array method #395

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions docs/integrations/storage/irys.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ For more advanced examples, see [unified access control conditions](https://deve
We provide multiple methods to encrypt data, including strings, files, zip files.

- `encryptString():` Encrypts a string.
- `encryptFile()`: Encrypts a file.
- `encryptUint8Array()`: Encrypts a Uint8Array, which can be a compressed file.
- `encryptToJson()`: Encrypts a string or file and serializes the result to JSON.

We will use `encryptString()` to encrypt a simple string:
Expand Down Expand Up @@ -426,8 +428,10 @@ For more advanced examples, see [unified access control conditions](https://deve

We provide multiple methods to encrypt data, including strings, files, zip files.

- `encryptString()`: Encrypts a string.
- `encryptToJson()`: Encrypts a string or file and serializes the result to JSON.
- `encryptString():` Encrypts a string.
- `encryptFile()`: Encrypts a file.
- `encryptUint8Array()`: Encrypts a Uint8Array, which can be a compressed file.
- `encryptToJson()`: Encrypts a string or file and serializes the result to JSON.

We will use `encryptString()` to encrypt a string:

Expand Down Expand Up @@ -593,4 +597,4 @@ export const decryptData = async (encryptedText: string, dataToEncryptHash: stri

Any questions? Reach out the Irys team in their [Discord](https://discord.gg/irys).

<FeedbackComponent/>
<FeedbackComponent/>
11 changes: 8 additions & 3 deletions docs/sdk/access-control/encryption.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,19 @@ const accessControlConditions = [

#### Encryption

To encrypt a string, use one of the following functions:
To encrypt a string, use:

- [encryptString()](https://v7-api-doc-lit-js-sdk.vercel.app/functions/encryption_src.encryptString.html) - Used to encrypt the raw string.

To encrypt a file, use:

- [encryptFile()](https://v7-api-doc-lit-js-sdk.vercel.app/functions/encryption_src.encryptFile.html) - Used to encrypt a file without doing any zipping or packing. Because zipping larger files takes time, this function is useful when encrypting large files ( > 20mb). This also requires that you store the file metadata.

Apart from this, we have one more function which can be used to encrypt both strings and files:
To encrypt a Uint8Array, use:

- [encryptUint8Array()](https://v7-api-doc-lit-js-sdk.vercel.app/functions/encryption_src.encryptUint8Array.html) - Used to encrypt a Uint8Array, which can be the output of a [compression algorithm](https://github.com/LIT-Protocol/compression) or anything else that does not adhere to the string or file types.

Apart from those, we have one more function which can be used to encrypt both strings and files:

- [encryptToJson()](https://v7-api-doc-lit-js-sdk.vercel.app/functions/encryption_src.encryptToJson.html) - Used to encrypt a string or file and serialize all the metadata required to decrypt i.e. accessControlConditions, evmContractConditions, solRpcConditions, unifiedAccessControlConditions & chain to JSON. It is useful for encrypting/decrypting data in IPFS or other storage without compressing it in a ZIP file.

Expand Down Expand Up @@ -523,6 +527,7 @@ To decrypt use the following functions depending on the function used to encrypt

- [decryptToString()](https://v7-api-doc-lit-js-sdk.vercel.app/functions/encryption_src.decryptToString.html) for [encryptString()](https://v7-api-doc-lit-js-sdk.vercel.app/functions/encryption_src.encryptString.html)
- [decryptToFile()](https://v7-api-doc-lit-js-sdk.vercel.app/functions/encryption_src.decryptToFile.html) for [encryptFile()](https://v7-api-doc-lit-js-sdk.vercel.app/functions/encryption_src.encryptFile.html)
- [decryptToUint8Array()](https://v7-api-doc-lit-js-sdk.vercel.app/functions/encryption_src.decryptToUint8Array.html) for [encryptUint8Array()](https://v7-api-doc-lit-js-sdk.vercel.app/functions/encryption_src.encryptUint8Array.html)
- [decryptFromJson()](https://v7-api-doc-lit-js-sdk.vercel.app/functions/encryption_src.decryptFromJson.html) for [encryptToJson()](https://v7-api-doc-lit-js-sdk.vercel.app/functions/encryption_src.encryptToJson.html)

In the example, we used `encryptString()` to encrypt so we will use `decryptToString()` to decrypt. Pass in the data `accessControlConditions`, `ciphertext`, `dataToEncryptHash`, and `authSig`.
Expand Down Expand Up @@ -563,4 +568,4 @@ class Lit {

Check out [this example](https://github.com/LIT-Protocol/js-sdk/tree/feat/SDK-V3/apps/demo-encrypt-decrypt-react) for a full-fledged **React** application that encrypts and decrypts a **string** using the Lit JS SDK V3.

<FeedbackComponent/>
<FeedbackComponent/>
12 changes: 8 additions & 4 deletions docs/sdk/access-control/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,17 +185,21 @@ const accessControlConditions = [

### Encryption

To encrypt a string, use the following function:
To encrypt a string, use:

- [encryptString()](https://v7-api-doc-lit-js-sdk.vercel.app/functions/encryption_src.encryptString.html) - Used to encrypt the raw string.

To encrypt a file, use:

- [encryptFile()](https://v7-api-doc-lit-js-sdk.vercel.app/functions/encryption_src.encryptFile.html) - Used to encrypt a file without doing any zipping or packing. Because zipping larger files takes time, this function is useful when encrypting large files ( > 20mb). This also requires that you store the file metadata.

Apart from these, we have one more function which can be used to encrypt both strings and files:
To encrypt a Uint8Array, use:

- [encryptToJson()](https://v7-api-doc-lit-js-sdk.vercel.app/functions/encryption_src.encryptToJson.html) - Used to encrypt a string or file and serialise all the metadata required to decrypt i.e. accessControlConditions, evmContractConditions, solRpcConditions, unifiedAccessControlConditions & chain to JSON. It is useful for encrypting/decrypting data in IPFS or other storage without compressing it in a ZIP file.
- [encryptUint8Array()](https://v7-api-doc-lit-js-sdk.vercel.app/functions/encryption_src.encryptUint8Array.html) - Used to encrypt a Uint8Array, which can be the output of a [compression algorithm](https://github.com/LIT-Protocol/compression) or anything else that does not adhere to the string or file types.

Apart from those, we have one more function which can be used to encrypt both strings and files:

- [encryptToJson()](https://v7-api-doc-lit-js-sdk.vercel.app/functions/encryption_src.encryptToJson.html) - Used to encrypt a string or file and serialize all the metadata required to decrypt i.e. accessControlConditions, evmContractConditions, solRpcConditions, unifiedAccessControlConditions & chain to JSON. It is useful for encrypting/decrypting data in IPFS or other storage without compressing it in a ZIP file.

Encryption can be performed entirely client-side and doesn't require making a request to the Lit nodes.

Expand Down Expand Up @@ -556,4 +560,4 @@ By now you should have successfully created an Access Control Condition and perf
3. [Off-Chain Conditions](../access-control/lit-action-conditions.md).
4. [Custom Contract Calls](../access-control/evm/custom-contract-calls.md).

<FeedbackComponent/>
<FeedbackComponent/>