@zama-fhe/relayer-sdk 0.1.0-1 → 0.1.0-2
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/bundle/fhevm.js +1 -0
- package/bundle/fhevm.umd.cjs +7 -7
- package/bundle.d.ts +16 -1
- package/lib/node.cjs +8 -7
- package/lib/node.d.ts +139 -2
- package/lib/node.js +1146 -0
- package/lib/web.d.ts +141 -2
- package/lib/web.js +8 -8
- package/package.json +12 -4
- package/lib/config.d.ts +0 -30
- package/lib/index.d.ts +0 -29
- package/lib/init.d.ts +0 -7
- package/lib/relayer/decryptUtils.d.ts +0 -2
- package/lib/relayer/handles.d.ts +0 -4
- package/lib/relayer/network.d.ts +0 -31
- package/lib/relayer/network.test.d.ts +0 -1
- package/lib/relayer/publicDecrypt.d.ts +0 -3
- package/lib/relayer/publicDecrypt.test.d.ts +0 -1
- package/lib/relayer/sendEncryption.d.ts +0 -41
- package/lib/relayer/sendEncryption.test.d.ts +0 -1
- package/lib/relayer/userDecrypt.d.ts +0 -11
- package/lib/relayer/userDecrypt.test.d.ts +0 -1
- package/lib/sdk/encrypt.d.ts +0 -34
- package/lib/sdk/encrypt.test.d.ts +0 -1
- package/lib/sdk/encryptionTypes.d.ts +0 -13
- package/lib/sdk/keypair.d.ts +0 -34
- package/lib/sdk/keypair.test.d.ts +0 -1
- package/lib/test/index.d.ts +0 -10
- package/lib/tfhe.d.ts +0 -7
- package/lib/utils.d.ts +0 -9
package/bundle.d.ts
CHANGED
|
@@ -1 +1,16 @@
|
|
|
1
|
-
export
|
|
1
|
+
// Special case for bundle. Explicit named re-export is required.
|
|
2
|
+
export {
|
|
3
|
+
RelayerEncryptedInput,
|
|
4
|
+
PublicParams,
|
|
5
|
+
HandleContractPair,
|
|
6
|
+
generateKeypair,
|
|
7
|
+
createEIP712,
|
|
8
|
+
EIP712,
|
|
9
|
+
EIP712Type,
|
|
10
|
+
FhevmInstance,
|
|
11
|
+
createInstance,
|
|
12
|
+
EncryptionTypes,
|
|
13
|
+
ENCRYPTION_TYPES,
|
|
14
|
+
DecryptedResults,
|
|
15
|
+
initFhevm,
|
|
16
|
+
} from './lib/web';
|
package/lib/node.cjs
CHANGED
|
@@ -975,13 +975,13 @@ const publicDecryptRequest = (kmsSigners, thresholdSigners, gatewayChainId, veri
|
|
|
975
975
|
/**
|
|
976
976
|
* Creates an EIP712 structure specifically for user decrypt requests
|
|
977
977
|
*
|
|
978
|
-
* @param gatewayChainId The chain ID of the gateway
|
|
979
|
-
* @param verifyingContract The address of the contract that will verify the signature
|
|
980
|
-
* @param publicKey The user's public key as a hex string or Uint8Array
|
|
981
|
-
* @param contractAddresses Array of contract addresses that can access the decryption
|
|
982
|
-
* @param contractsChainId The chain ID where the contracts are deployed
|
|
983
|
-
* @param startTimestamp The timestamp when the decryption permission becomes valid
|
|
984
|
-
* @param durationDays How many days the decryption permission remains valid
|
|
978
|
+
* @param gatewayChainId - The chain ID of the gateway
|
|
979
|
+
* @param verifyingContract - The address of the contract that will verify the signature
|
|
980
|
+
* @param publicKey - The user's public key as a hex string or Uint8Array
|
|
981
|
+
* @param contractAddresses - Array of contract addresses that can access the decryption
|
|
982
|
+
* @param contractsChainId - The chain ID where the contracts are deployed
|
|
983
|
+
* @param startTimestamp - The timestamp when the decryption permission becomes valid
|
|
984
|
+
* @param durationDays - How many days the decryption permission remains valid
|
|
985
985
|
* @returns EIP712 typed data structure for user decryption
|
|
986
986
|
*/
|
|
987
987
|
const createEIP712 = (gatewayChainId, verifyingContract, contractsChainId) => (publicKey, contractAddresses, startTimestamp, durationDays, delegatedAccount) => {
|
|
@@ -1145,6 +1145,7 @@ const createTfhePublicKey = () => {
|
|
|
1145
1145
|
return toHexString(publicKey.serialize());
|
|
1146
1146
|
};
|
|
1147
1147
|
|
|
1148
|
+
exports.ENCRYPTION_TYPES = ENCRYPTION_TYPES;
|
|
1148
1149
|
exports.createEIP712 = createEIP712;
|
|
1149
1150
|
exports.createInstance = createInstance;
|
|
1150
1151
|
exports.createTfheKeypair = createTfheKeypair;
|
package/lib/node.d.ts
CHANGED
|
@@ -1,2 +1,139 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { CompactPkeCrs } from 'node-tfhe';
|
|
2
|
+
import { Eip1193Provider } from 'ethers';
|
|
3
|
+
import { TfheClientKey } from 'node-tfhe';
|
|
4
|
+
import { TfheCompactPublicKey } from 'node-tfhe';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Creates an EIP712 structure specifically for user decrypt requests
|
|
8
|
+
*
|
|
9
|
+
* @param gatewayChainId - The chain ID of the gateway
|
|
10
|
+
* @param verifyingContract - The address of the contract that will verify the signature
|
|
11
|
+
* @param publicKey - The user's public key as a hex string or Uint8Array
|
|
12
|
+
* @param contractAddresses - Array of contract addresses that can access the decryption
|
|
13
|
+
* @param contractsChainId - The chain ID where the contracts are deployed
|
|
14
|
+
* @param startTimestamp - The timestamp when the decryption permission becomes valid
|
|
15
|
+
* @param durationDays - How many days the decryption permission remains valid
|
|
16
|
+
* @returns EIP712 typed data structure for user decryption
|
|
17
|
+
*/
|
|
18
|
+
export declare const createEIP712: (gatewayChainId: number, verifyingContract: string, contractsChainId: number) => (publicKey: string | Uint8Array, contractAddresses: string[], startTimestamp: string | number, durationDays: string | number, delegatedAccount?: string) => EIP712;
|
|
19
|
+
|
|
20
|
+
export declare const createInstance: (config: FhevmInstanceConfig) => Promise<FhevmInstance>;
|
|
21
|
+
|
|
22
|
+
export declare const createTfheKeypair: () => {
|
|
23
|
+
clientKey: TfheClientKey;
|
|
24
|
+
publicKey: TfheCompactPublicKey;
|
|
25
|
+
crs: CompactPkeCrs;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export declare const createTfhePublicKey: () => string;
|
|
29
|
+
|
|
30
|
+
export declare type DecryptedResults = Record<string, bigint | boolean | string>;
|
|
31
|
+
|
|
32
|
+
export declare type EIP712 = {
|
|
33
|
+
domain: {
|
|
34
|
+
chainId: number;
|
|
35
|
+
name: string;
|
|
36
|
+
verifyingContract: string;
|
|
37
|
+
version: string;
|
|
38
|
+
};
|
|
39
|
+
message: any;
|
|
40
|
+
primaryType: string;
|
|
41
|
+
types: {
|
|
42
|
+
[key: string]: EIP712Type[];
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export declare type EIP712Type = {
|
|
47
|
+
name: string;
|
|
48
|
+
type: string;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export declare const ENCRYPTION_TYPES: {
|
|
52
|
+
1: number;
|
|
53
|
+
8: number;
|
|
54
|
+
16: number;
|
|
55
|
+
32: number;
|
|
56
|
+
64: number;
|
|
57
|
+
128: number;
|
|
58
|
+
160: number;
|
|
59
|
+
256: number;
|
|
60
|
+
512: number;
|
|
61
|
+
1024: number;
|
|
62
|
+
2048: number;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export declare type EncryptionTypes = keyof typeof ENCRYPTION_TYPES;
|
|
66
|
+
|
|
67
|
+
export declare type FhevmInstance = {
|
|
68
|
+
createEncryptedInput: (contractAddress: string, userAddress: string) => RelayerEncryptedInput;
|
|
69
|
+
generateKeypair: () => {
|
|
70
|
+
publicKey: string;
|
|
71
|
+
privateKey: string;
|
|
72
|
+
};
|
|
73
|
+
createEIP712: (publicKey: string, contractAddresses: string[], startTimestamp: string | number, durationDays: string | number) => EIP712;
|
|
74
|
+
publicDecrypt: (handles: (string | Uint8Array)[]) => Promise<DecryptedResults>;
|
|
75
|
+
userDecrypt: (handles: HandleContractPair[], privateKey: string, publicKey: string, signature: string, contractAddresses: string[], userAddress: string, startTimestamp: string | number, durationDays: string | number) => Promise<DecryptedResults>;
|
|
76
|
+
getPublicKey: () => {
|
|
77
|
+
publicKeyId: string;
|
|
78
|
+
publicKey: Uint8Array;
|
|
79
|
+
} | null;
|
|
80
|
+
getPublicParams: (bits: keyof PublicParams) => {
|
|
81
|
+
publicParams: Uint8Array;
|
|
82
|
+
publicParamsId: string;
|
|
83
|
+
} | null;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export declare type FhevmInstanceConfig = {
|
|
87
|
+
verifyingContractAddressDecryption: string;
|
|
88
|
+
verifyingContractAddressInputVerification: string;
|
|
89
|
+
kmsContractAddress: string;
|
|
90
|
+
inputVerifierContractAddress: string;
|
|
91
|
+
aclContractAddress: string;
|
|
92
|
+
gatewayChainId: number;
|
|
93
|
+
chainId?: number;
|
|
94
|
+
relayerUrl?: string;
|
|
95
|
+
network?: Eip1193Provider | string;
|
|
96
|
+
publicParams?: PublicParams<Uint8Array> | null;
|
|
97
|
+
publicKey?: {
|
|
98
|
+
data: Uint8Array | null;
|
|
99
|
+
id: string | null;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export declare const generateKeypair: () => {
|
|
104
|
+
publicKey: string;
|
|
105
|
+
privateKey: string;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export declare type HandleContractPair = {
|
|
109
|
+
handle: Uint8Array | string;
|
|
110
|
+
contractAddress: string;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export declare type PublicParams<T = CompactPkeCrs> = {
|
|
114
|
+
[key in EncryptionTypes]?: {
|
|
115
|
+
publicParams: T;
|
|
116
|
+
publicParamsId: string;
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export declare type RelayerEncryptedInput = {
|
|
121
|
+
addBool: (value: boolean | number | bigint) => RelayerEncryptedInput;
|
|
122
|
+
add8: (value: number | bigint) => RelayerEncryptedInput;
|
|
123
|
+
add16: (value: number | bigint) => RelayerEncryptedInput;
|
|
124
|
+
add32: (value: number | bigint) => RelayerEncryptedInput;
|
|
125
|
+
add64: (value: number | bigint) => RelayerEncryptedInput;
|
|
126
|
+
add128: (value: number | bigint) => RelayerEncryptedInput;
|
|
127
|
+
add256: (value: number | bigint) => RelayerEncryptedInput;
|
|
128
|
+
addBytes64: (value: Uint8Array) => RelayerEncryptedInput;
|
|
129
|
+
addBytes128: (value: Uint8Array) => RelayerEncryptedInput;
|
|
130
|
+
addBytes256: (value: Uint8Array) => RelayerEncryptedInput;
|
|
131
|
+
addAddress: (value: string) => RelayerEncryptedInput;
|
|
132
|
+
getBits: () => EncryptionTypes[];
|
|
133
|
+
encrypt: () => Promise<{
|
|
134
|
+
handles: Uint8Array[];
|
|
135
|
+
inputProof: Uint8Array;
|
|
136
|
+
}>;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export { }
|