You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: conditional-signing/browser/README.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ In this directory, `conditional-signing/browser`, run `yarn` to install the proj
12
12
13
13
If you already have a Lit PKP that you'd like to use, you can copy the contents of the provided `.env.example` to a `.env` file to specify it. If you don't have a PKP, or wish to use a new one for this example, then you can skip this step and one will be created for you when you run this example.
14
14
15
-
**NOTE** In order for a new Lit PKP to minted for you, you **must** have `testLPX` tokens. You can receive some `testLPX` using the faucet available [here](https://faucet.litprotocol.com/).
15
+
**NOTE** In order for a new Lit PKP to minted for you, you **must** have `tstLPX` tokens. You can receive some `tstLPX` using the faucet available [here](https://faucet.litprotocol.com/).
# String Encryption/Decryption Using the Lit SDK in the Browser
2
2
3
-
This is a simple example, that currently contains hardcoded values as `const`s in [encryptString.ts](./src/encryptString.ts) and [decryptString.ts](./src/decryptString.ts), that demonstrates encrypting and decrypting a string within the Browser using React.
3
+
This code example demonstrates how the Lit SDK can be used to encrypt and decrypt data within a browser.
4
4
5
-
## Running the Example
5
+
## Running this Example
6
6
7
-
### Installed the dependencies
7
+
### Install the Dependencies
8
8
9
-
After downloading this repository, you will need to install the necessary dependencies"
9
+
In this directory, `encryption-decryption/browser`, run `yarn` to install the project dependencies.
10
10
11
-
```bash
12
-
yarn
13
-
```
11
+
### Specifying Your Lit Capacity Credit's Token ID
12
+
13
+
If you already have a Lit Capacity Credit that you'd like to use, you can copy the contents of the provided `.env.example` to a `.env` file to specify it. If you don't have a Capacity Credit, or wish to use a new one for this example, then you can skip this step and one will be minted for you when you run this example.
14
+
15
+
**NOTE** In order for a new Lit Capacity Credit to be minted, you **must** have `tstLPX` tokens. You can receive some `tstLPX` using the faucet available [here](https://faucet.litprotocol.com/).
14
16
15
-
### Run the Web App
17
+
```
18
+
cp .env.example .env
19
+
```
16
20
17
-
This example uses Vite to bundle and serve the web app at `http://localhost:5173/`:
In this directory, `encryption-decryption/browser`, run `yarn dev` to bundle all of this code and serve the HTML file at: [http://localhost:5173](http://localhost:5173).
30
+
31
+
Before you click the buttons, open up the JavaScript console in your browser so you can see the output of this example.
32
+
33
+
After typing in the text you want to encrypt, clicking the `Encrypt String` button will:
34
+
35
+
1. You will be prompted by your wallet (i.e. MetaMask) to connect an account to the site
36
+
2. After connecting an account, the console should display a successful connection to the Lit network and the encrypted `ciphertext` and `dataToEncryptHash` that will later be used to decrypt the string.
37
+
38
+
After encrypting the string, clicking the `Decrypt String` button will:
22
39
23
-
### Console Output
40
+
1. Connect you to the Lit network and LitContracts client
41
+
2. If you did not provide a Capacity Credit token ID, you will be prompted by your wallet to mint a new one
42
+
3. You will then be prompted by your wallet to sign a message. This message will create a `capacityDelegationAuthSig`, which is used to pay for decrypting data ([and other functionality](https://developer.litprotocol.com/paying-for-lit/capacity-credits)) on the Lit
43
+
4. You will then be prompted by your wallet to sign another one final message. This message is the SIWE message that will derive your address from to use for the conditional check of whether or not you are permitted to decrypt the data
24
44
25
-
The web app will present you two buttons:
45
+
The full example should look something like:
26
46
27
-
1.`Encrypt String`
28
-
- Will encrypt a hardcoded string using the Lit SDK
29
-
2.`Decrypt String`
30
-
- Will decrypt a hardcoded string using the Lit SDK and Habanero network
0 commit comments