|
| 1 | +<!-- omit in toc --> |
| 2 | +# Getting Started with the Lit SDK |
| 3 | + |
| 4 | +The Lit SDK is a set of libraries that enable various functionalities of the Lit Protocol. Each package is available on npm, and can be installed with your preferred JavaScript package manager. |
| 5 | + |
| 6 | +<!-- omit in toc --> |
| 7 | +## Table of Contents |
| 8 | + |
| 9 | +- [Lit Documentation](#lit-documentation) |
| 10 | +- [Core Terminology](#core-terminology) |
| 11 | + - [Lit Node Client](#lit-node-client) |
| 12 | + - [Lit Network](#lit-network) |
| 13 | + - [Lit Chronicle Blockchain](#lit-chronicle-blockchain) |
| 14 | + - [Session Signatures](#session-signatures) |
| 15 | + - [Lit Resources and Abilities](#lit-resources-and-abilities) |
| 16 | + - [Programmable Key Pair (PKP)](#programmable-key-pair-pkp) |
| 17 | + - [Lit Action](#lit-action) |
| 18 | +- [Installing Common Lit SDK Packages](#installing-common-lit-sdk-packages) |
| 19 | + - [@lit-protocol/lit-node-client](#lit-protocollit-node-client) |
| 20 | + - [@lit-protocol/contracts-sdk](#lit-protocolcontracts-sdk) |
| 21 | + - [@lit-protocol/constants](#lit-protocolconstants) |
| 22 | + - [ethers.js@v5](#ethersjsv5) |
| 23 | +- [Next Steps](#next-steps) |
| 24 | + |
| 25 | + |
| 26 | +## Lit Documentation |
| 27 | + |
| 28 | +- [Lit Documentation](https://developer.litprotocol.com) |
| 29 | + - This is the main source of information for the Lit Protocol. It contains guides, reference documentation, and other resources for developers. |
| 30 | +- [Lit SDK Api Documentation](https://v6-api-doc-lit-js-sdk.vercel.app) |
| 31 | + - This is the API reference docs for the Lit SDK. It contains detailed information about the available methods and parameters for each package. |
| 32 | +- [Lit Actions Api Documentation](https://actions-docs.litprotocol.com) |
| 33 | + - This is the API reference docs for Lit Actions. It contains detailed information about the available methods and parameters for Lit Actions. |
| 34 | +- [Lit Developer Code Examples](https://github.com/LIT-Protocol/developer-guides-code) |
| 35 | + - This is a repository of code examples for various functionalities of the Lit Protocol. Each directory is a separate example demonstrating a specific functionality. Each example should include a `README.md` with a brief explanation of the code and how to run it. |
| 36 | + |
| 37 | +## Core Terminology |
| 38 | + |
| 39 | +### Lit Node Client |
| 40 | + |
| 41 | +An instance of the `LitNodeClient` class is used to interact with the Lit Network. |
| 42 | + |
| 43 | +### Lit Network |
| 44 | + |
| 45 | +The Lit Network is a decentralized network of nodes that are running the Lit Protocol on [AMD SEV-SNP](https://www.amd.com/content/dam/amd/en/documents/epyc-business-docs/solution-briefs/amd-secure-encrypted-virtualization-solution-brief.pdf) enabled hardware to provide the Multi-Party Computation (MPC) services that are used by the Lit Protocol. |
| 46 | + |
| 47 | +### Lit Chronicle Blockchain |
| 48 | + |
| 49 | +The blockchain used by the Lit Networks to store the state of the Lit Protocol such as Programmable Key Pairs (PKPs) and their permitted Authentication Methods. |
| 50 | + |
| 51 | +### Session Signatures |
| 52 | + |
| 53 | +A **Session** in the Lit Protocol is a temporary context that allows users to interact with Lit Resources securely without repeatedly signing transactions with their wallets. Sessions are established using an ephemeral **Session Key Pair** (a locally generated public and private key), where: |
| 54 | + |
| 55 | +- **Session Private Key**: Held securely by the user and used to sign requests to the Lit network. |
| 56 | +- **Session Public Key**: Shared with the Lit network and used by nodes to verify the session's requests. |
| 57 | + |
| 58 | +**Session Signatures** are aggregated signatures generated by Lit nodes. They authenticate a Session Key Pair, authorizing it to access specified Lit Resources with defined Abilities for a certain period. Essentially, Session Signatures delegate permissions from your authenticated blockchain account to an ephemeral Session Key. |
| 59 | + |
| 60 | +### Lit Resources and Abilities |
| 61 | + |
| 62 | +**Lit Resources** identify the core Lit assets that can be utilized within the Lit Protocol: |
| 63 | + |
| 64 | +- **Access Control Conditions (ACCs)**: Rules that express the conditions under which access to a resource is granted. They are used to determine who can decrypt data, but can also be used arbitrarily as a permissioning mechanism. |
| 65 | +- **Lit Actions**: Serverless functions that run on the Lit network. |
| 66 | +- **Programmable Key Pairs (PKPs)**: Distributed key pairs for signing. |
| 67 | + |
| 68 | +**Abilities** are specific permissions that define what actions can be performed with these resources. When generating a session (Session Signatures), you explicitly specify which resources the session can access, what abilities (permissions) the session has for each resource, and the duration these permissions are valid. |
| 69 | + |
| 70 | +This granular control ensures that sessions operate with the principle of least privilege, only having access to the specific resources and abilities they need. |
| 71 | + |
| 72 | +### Programmable Key Pair (PKP) |
| 73 | + |
| 74 | +A PKP is a key pair where the private key is generated by Lit's MPC network, and is never revealed in entirety to any single party. Instead, the private key is split into multiple shares and distributed to the MPC nodes. A threshold of the MPC nodes need to cooperate to construct signature shares that can be combined to form a valid signature. |
| 75 | + |
| 76 | +### Lit Action |
| 77 | + |
| 78 | +A Lit Action is a decentralized serverless function that is executed by each Lit Node in the network to reach consensus on the result of the function. |
| 79 | + |
| 80 | +## Installing Common Lit SDK Packages |
| 81 | + |
| 82 | +Below is a list of the most commonly used Lit SDK packages: |
| 83 | + |
| 84 | +### [@lit-protocol/lit-node-client](https://v6-api-doc-lit-js-sdk.vercel.app/modules/lit_node_client_src.html) |
| 85 | + |
| 86 | +Connects to a Lit Network and provides methods for interacting with the network, such as getting session signatures and performing encryption/decryption. |
| 87 | + |
| 88 | +This package is almost always required for any project using Lit. |
| 89 | + |
| 90 | +```bash |
| 91 | +npm install @lit-protocol/lit-node-client |
| 92 | +``` |
| 93 | + |
| 94 | +```bash |
| 95 | +yarn add @lit-protocol/lit-node-client |
| 96 | +``` |
| 97 | + |
| 98 | +### [@lit-protocol/contracts-sdk](https://v6-api-doc-lit-js-sdk.vercel.app/modules/contracts_sdk_src.html) |
| 99 | + |
| 100 | +Provides a set of interfaces and helper functions for interacting with the contracts that are deployed on the Lit Chronicle blockchain. |
| 101 | + |
| 102 | +This package is useful for minting Programmable Key Pairs (PKPs), and managing their permitted Authentication Methods. |
| 103 | + |
| 104 | +```bash |
| 105 | +npm install @lit-protocol/contracts-sdk |
| 106 | +``` |
| 107 | + |
| 108 | +```bash |
| 109 | +yarn add @lit-protocol/contracts-sdk |
| 110 | +``` |
| 111 | + |
| 112 | +### [@lit-protocol/constants](https://v6-api-doc-lit-js-sdk.vercel.app/modules/constants_src.html) |
| 113 | + |
| 114 | +A package containing useful constants for use across the SDK. |
| 115 | + |
| 116 | +Some useful constants include: |
| 117 | + |
| 118 | +- `LitNetwork`: An object containing the correct chain identifier for each available Lit Network. |
| 119 | + - For the purposes of a hackathon, you should be using `LitNetwork.DatilDev`. |
| 120 | +- `LIT_RPC`: An object containing the RPC URLs for each available Lit blockchain network. |
| 121 | + - For the purposes of a hackathon, you should be using `LIT_RPC.CHRONICLE_YELLOWSTONE`. |
| 122 | + |
| 123 | +```bash |
| 124 | +npm install @lit-protocol/constants |
| 125 | +``` |
| 126 | + |
| 127 | +```bash |
| 128 | +yarn add @lit-protocol/constants |
| 129 | +``` |
| 130 | + |
| 131 | +--- |
| 132 | + |
| 133 | +### [ethers.js@v5](https://docs.ethers.org/v5/) |
| 134 | + |
| 135 | +A popular library for interacting with Ethereum-based blockchains. Lit uses version `v5` of ethers.js. |
| 136 | + |
| 137 | +```bash |
| 138 | +npm install ethers@v5 |
| 139 | +``` |
| 140 | + |
| 141 | +```bash |
| 142 | +yarn add ethers@v5 |
| 143 | +``` |
| 144 | + |
| 145 | +## Next Steps |
| 146 | + |
| 147 | +Now that you have an understanding of the core terminology and have installed the common Lit SDK packages, you can continue on to the code example for instantiating a `LitNodeClient` to connect to a Lit Network: [Connecting to Lit](./connecting-to-lit/README.md). |
0 commit comments