|
1 | | -# Quick Start |
| 1 | +# PKP Base |
2 | 2 |
|
3 | | -This submodule defines a PKPBase class, providing shared wallet functionality for PKP signers, responsible for managing public key compression, initializing and connecting to the LIT node, running LIT actions, and offering debug functions for logging and error handling. |
| 3 | +A foundational package providing shared wallet functionality for PKP (Programmable Key Pair) signers in the Lit Protocol ecosystem. This package manages public key operations, LIT node connections, and action execution. |
4 | 4 |
|
5 | | -| Method/Property | Description | |
6 | | -| -------------------------------------------------------------------- | ----------------------------------------------------------------------------- | |
7 | | -| `compressPubKey(pubKey: string)` | Compresses a provided public key | |
8 | | -| `setUncompressPubKeyAndBuffer(prop: PKPBaseProp)` | Sets the uncompressed public key and its buffer representation | |
9 | | -| `setCompressedPubKeyAndBuffer(prop: PKPBaseProp)` | Sets the compressed public key and its buffer representation | |
10 | | -| `setLitAction(prop: PKPBaseProp)` | Sets the Lit action to be executed by the LitNode client | |
11 | | -| `setLitActionJsParams<CustomType extends T = T>(params: CustomType)` | Sets the value of the `litActionJsParams` property to the given params object | |
12 | | -| `createAndSetSessionSigs(sessionParams: GetSessionSigsProps)` | Creates and sets the session sigs and their expiration | |
13 | | -| `init()` | Initializes the PKPBase instance by connecting to the LIT node | |
14 | | -| `runLitAction(toSign: Uint8Array, sigName: string)` | Runs the specified Lit action with the given parameters | |
15 | | -| `ensureLitNodeClientReady()` | Ensures that the LitNode client is ready for use | |
16 | | -| `log(...args: any[])` | Logs the provided arguments to the console, but only if debugging is enabled | |
| 5 | +## Installation |
17 | 6 |
|
18 | | -### node.js / browser |
19 | | - |
20 | | -``` |
| 7 | +```bash |
21 | 8 | yarn add @lit-protocol/pkp-base |
22 | 9 | ``` |
| 10 | + |
| 11 | +## Quick Start |
| 12 | + |
| 13 | +```typescript |
| 14 | +import { PKPBase } from '@lit-protocol/pkp-base'; |
| 15 | + |
| 16 | +// Initialize PKP Base |
| 17 | +const pkpBase = new PKPBase({ |
| 18 | + controllerAuthSig: authSig, |
| 19 | + pkpPubKey: publicKey, |
| 20 | +}); |
| 21 | + |
| 22 | +// Connect to LIT node |
| 23 | +await pkpBase.init(); |
| 24 | + |
| 25 | +// Run LIT action |
| 26 | +const signature = await pkpBase.runLitAction(dataToSign, 'sign'); |
| 27 | +``` |
| 28 | + |
| 29 | +## Key Features |
| 30 | + |
| 31 | +- Public key compression and management |
| 32 | +- LIT node connection handling |
| 33 | +- Session signature management |
| 34 | +- LIT action execution |
| 35 | +- Debug logging capabilities |
| 36 | + |
| 37 | +## Core Methods |
| 38 | + |
| 39 | +| Method | Description | |
| 40 | +| ------ | ----------- | |
| 41 | +| `init()` | Initialize and connect to LIT node | |
| 42 | +| `compressPubKey()` | Compress public keys | |
| 43 | +| `runLitAction()` | Execute LIT actions | |
| 44 | +| `createAndSetSessionSigs()` | Manage session signatures | |
| 45 | +| `ensureLitNodeClientReady()` | Verify node connection | |
| 46 | + |
| 47 | +## Development |
| 48 | + |
| 49 | +### Building |
| 50 | + |
| 51 | +Run `nx build pkp-base` to build the library. |
| 52 | + |
| 53 | +### Testing |
| 54 | + |
| 55 | +Run `nx test pkp-base` to execute the unit tests. |
0 commit comments