@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.
Files changed (44) hide show
  1. package/LICENSE +28 -0
  2. package/README.md +55 -0
  3. package/bin/relayer.js +61 -0
  4. package/bin/utils.js +14 -0
  5. package/bundle/fhevm.js +40713 -0
  6. package/bundle/fhevm.umd.cjs +24 -0
  7. package/bundle/kms_lib_bg.wasm +0 -0
  8. package/bundle/tfhe_bg.wasm +0 -0
  9. package/bundle/workerHelpers.js +2 -0
  10. package/bundle.d.ts +1 -0
  11. package/bundle.js +12 -0
  12. package/lib/config.d.ts +30 -0
  13. package/lib/index.d.ts +29 -0
  14. package/lib/init.d.ts +7 -0
  15. package/lib/kms_lib_bg.wasm +0 -0
  16. package/lib/node.cjs +1152 -0
  17. package/lib/node.d.ts +2 -0
  18. package/lib/relayer/decryptUtils.d.ts +2 -0
  19. package/lib/relayer/handles.d.ts +4 -0
  20. package/lib/relayer/network.d.ts +31 -0
  21. package/lib/relayer/network.test.d.ts +1 -0
  22. package/lib/relayer/publicDecrypt.d.ts +3 -0
  23. package/lib/relayer/publicDecrypt.test.d.ts +1 -0
  24. package/lib/relayer/sendEncryption.d.ts +41 -0
  25. package/lib/relayer/sendEncryption.test.d.ts +1 -0
  26. package/lib/relayer/userDecrypt.d.ts +11 -0
  27. package/lib/relayer/userDecrypt.test.d.ts +1 -0
  28. package/lib/sdk/encrypt.d.ts +34 -0
  29. package/lib/sdk/encrypt.test.d.ts +1 -0
  30. package/lib/sdk/encryptionTypes.d.ts +13 -0
  31. package/lib/sdk/keypair.d.ts +34 -0
  32. package/lib/sdk/keypair.test.d.ts +1 -0
  33. package/lib/test/index.d.ts +10 -0
  34. package/lib/tfhe.d.ts +7 -0
  35. package/lib/tfhe_bg.wasm +0 -0
  36. package/lib/utils.d.ts +9 -0
  37. package/lib/web.d.ts +2 -0
  38. package/lib/web.js +27305 -0
  39. package/lib/workerHelpers.js +24774 -0
  40. package/node.d.ts +1 -0
  41. package/node.js +1 -0
  42. package/package.json +99 -0
  43. package/web.d.ts +1 -0
  44. 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 };
@@ -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
@@ -0,0 +1,7 @@
1
+ import { InitInput as TFHEInput } from 'tfhe';
2
+ import { InitInput as KMSInput } from 'tkms';
3
+ export declare const initFhevm: ({ tfheParams, kmsParams, thread, }?: {
4
+ tfheParams?: TFHEInput;
5
+ kmsParams?: KMSInput;
6
+ thread?: number;
7
+ }) => Promise<boolean>;
Binary file