|
1 | 1 | # tKey Web Storage Module |
2 | 2 |
|
3 | | -[](https://www.npmjs.com/package/@tkey/web-storage/v/latest) [](https://bundlephobia.com/result?p=@tkey/web-storage@latest) |
| 3 | +[](https://www.npmjs.com/package/@tkey/tss/v/latest) |
| 4 | +[](https://bundlephobia.com/result?p=@tkey/tss@latest) |
4 | 5 |
|
5 | | -The tKey Web Storage Module helps you store and recall key shares in the from local and file storage. This module is the part of the [tKey SDK](https://github.com/tkey/tkey/). |
| 6 | +The tKey TSS Module enable tss- Threshold Signature Scheme (MPC - multi Party Computing) feature. This module is the part of the [tKey SDK](https://github.com/tkey/tkey/). |
6 | 7 |
|
7 | 8 | ## Installation |
8 | 9 |
|
9 | 10 | ```shell |
10 | | -npm install --save @tkey/web-storage |
| 11 | +npm install --save @tkey/tss |
11 | 12 | ``` |
12 | 13 |
|
13 | 14 | ## Initialization |
14 | 15 |
|
15 | | -#### Import the `WebStorageModule` class from `@tkey/web-storage` |
| 16 | +#### Import the `TSSModule` class from `@tkey/tss` |
16 | 17 |
|
17 | 18 | ```javascript |
18 | | -import WebStorageModule from "@tkey/web-storage"; |
| 19 | +import TSSModule from "@tkey/tss"; |
19 | 20 | ``` |
20 | 21 |
|
21 | | -#### Assign the `WebStorageModule` class to a variable |
| 22 | +#### Assign the `TSSModule` class to a variable |
22 | 23 |
|
23 | 24 | ```javascript |
24 | | -const webStorageModule = new WebStorageModule(params); |
| 25 | +const tssModule = new TSSModule(params); |
25 | 26 | ``` |
26 | 27 |
|
27 | 28 | ### Parameters |
28 | 29 |
|
29 | 30 | `params` |
30 | 31 |
|
31 | | -- `canUseFileStorage?`: `boolean` |
32 | | - |
| 32 | +- `tkey`: `ThresholdKey` |
| 33 | +- `moduleName` = `TSS_MODULE_NAME`, |
| 34 | +- `tssTag` = `default` |
33 | 35 | ### Returns |
34 | 36 |
|
35 | | -The `WebStorageModule` class returns an object with the following properties: |
| 37 | +The `TSSModule` class returns an object with the following properties: |
36 | 38 |
|
37 | 39 | ```ts |
38 | | -class WebStorageModule implements IModule { |
| 40 | +class TSSModule { |
39 | 41 | moduleName: string; |
40 | | - tbSDK: ITKeyApi; |
41 | | - canUseFileStorage: boolean; |
42 | | - constructor(canUseFileStorage?: boolean); |
43 | | - setFileStorageAccess(): Promise<void>; |
44 | | - setModuleReferences(tbSDK: ITKeyApi): void; |
45 | | - initialize(): Promise<void>; |
46 | | - storeDeviceShare(deviceShareStore: ShareStore, customDeviceInfo?: StringifiedType): Promise<void>; |
47 | | - storeDeviceShareOnFileStorage(shareIndex: BNString): Promise<void>; |
48 | | - getDeviceShare(): Promise<ShareStore>; |
49 | | - inputShareFromWebStorage(): Promise<void>; |
| 42 | + tkey: ThresholdKey; |
| 43 | + tssTag: string; |
| 44 | + |
| 45 | + async setModuleReferences(api: ThresholdKey): Promise<void> |
| 46 | + async initializeWithTss( |
| 47 | + tssOptions: { deviceTSSShare: BN; deviceTSSIndex: number; factorPub: Point }, |
| 48 | + params?: { |
| 49 | + withShare?: ShareStore; |
| 50 | + importKey?: BN; |
| 51 | + neverInitializeNewKey?: boolean; |
| 52 | + transitionMetadata?: IMetadata; |
| 53 | + previouslyFetchedCloudMetadata?: IMetadata; |
| 54 | + previousLocalMetadataTransitions?: LocalMetadataTransitions; |
| 55 | + delete1OutOf1?: boolean; |
| 56 | + } |
| 57 | + ) |
| 58 | + |
| 59 | + getTSSCommits(): Point[] |
| 60 | + |
| 61 | + getTSSPub(): Point |
| 62 | + |
| 63 | + async getTSSShare(factorKey: BN, opts?: { threshold: number }): Promise<{ tssIndex: number; tssShare: BN }> |
| 64 | + |
| 65 | + getFactorEncs(factorPub: Point): FactorEnc |
| 66 | + |
| 67 | + async generateNewShare(tssOptions?: { |
| 68 | + inputTSSShare: BN; |
| 69 | + inputTSSIndex: number; |
| 70 | + newFactorPub: Point; |
| 71 | + newTSSIndex: number; |
| 72 | + authSignatures?: string[]; |
| 73 | + selectedServers?: number[]; |
| 74 | + }): Promise<GenerateNewShareResult> |
| 75 | + |
| 76 | + async deleteShare( |
| 77 | + tssOptions: { |
| 78 | + inputTSSShare: BN; |
| 79 | + inputTSSIndex: number; |
| 80 | + factorPub: Point; |
| 81 | + authSignatures: string[]; |
| 82 | + selectedServers?: number[]; |
| 83 | + }, |
| 84 | + shareIndex: BNString |
| 85 | + ) : Promise<void> |
50 | 86 | } |
51 | 87 | ``` |
52 | 88 |
|
53 | 89 | ## Usage |
54 | 90 |
|
55 | | -With the `WebStorageModule`, you've access to the following functions: |
56 | | - |
57 | | -### Store Device Share |
58 | | - |
59 | | -#### `storeDeviceShare(deviceShareStore: ShareStore, customDeviceInfo?: StringifiedType)` |
60 | | - |
61 | | -- `deviceShareStore`: The `ShareStore` object to store. |
62 | | -- `customDeviceInfo?`: Information about the device to store. |
63 | | - |
64 | | -#### `ShareStore` |
65 | | - |
66 | | -```ts |
67 | | -class ShareStore implements ISerializable { |
68 | | - share: Share; |
69 | | - polynomialID: PolynomialID; |
70 | | - constructor(share: Share, polynomialID: PolynomialID); |
71 | | - static fromJSON(value: StringifiedType): ShareStore; |
72 | | - toJSON(): StringifiedType; |
73 | | -} |
74 | | -interface ISerializable { |
75 | | - toJSON(): StringifiedType; |
76 | | -} |
77 | | -``` |
78 | | - |
79 | | -### Storing a Share on File Storage |
80 | | - |
81 | | -#### `storeDeviceShareOnFileStorage(shareIndex)` |
82 | | - |
83 | | -- `shareIndex`: The index of the share to store. |
84 | | - |
85 | | -### Get a ShareStore from Storage |
86 | | - |
87 | | -#### `getDeviceShare()` |
88 | | - |
89 | | -#### Return |
90 | | - |
91 | | -- `Promise<ShareStore>`: The [`ShareStore`](#sharestore) object. |
| 91 | +With the `TSSModule`, you've access to the following functions: |
0 commit comments