Skip to content

Commit 145b959

Browse files
committed
Rename siws-encryption dir
1 parent 53f72f2 commit 145b959

37 files changed

+71
-3
lines changed

siws-accs/browser/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ An example use case fo this functionality is permitting decryption capabilities
1414
- In order to pay for this, the corresponding Ethereum account must have Lit Test Tokens. If you do not have any, you can get some from [the faucet](https://chronicle-yellowstone-faucet.getlit.dev/)
1515
- Create a Lit Capacity Credit delegation Auth Sig
1616
- Create Lit Session Signatures for the request to the Lit network to execute a Lit Action that authenticates the SIWS message and check for authorization by executing the Access Control Conditions
17-
- This code example uses Node.js and Yarn, please have these installed before running the example
17+
- This code example uses Node.js, Yarn, and Deno please have these installed before running the example
1818
- The code example also expects the [Phantom wallet browser extension](https://chromewebstore.google.com/detail/phantom/bfnaelmomeimhlpmgjnjophhpkkoljpa?hl=en) to be installed and setup with a Solana wallet
1919

2020
## Installation and Setup

siws-authentication/browser/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This code example has a [corresponding doc page](https://developer.litprotocol.c
1111
- Mint a Lit Capacity Credit if none was specific in the project's `.env` file
1212
- In order to pay for this, the corresponding Ethereum account must have Lit Test Tokens. If you do not have any, you can get some from [the faucet](https://chronicle-yellowstone-faucet.getlit.dev/)
1313
- Create a Lit Capacity Credit delegation Auth Sig
14-
- This code example uses Node.js and Yarn, please have these installed before running the example
14+
- This code example uses Node.js, Yarn, and Deno please have these installed before running the example
1515
- The code example also expects the [Phantom wallet browser extension](https://chromewebstore.google.com/detail/phantom/bfnaelmomeimhlpmgjnjophhpkkoljpa?hl=en) to be installed and setup with a Solana wallet
1616

1717
## Installation and Setup
File renamed without changes.
File renamed without changes.
File renamed without changes.

siws-encryption/browser/README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Encrypting Data with Sign-in With Solana
2+
3+
This example demonstrates how to use Lit Protocol to encrypt and decrypt data based on authenticated Solana public keys. It leverages three key components:
4+
5+
1. Lit Access Control Conditions
6+
2. Sign-in With Solana (SIWS) messages (following [Phantom's specification](https://github.com/phantom/sign-in-with-solana/tree/main))
7+
3. Lit Actions
8+
9+
By combining these technologies, we create a secure system for data decryption tied to Solana wallet authentication.
10+
11+
This code example has a [corresponding doc page](https://developer.litprotocol.com/sdk/access-control/solana/siws-encryption) that covers the implementation in more detail, this repository acts as a reference implementation for you to use as a guide for restricting data decryption to specific Solana public keys in your project.
12+
13+
## Prerequisites
14+
15+
- An Ethereum private key
16+
- This private key will be used to:
17+
- Mint a Lit Capacity Credit if none was specific in the project's `.env` file
18+
- In order to pay for this, the corresponding Ethereum account must have Lit Test Tokens. If you do not have any, you can get some from [the faucet](https://chronicle-yellowstone-faucet.getlit.dev/)
19+
- Create a Lit Capacity Credit delegation Auth Sig
20+
- Mint a PKP if none was specific in the project's `.env` file
21+
- This code example uses Node.js, Yarn, and Deno please have these installed before running the example
22+
- The code example also expects the [Phantom wallet browser extension](https://chromewebstore.google.com/detail/phantom/bfnaelmomeimhlpmgjnjophhpkkoljpa?hl=en) to be installed and setup with a Solana wallet
23+
24+
## Installation and Setup
25+
26+
1. Clone the repository
27+
2. `cd` into the code example directory: `cd siws-session-sigs/browser`
28+
3. Install the dependencies: `yarn`
29+
4. Create and fill in the `.env` file: `cp .env.example .env`
30+
- `VITE_ETHEREUM_PRIVATE_KEY`: **Required** This is the Ethereum private key that will be used to mint a Lit Capacity Credit and create Lit Session Signatures
31+
- `VITE_LIT_CAPACITY_CREDIT_TOKEN_ID`: **Optional** This is the ID of the Lit Capacity Credit to use for the PKP delegation Auth Sig
32+
- `VITE_LIT_PKP_PUBLIC_KEY`: **Optional** This is the public key of the PKP to use for generating Session Signatures
33+
- `VITE_LIT_PKP_TOKEN_ID`: **Optional** This is the ID of the PKP to use for generating Session Signatures
34+
5. Build the Lit Action file: `yarn build:lit-action`
35+
6. Start the development server: `yarn dev`
36+
37+
## Executing the Example
38+
39+
1. Open the app in your browser: http://localhost:5173
40+
2. Open the JavaScript browser console
41+
3. Click the `Select Wallet` button and connect your Phantom wallet
42+
4. Click the `Sign In` button to sign the SIWS message
43+
5. Enter some text in the encryption input field and click the `Encrypt` button
44+
6. Click the `Decrypt` button to decrypt the data
45+
46+
The following diagram provides an overview of how this code example works:
47+
48+
![Code Example Overview](./src/assets/siws-session-signatures.png)
49+
50+
### Expected Output
51+
52+
After clicking the `Sign In` button, the code example will submit your signed SIWS message to the Lit network to be authenticated using a Lit Action and will generate Session Signatures using the minted PKP if the signing Solana public key is authorized to use the PKP.
53+
54+
After successful execution, you should see `✅ Got Session sigs` in the JavaScript console and `Session Sigs generated successfully` on the web page:
55+
56+
![Successful execution](./src/assets/successful-execution.png)
57+
58+
## Specific Files to Reference
59+
60+
- [App.tsx](./src/App.tsx): Contains the frontend code and logic for the example
61+
- [SignInButton.tsx](./src/SignInButton.tsx): Contains the code for the `Sign In` button that creates and submits the SIWS message to the browser wallet extension
62+
- [litSiws.ts](./src/litSiws.ts): Contains the code for:
63+
- Minting a Capacity Credit if none was specified in the `.env` file
64+
- Generating the Capacity Credit delegation Auth Sig
65+
- Minting a PKP if none was specified in the `.env` file
66+
- Adding the permitted Auth Methods to the PKP
67+
- Executing the Lit Action to authenticate the SIWS message and generate Session Signatures
68+
- [litActionSessionSigs.ts](./src/litActionSessionSigs.ts): Contains the Lit Action code that authenticates the SIWS message, checks the PKPs permitted Auth Methods, and signals the Lit Network to generate Session Signatures
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)