@idos-network/enclave 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +50 -0
- package/dist/base-0xSNl4rW.d.mts +140 -0
- package/dist/base-0xSNl4rW.d.mts.map +1 -0
- package/dist/client-BSkUuHYm.mjs +1196 -0
- package/dist/client-BSkUuHYm.mjs.map +1 -0
- package/dist/client-Bu0aO5sT.d.mts +38 -0
- package/dist/client-Bu0aO5sT.d.mts.map +1 -0
- package/dist/index.d.mts +16 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/keys-RuC1M-_K.mjs +187 -0
- package/dist/keys-RuC1M-_K.mjs.map +1 -0
- package/dist/local.d.mts +96 -0
- package/dist/local.d.mts.map +1 -0
- package/dist/local.mjs +253 -0
- package/dist/local.mjs.map +1 -0
- package/dist/mpc/index.d.mts +3 -0
- package/dist/mpc/index.mjs +2 -0
- package/dist/types-DKsOwtWL.d.mts +73 -0
- package/dist/types-DKsOwtWL.d.mts.map +1 -0
- package/package.json +76 -0
- package/src/base.test.ts +137 -0
- package/src/base.ts +306 -0
- package/src/index.ts +3 -0
- package/src/keys.ts +10 -0
- package/src/local.test.ts +113 -0
- package/src/local.ts +495 -0
- package/src/mpc/api.ts +122 -0
- package/src/mpc/client.ts +411 -0
- package/src/mpc/engine-client.ts +144 -0
- package/src/mpc/generated/IdosContract.ts +92 -0
- package/src/mpc/index.ts +2 -0
- package/src/mpc/secretsharing/f256.ts +122 -0
- package/src/mpc/secretsharing/finite-field-element.ts +50 -0
- package/src/mpc/secretsharing/lagrange.ts +163 -0
- package/src/mpc/secretsharing/polynomial.ts +84 -0
- package/src/mpc/secretsharing/secret-share-factory.ts +30 -0
- package/src/mpc/secretsharing/secret-shares.ts +20 -0
- package/src/mpc/secretsharing/shamir-secret-shares.ts +164 -0
- package/src/mpc/secretsharing/xor-secret-shares.ts +68 -0
- package/src/mpc/types.ts +117 -0
- package/src/types.ts +37 -0
package/src/mpc/types.ts
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import type { TypedDataDomain, TypedDataField } from "ethers";
|
|
2
|
+
|
|
3
|
+
export type PbcAddress = string;
|
|
4
|
+
export type Bytes32 = string;
|
|
5
|
+
export type Bytes24 = string;
|
|
6
|
+
export type Address = string;
|
|
7
|
+
export type Bytes = string;
|
|
8
|
+
|
|
9
|
+
export const UPLOAD_TYPES: Record<string, TypedDataField[]> = {
|
|
10
|
+
UploadSignatureMessage: [
|
|
11
|
+
{ name: "share_commitments", type: "bytes32[]" },
|
|
12
|
+
{ name: "recovering_addresses", type: "string[]" },
|
|
13
|
+
],
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const DOWNLOAD_TYPES: Record<string, TypedDataField[]> = {
|
|
17
|
+
DownloadSignatureMessage: [
|
|
18
|
+
{ name: "recovering_address", type: "string" },
|
|
19
|
+
{ name: "timestamp", type: "uint64" },
|
|
20
|
+
{ name: "public_key", type: "bytes32" },
|
|
21
|
+
],
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const UPDATE_TYPES: Record<string, TypedDataField[]> = {
|
|
25
|
+
UpdateWalletsSignatureMessage: [
|
|
26
|
+
{ name: "recovering_addresses", type: "string[]" },
|
|
27
|
+
{ name: "timestamp", type: "uint64" },
|
|
28
|
+
],
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const ADD_ADDRESS_TYPES: Record<string, TypedDataField[]> = {
|
|
32
|
+
AddAddressSignatureMessage: [
|
|
33
|
+
{ name: "recovering_address", type: "string" },
|
|
34
|
+
{ name: "address_to_add", type: "string" },
|
|
35
|
+
{ name: "timestamp", type: "uint64" },
|
|
36
|
+
],
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const REMOVE_ADDRESS_TYPES: Record<string, TypedDataField[]> = {
|
|
40
|
+
RemoveAddressSignatureMessage: [
|
|
41
|
+
{ name: "recovering_address", type: "string" },
|
|
42
|
+
{ name: "address_to_remove", type: "string" },
|
|
43
|
+
{ name: "timestamp", type: "uint64" },
|
|
44
|
+
],
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export interface UploadSignatureMessage {
|
|
48
|
+
share_commitments: Bytes32[];
|
|
49
|
+
recovering_addresses: Address[];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface Sharing {
|
|
53
|
+
share_commitments: Bytes32[];
|
|
54
|
+
recovering_addresses: Address[];
|
|
55
|
+
share_data: Bytes;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface DownloadSignatureMessage {
|
|
59
|
+
recovering_address: Address;
|
|
60
|
+
timestamp: number;
|
|
61
|
+
public_key: Bytes32;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type DownloadRequest = DownloadSignatureMessage;
|
|
65
|
+
|
|
66
|
+
export interface AddAddressSignatureMessage {
|
|
67
|
+
recovering_address: Address;
|
|
68
|
+
address_to_add: Address;
|
|
69
|
+
timestamp: number;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export type AddAddressRequest = AddAddressSignatureMessage;
|
|
73
|
+
|
|
74
|
+
export interface RemoveAddressSignatureMessage {
|
|
75
|
+
recovering_address: Address;
|
|
76
|
+
address_to_remove: Address;
|
|
77
|
+
timestamp: number;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export type RemoveAddressRequest = RemoveAddressSignatureMessage;
|
|
81
|
+
|
|
82
|
+
export interface UpdateWalletsSignatureMessage {
|
|
83
|
+
recovering_addresses: Address[];
|
|
84
|
+
timestamp: number;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export type UpdateWalletsRequest = UpdateWalletsSignatureMessage;
|
|
88
|
+
|
|
89
|
+
export interface EncryptedShare {
|
|
90
|
+
encrypted_share: Bytes;
|
|
91
|
+
public_key: Bytes32;
|
|
92
|
+
nonce: Bytes24;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export type DownloadMessageToSign = {
|
|
96
|
+
domain: TypedDataDomain;
|
|
97
|
+
types: Record<string, TypedDataField[]>;
|
|
98
|
+
value: DownloadSignatureMessage;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export type UploadMessageToSign = {
|
|
102
|
+
domain: TypedDataDomain;
|
|
103
|
+
types: Record<string, TypedDataField[]>;
|
|
104
|
+
value: UploadSignatureMessage;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export type AddAddressMessageToSign = {
|
|
108
|
+
domain: TypedDataDomain;
|
|
109
|
+
types: Record<string, TypedDataField[]>;
|
|
110
|
+
value: AddAddressSignatureMessage;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export type RemoveAddressMessageToSign = {
|
|
114
|
+
domain: TypedDataDomain;
|
|
115
|
+
types: Record<string, TypedDataField[]>;
|
|
116
|
+
value: RemoveAddressSignatureMessage;
|
|
117
|
+
};
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { EncryptionPasswordStore, WalletType } from "@idos-network/kwil-infra/actions";
|
|
2
|
+
|
|
3
|
+
export type { EncryptionPasswordStore };
|
|
4
|
+
|
|
5
|
+
export type PublicEncryptionProfile = {
|
|
6
|
+
userId: string;
|
|
7
|
+
userEncryptionPublicKey: string;
|
|
8
|
+
encryptionPasswordStore: EncryptionPasswordStore;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type PrivateEncryptionProfile = {
|
|
12
|
+
userId: string;
|
|
13
|
+
password: string;
|
|
14
|
+
keyPair: nacl.BoxKeyPair;
|
|
15
|
+
encryptionPasswordStore: EncryptionPasswordStore;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type EnclaveOptions = {
|
|
19
|
+
theme?: "light" | "dark";
|
|
20
|
+
mode?: "new" | "existing";
|
|
21
|
+
userId?: string;
|
|
22
|
+
expectedUserEncryptionPublicKey?: string;
|
|
23
|
+
walletAddress?: string;
|
|
24
|
+
walletPublicKey?: string;
|
|
25
|
+
walletType?: WalletType;
|
|
26
|
+
encryptionPasswordStore?: EncryptionPasswordStore;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type PasswordContext = {
|
|
30
|
+
encryptionPasswordStore: "user";
|
|
31
|
+
password: string;
|
|
32
|
+
duration?: number;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type MPCPasswordContext = {
|
|
36
|
+
encryptionPasswordStore: "mpc";
|
|
37
|
+
};
|