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

fixed typo about lit initialization #172

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
small refactoring
  • Loading branch information
brieyla1 committed Nov 17, 2023
commit ce81480fdac18f3761ea9d1717403ce83f6f97ff
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
---
sidebar_position: 2
---

# Setup the Project

## Smart Contract

1. Install hardhat:

```js
yarn add hardhat
```

2. Init hardhat to create the boilerplate for a **Basic project (with Javascript)**:

```js
npx hardhat init
```

3. Install Openzepplin:

```js
yarn add @openzeppelin/contracts
```

4. Test deploy the sample smart contract on 2 separate terminals:

```js
npx hardhat node
npx hardhat run scripts/deploy.js --network localhost
Expand All @@ -36,14 +33,13 @@ Now that we have our hardhat working & the sample smart contract is deployed cor

You can use the Lit JS SDK V2 to encrypt and store any static content. This could be a file, a string, or anything that won't change (we're going to encrypt an input string). You have to store the content and metadata yourself (we're storing that on a blockchain network), but Lit will store who is allowed to decrypt it and enforce this (aka key management).

1. Install Lit JS SDK V2:

1. Install Lit JS SDK V2:
```js
yarn add @lit-protocol/lit-node-client
```

2. Create a Lit class which will have all the encryption & decryption functions we require:

```js
import * as LitJsSdk from "@lit-protocol/lit-node-client";

Expand All @@ -64,4 +60,4 @@ class Lit {
`client.connect()` will return a promise that resolves when you are connected to the Lit Network. You may also listen for the `lit-ready` event.

In this code example, the `litNodeClient` is set as a global variable for use throughout the web app.
:::
:::
8 changes: 5 additions & 3 deletions versioned_docs/version-2.0/sdk/explanation/encryption.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
sidebar_position: 3
---
# Encryption

# Encryption
You can use Lit to encrypt and store any static content. This could be a file, a string, or anything that won't change. You need to store the content and metadata yourself (on IPFS, Arweave, or even a centralized storage solution), and Lit will store who is allowed to decrypt it and enforce this (aka key management).

If you want to use IPFS as a storage solution, Lit has an `encryptToIpfs` function that will help streamline the process of encryption and storing the encrypted data. You will need to provide an Infura ID and API secret key. [Jump to encryptToIPFS](../../SDK/Explanation/encryption#encrypttoipfs).
Expand All @@ -17,6 +17,7 @@ This example will show you how to encrypt and decrypt static data using the Lit

At the top of your file, instantiate your Lit Node client like so:


```js
import * as LitJsSdk from "@lit-protocol/lit-node-client";

Expand All @@ -43,12 +44,12 @@ export default new Lit()
Get more info on functions in the [API docs](https://js-sdk.litprotocol.com/index.html).

Steps to Encrypt

1. Obtain an `authSig` and create an access control condition.
2. Encrypt the static content (string, file, etc.) to get the `encryptedString`, for example.
3. Use `litNodeClient.saveEncryptionKey` to tie the `accessControlConditions` with the `symmetricKey` we got above. This returns us the `encryptedSymmetricKey`.
4. Finally, we have to store the `encryptedString` & other metadata: `encryptedSymmetricKey`, `accessControlConditions` (or other conditions eg: `evmContractConditions`) and `chain`. IPFS is generally used to store these values.


### Access Control & AuthSig

In this example, we will set the accessControlConditions on if a wallet has at least 0.000001 ETH:
Expand Down Expand Up @@ -208,6 +209,7 @@ The full decryption process should look like:
}
```


# Encryption & Upload to IPFS

To simplify encrypting and uploading to IPFS, there is a method within the SDK to help encrypt and store data on IPFS.
Expand Down Expand Up @@ -261,4 +263,4 @@ async decrypt(ipfsCid) {

### How to encrypt & decrypt a file instead?

For encryption use the same function params as above with the string param replaced with a file. For decryption nothing changes. The returned value in that case will be a Uint8Array instead of a string since it's a decrypted file.
For encryption use the same function params as above with the string param replaced with a file. For decryption nothing changes. The returned value in that case will be a Uint8Array instead of a string since it's a decrypted file.
12 changes: 5 additions & 7 deletions versioned_docs/version-2.0/sdk/explanation/installation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
sidebar_position: 1
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

Expand All @@ -21,7 +22,7 @@ values={[
{label: 'script tag with all dependencies included', value: 'script-tag'},
{label: 'server side with nodejs', value: 'server-side'},
]}>
`<TabItem value="browser">`
<TabItem value="browser">

Install the `@lit-protocol/lit-node-client` package, which can be used in both browser and Node environments:

Expand All @@ -36,15 +37,15 @@ import * as LitJsSdk from "@lit-protocol/lit-node-client";
```

</TabItem>

<TabItem value="script-tag">

```js
<script src="https://cdn.jsdelivr.net/npm/@lit-protocol/lit-node-client-vanilla/lit-node-client.js"></script>
```

If you decide to import the SDK with the script tag, we provide a web-ready package with the dependencies you need. You can use the SDK functions via `LitJsSdk_litNodeClient`, for example `LitJsSdk_litNodeClient.encryptString()`
`</TabItem>`
</TabItem>

<TabItem value="server-side">

Expand Down Expand Up @@ -79,12 +80,9 @@ values={[
{label: 'yarn / NPM', value: 'yarn'},
{label: 'script tag', value: 'script'},
]}>
`<TabItem value="yarn">`
<TabItem value="yarn">

```js
import * as LitJsSdk from "@lit-protocol/lit-node-client";


const client = new LitJsSdk.LitNodeClient({});
await client.connect();
window.litNodeClient = client;
Expand Down