@zama-fhe/relayer-sdk 0.1.0-1
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 +28 -0
- package/README.md +55 -0
- package/bin/relayer.js +61 -0
- package/bin/utils.js +14 -0
- package/bundle/fhevm.js +40713 -0
- package/bundle/fhevm.umd.cjs +24 -0
- package/bundle/kms_lib_bg.wasm +0 -0
- package/bundle/tfhe_bg.wasm +0 -0
- package/bundle/workerHelpers.js +2 -0
- package/bundle.d.ts +1 -0
- package/bundle.js +12 -0
- package/lib/config.d.ts +30 -0
- package/lib/index.d.ts +29 -0
- package/lib/init.d.ts +7 -0
- package/lib/kms_lib_bg.wasm +0 -0
- package/lib/node.cjs +1152 -0
- package/lib/node.d.ts +2 -0
- package/lib/relayer/decryptUtils.d.ts +2 -0
- package/lib/relayer/handles.d.ts +4 -0
- package/lib/relayer/network.d.ts +31 -0
- package/lib/relayer/network.test.d.ts +1 -0
- package/lib/relayer/publicDecrypt.d.ts +3 -0
- package/lib/relayer/publicDecrypt.test.d.ts +1 -0
- package/lib/relayer/sendEncryption.d.ts +41 -0
- package/lib/relayer/sendEncryption.test.d.ts +1 -0
- package/lib/relayer/userDecrypt.d.ts +11 -0
- package/lib/relayer/userDecrypt.test.d.ts +1 -0
- package/lib/sdk/encrypt.d.ts +34 -0
- package/lib/sdk/encrypt.test.d.ts +1 -0
- package/lib/sdk/encryptionTypes.d.ts +13 -0
- package/lib/sdk/keypair.d.ts +34 -0
- package/lib/sdk/keypair.test.d.ts +1 -0
- package/lib/test/index.d.ts +10 -0
- package/lib/tfhe.d.ts +7 -0
- package/lib/tfhe_bg.wasm +0 -0
- package/lib/utils.d.ts +9 -0
- package/lib/web.d.ts +2 -0
- package/lib/web.js +27305 -0
- package/lib/workerHelpers.js +24774 -0
- package/node.d.ts +1 -0
- package/node.js +1 -0
- package/package.json +99 -0
- package/web.d.ts +1 -0
- package/web.js +1 -0
package/bundle.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/web';
|
package/bundle.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const waitForFunction =
|
|
2
|
+
(functionName) =>
|
|
3
|
+
async (...params) => {
|
|
4
|
+
if (window && window.fhevm) {
|
|
5
|
+
return window.fhevm[functionName](...params);
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const initFhevm = waitForFunction('initFhevm');
|
|
10
|
+
const createInstance = waitForFunction('createInstance');
|
|
11
|
+
|
|
12
|
+
export { initFhevm, createInstance };
|
package/lib/config.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { BrowserProvider, Eip1193Provider, JsonRpcProvider, Provider } from 'ethers';
|
|
2
|
+
import { PublicParams } from './sdk/encrypt';
|
|
3
|
+
import { TfheCompactPublicKey } from 'node-tfhe';
|
|
4
|
+
export type FhevmInstanceConfig = {
|
|
5
|
+
verifyingContractAddressDecryption: string;
|
|
6
|
+
verifyingContractAddressInputVerification: string;
|
|
7
|
+
kmsContractAddress: string;
|
|
8
|
+
inputVerifierContractAddress: string;
|
|
9
|
+
aclContractAddress: string;
|
|
10
|
+
gatewayChainId: number;
|
|
11
|
+
chainId?: number;
|
|
12
|
+
relayerUrl?: string;
|
|
13
|
+
network?: Eip1193Provider | string;
|
|
14
|
+
publicParams?: PublicParams<Uint8Array> | null;
|
|
15
|
+
publicKey?: {
|
|
16
|
+
data: Uint8Array | null;
|
|
17
|
+
id: string | null;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export declare const getProvider: (config: FhevmInstanceConfig) => JsonRpcProvider | BrowserProvider;
|
|
21
|
+
export declare const getChainId: (provider: Provider, config: FhevmInstanceConfig) => Promise<number>;
|
|
22
|
+
export declare const getTfheCompactPublicKey: (config: FhevmInstanceConfig) => Promise<{
|
|
23
|
+
publicKey: TfheCompactPublicKey;
|
|
24
|
+
publicKeyId: string;
|
|
25
|
+
}>;
|
|
26
|
+
export declare const getPublicParams: (config: FhevmInstanceConfig) => Promise<PublicParams>;
|
|
27
|
+
export declare const getKMSSigners: (provider: Provider, config: FhevmInstanceConfig) => Promise<string[]>;
|
|
28
|
+
export declare const getKMSSignersThreshold: (provider: Provider, config: FhevmInstanceConfig) => Promise<number>;
|
|
29
|
+
export declare const getCoprocessorSigners: (provider: Provider, config: FhevmInstanceConfig) => Promise<string[]>;
|
|
30
|
+
export declare const getCoprocessorSignersThreshold: (provider: Provider, config: FhevmInstanceConfig) => Promise<number>;
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { FhevmInstanceConfig } from './config';
|
|
2
|
+
import { HandleContractPair } from './relayer/userDecrypt';
|
|
3
|
+
import { RelayerEncryptedInput } from './relayer/sendEncryption';
|
|
4
|
+
import { DecryptedResults } from './relayer/decryptUtils';
|
|
5
|
+
import { PublicParams } from './sdk/encrypt';
|
|
6
|
+
import { EIP712 } from './sdk/keypair';
|
|
7
|
+
export { generateKeypair, createEIP712, EIP712, EIP712Type, } from './sdk/keypair';
|
|
8
|
+
export { RelayerEncryptedInput } from './relayer/sendEncryption';
|
|
9
|
+
export { HandleContractPair } from './relayer/userDecrypt';
|
|
10
|
+
export { PublicParams } from './sdk/encrypt';
|
|
11
|
+
export type FhevmInstance = {
|
|
12
|
+
createEncryptedInput: (contractAddress: string, userAddress: string) => RelayerEncryptedInput;
|
|
13
|
+
generateKeypair: () => {
|
|
14
|
+
publicKey: string;
|
|
15
|
+
privateKey: string;
|
|
16
|
+
};
|
|
17
|
+
createEIP712: (publicKey: string, contractAddresses: string[], startTimestamp: string | number, durationDays: string | number) => EIP712;
|
|
18
|
+
publicDecrypt: (handles: (string | Uint8Array)[]) => Promise<DecryptedResults>;
|
|
19
|
+
userDecrypt: (handles: HandleContractPair[], privateKey: string, publicKey: string, signature: string, contractAddresses: string[], userAddress: string, startTimestamp: string | number, durationDays: string | number) => Promise<DecryptedResults>;
|
|
20
|
+
getPublicKey: () => {
|
|
21
|
+
publicKeyId: string;
|
|
22
|
+
publicKey: Uint8Array;
|
|
23
|
+
} | null;
|
|
24
|
+
getPublicParams: (bits: keyof PublicParams) => {
|
|
25
|
+
publicParams: Uint8Array;
|
|
26
|
+
publicParamsId: string;
|
|
27
|
+
} | null;
|
|
28
|
+
};
|
|
29
|
+
export declare const createInstance: (config: FhevmInstanceConfig) => Promise<FhevmInstance>;
|
package/lib/init.d.ts
ADDED
|
Binary file
|