@inco/js 0.1.9

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 (93) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +50 -0
  3. package/dist/binary.d.ts +17 -0
  4. package/dist/chain.d.ts +22 -0
  5. package/dist/encryption/encryption.d.ts +118 -0
  6. package/dist/encryption/index.d.ts +1 -0
  7. package/dist/fhevm/fhe-environment.d.ts +9 -0
  8. package/dist/fhevm/fhevm.d.ts +41 -0
  9. package/dist/fhevm/index.cjs +87 -0
  10. package/dist/fhevm/index.d.ts +1 -0
  11. package/dist/fhevm/index.mjs +83 -0
  12. package/dist/fhevm/reencrypt.d.ts +20 -0
  13. package/dist/fhevm/tfhe.d.ts +74 -0
  14. package/dist/fhevm/types.d.ts +3 -0
  15. package/dist/generated/abis/inco-fhevm.d.ts +8698 -0
  16. package/dist/generated/abis/inco-lite.d.ts +21794 -0
  17. package/dist/generated/es/cosmos/ics23/v1/proofs_pb.d.ts +593 -0
  18. package/dist/generated/es/cosmos/msg/v1/msg_pb.d.ts +29 -0
  19. package/dist/generated/es/cosmos_proto/cosmos_pb.d.ts +174 -0
  20. package/dist/generated/es/google/api/annotations_pb.d.ts +13 -0
  21. package/dist/generated/es/google/api/http_pb.d.ts +440 -0
  22. package/dist/generated/es/inco/fhe/v1/events_pb.d.ts +79 -0
  23. package/dist/generated/es/inco/fhe/v1/genesis_pb.d.ts +252 -0
  24. package/dist/generated/es/inco/fhe/v1/query_pb.d.ts +569 -0
  25. package/dist/generated/es/inco/fhe/v1/tx_pb.d.ts +494 -0
  26. package/dist/generated/es/inco/fhe/v1/types_pb.d.ts +419 -0
  27. package/dist/generated/es/inco/kms/lite/v1/kms_service_pb.d.ts +181 -0
  28. package/dist/generated/es/inco/kms/lite/v1/types_pb.d.ts +212 -0
  29. package/dist/generated/es/inco/preflight/v1/genesis_pb.d.ts +56 -0
  30. package/dist/generated/es/inco/preflight/v1/query_pb.d.ts +100 -0
  31. package/dist/generated/es/inco/preflight/v1/tx_pb.d.ts +193 -0
  32. package/dist/generated/es/inco/preflight/v1/types_pb.d.ts +144 -0
  33. package/dist/generated/es/kms/base_pb.d.ts +765 -0
  34. package/dist/generated/es/sf/ethereum/type/v2/type_pb.d.ts +1736 -0
  35. package/dist/generated/fhe-environments.d.ts +14 -0
  36. package/dist/generated/inco-lite.d.ts +61 -0
  37. package/dist/generated/ts/amino/amino.d.ts +1 -0
  38. package/dist/generated/ts/cometbft/abci/v1/types.d.ts +597 -0
  39. package/dist/generated/ts/cometbft/crypto/v1/keys.d.ts +27 -0
  40. package/dist/generated/ts/cometbft/crypto/v1/proof.d.ts +60 -0
  41. package/dist/generated/ts/cometbft/types/v1/params.d.ts +179 -0
  42. package/dist/generated/ts/cometbft/types/v1/validator.d.ts +61 -0
  43. package/dist/generated/ts/cosmos/app/v1alpha1/module.d.ts +104 -0
  44. package/dist/generated/ts/cosmos/msg/v1/msg.d.ts +1 -0
  45. package/dist/generated/ts/cosmos_proto/cosmos.d.ts +80 -0
  46. package/dist/generated/ts/gogoproto/gogo.d.ts +1 -0
  47. package/dist/generated/ts/google/api/annotations.d.ts +1 -0
  48. package/dist/generated/ts/google/api/http.d.ts +371 -0
  49. package/dist/generated/ts/google/protobuf/descriptor.d.ts +1228 -0
  50. package/dist/generated/ts/google/protobuf/duration.d.ts +99 -0
  51. package/dist/generated/ts/google/protobuf/timestamp.d.ts +128 -0
  52. package/dist/generated/ts/google/protobuf/wrappers.d.ts +111 -0
  53. package/dist/generated/ts/inco/abci/v1/types.d.ts +35 -0
  54. package/dist/generated/ts/inco/fhe/module/v1/module.d.ts +31 -0
  55. package/dist/generated/ts/inco/fhe/v1/events.d.ts +66 -0
  56. package/dist/generated/ts/inco/fhe/v1/genesis.d.ts +117 -0
  57. package/dist/generated/ts/inco/fhe/v1/query.d.ts +366 -0
  58. package/dist/generated/ts/inco/fhe/v1/tx.d.ts +409 -0
  59. package/dist/generated/ts/inco/fhe/v1/types.d.ts +225 -0
  60. package/dist/generated/ts/inco/originchain/module/v1/module.d.ts +30 -0
  61. package/dist/generated/ts/inco/originchain/v1/abci.d.ts +80 -0
  62. package/dist/generated/ts/inco/originchain/v1/events.d.ts +60 -0
  63. package/dist/generated/ts/inco/originchain/v1/genesis.d.ts +28 -0
  64. package/dist/generated/ts/inco/originchain/v1/query.d.ts +116 -0
  65. package/dist/generated/ts/inco/originchain/v1/tx.d.ts +89 -0
  66. package/dist/generated/ts/inco/originchain/v1/types.d.ts +58 -0
  67. package/dist/generated/ts/inco/preflight/module/v1/module.d.ts +31 -0
  68. package/dist/generated/ts/inco/preflight/v1/genesis.d.ts +41 -0
  69. package/dist/generated/ts/inco/preflight/v1/query.d.ts +93 -0
  70. package/dist/generated/ts/inco/preflight/v1/tx.d.ts +187 -0
  71. package/dist/generated/ts/inco/preflight/v1/types.d.ts +84 -0
  72. package/dist/handle.d.ts +41 -0
  73. package/dist/index.cjs +22952 -0
  74. package/dist/index.d.ts +4 -0
  75. package/dist/index.mjs +24026 -0
  76. package/dist/l1/client.d.ts +35 -0
  77. package/dist/l1/index.d.ts +2 -0
  78. package/dist/l1/preflight.d.ts +20 -0
  79. package/dist/lite/deployments.d.ts +6 -0
  80. package/dist/lite/ecies.d.ts +26 -0
  81. package/dist/lite/hadu.d.ts +24 -0
  82. package/dist/lite/index.cjs +54911 -0
  83. package/dist/lite/index.d.ts +6 -0
  84. package/dist/lite/index.mjs +73891 -0
  85. package/dist/lite/reencrypt.d.ts +23 -0
  86. package/dist/reencryption/eip712.d.ts +29 -0
  87. package/dist/reencryption/index.cjs +22675 -0
  88. package/dist/reencryption/index.d.ts +2 -0
  89. package/dist/reencryption/index.mjs +22671 -0
  90. package/dist/reencryption/types.d.ts +24 -0
  91. package/dist/schema.d.ts +4 -0
  92. package/dist/viem.d.ts +385 -0
  93. package/package.json +92 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # @inco/js (called `@inco/js` for now)
2
+
3
+ The @inco/js package contains the TypeScript SDK for creating dapps built on Inco.
4
+
5
+ ## Install the package
6
+
7
+ Since the package is private in the Github package registry, you'll need to use npm to log in into the registry first. Obviously, this is only needed if you want to access the package from outside the monorepo, as the monorepo already has workspaces set up.
8
+
9
+ 1. Create a Github Personal Access Token (Classic)
10
+
11
+ Go to the [Personal Access Tokens](https://github.com/settings/tokens) page on Github, and create a new access token with the `read:packages` permission. Give it an explicit name like `inco-js-npm-github-pkg-registry`, and save the access token in a secure place, e.g. your password manager.
12
+
13
+ 2. Login via npm to Github Package Registry.
14
+
15
+ ```bash
16
+ cd /path/to/my/project
17
+ npm login --scope=@inco-fhevm --registry=https://npm.pkg.github.com
18
+ ```
19
+
20
+ You'll be asked to enter Username and Password. Put in your Github username, and paste the access token on step 1 as password.
21
+
22
+ 3. Tell npm to look into Github Package Registry.
23
+
24
+ Create a new `.npmrc` in `/path/to/my/project`, with the following lines:
25
+
26
+ ```
27
+ @inco-fhevm:registry=https://npm.pkg.github.com
28
+ //npm.pkg.github.com/:_authToken=${READ_PACKAGE_TOKEN}
29
+ ```
30
+
31
+ Then, you can do `npm install @inco/js`!
32
+
33
+ Note: If using bun or another package manager, take a look how they manage install scopes.
34
+
35
+ 4. Resources
36
+
37
+ - Github docs: https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry
38
+ - Medium article: https://medium.com/@aamiralihussain53/a-guide-to-publishing-private-npm-package-on-github-9c533a251e2d
39
+
40
+ ## Usage
41
+
42
+ Currently, there are no docs as how to use the @inco/js package, as it only exposes low-level functions. There's some API work to do to make it more user-friendly.
43
+
44
+ To take a look at the low-level functions, see [the E2E test](./test/incolite.ts), which shows how to encrypt, send an encrypted input to the host chain, request a reencrypt and wait for a decrypt.
45
+
46
+ ## Publishing the package
47
+
48
+ Currently the publishing process is manual, and anyone with enough rights can run `bun run publish:github` to publish to the Github Packages registry.
49
+
50
+ Some gitops process should replace this manual setup.
@@ -0,0 +1,17 @@
1
+ import { Schema } from 'effect';
2
+ import { Hex } from 'viem';
3
+ export declare const HexString: Schema.TemplateLiteral<`0x${string}`>;
4
+ export type HexString = typeof HexString.Type;
5
+ export type BytesIsh = string | Uint8Array;
6
+ export declare function bytesToBigInt(byteArray: Uint8Array): bigint;
7
+ export declare function bufferToBigInt(buffer: Buffer): bigint;
8
+ export declare function bigintToBytes32(value: bigint): Bytes32;
9
+ export declare function padLeft(bs: Uint8Array, n: number): Buffer;
10
+ export declare function bytes32ToBigint(bs: BytesIsh): bigint;
11
+ export declare function bytesFromHexString(hexString: string): Buffer;
12
+ export declare function mustBeHex(value: string): Hex;
13
+ export declare function normaliseToHex(value: string): Hex;
14
+ export declare function bytesToHex(bs: Uint8Array): Hex;
15
+ export declare const Bytes32: Schema.brand<Schema.filter<Schema.transformOrFail<Schema.Union<[typeof Schema.String, Schema.refine<object & Uint8Array<ArrayBufferLike>, Schema.Schema<object, object, never>>]>, Schema.TemplateLiteral<`0x${string}`>, never>>, "Bytes32">;
16
+ export declare function asBytes32(x: BytesIsh): Bytes32;
17
+ export type Bytes32 = typeof Bytes32.Type;
@@ -0,0 +1,22 @@
1
+ export declare const supportedChains: {
2
+ readonly baseSepolia: 84532;
3
+ readonly sepolia: 11155111;
4
+ readonly monadTestnet: 10143;
5
+ };
6
+ export declare const fheSupportedChains: {
7
+ readonly baseSepolia: 84532;
8
+ readonly sepolia: 11155111;
9
+ };
10
+ type SupportedChains = typeof supportedChains;
11
+ export type SupportedChainId = SupportedChains[keyof SupportedChains];
12
+ export type SupportedChainName = keyof SupportedChains;
13
+ export type SupportedChain = {
14
+ name: SupportedChainName;
15
+ id: SupportedChainId;
16
+ };
17
+ export type Numberish = number | bigint;
18
+ export type Chainish = {
19
+ id: Numberish;
20
+ } | Numberish | string;
21
+ export declare function getSupportedChain(chainish: Chainish): SupportedChain;
22
+ export {};
@@ -0,0 +1,118 @@
1
+ import { Schema } from 'effect';
2
+ import { Bytes32 } from '../binary';
3
+ import { InputContext } from '../handle';
4
+ export type Encryptor<S extends EncryptionScheme = EncryptionScheme> = <T extends SupportedFheType>(plaintext: PlaintextWithContextOf<S, T>) => Promise<EncryptResultOf<S, T>>;
5
+ export type Decryptor<S extends EncryptionScheme = EncryptionScheme> = <T extends SupportedFheType>(ciphertext: CiphertextOf<S, T>, context?: InputContext) => Promise<PlaintextOf<S, T>>;
6
+ export declare const supportedFheTypes: {
7
+ readonly euint64: 5;
8
+ readonly euint256: 8;
9
+ readonly ebool: 0;
10
+ };
11
+ export declare const SupportedFheTypeName: Schema.SchemaClass<"ebool" | "euint64" | "euint256", "ebool" | "euint64" | "euint256", never>;
12
+ export type SupportedFheTypeName = typeof SupportedFheTypeName.Type;
13
+ export declare const SupportedFheType: Schema.SchemaClass<0 | 5 | 8, 0 | 5 | 8, never>;
14
+ export type SupportedFheType = typeof SupportedFheType.Type;
15
+ export declare const encryptionSchemes: {
16
+ readonly tfhe: 0;
17
+ readonly ecies: 1;
18
+ readonly cryptobox: 2;
19
+ };
20
+ export declare function getEncryptionSchemeName(scheme: number): string;
21
+ export type EncryptionSchemes = typeof encryptionSchemes;
22
+ export type EciesScheme = EncryptionSchemes['ecies'];
23
+ export type TfheScheme = EncryptionSchemes['tfhe'];
24
+ export type CryptoboxScheme = EncryptionSchemes['cryptobox'];
25
+ export declare const EncryptionScheme: Schema.Literal<[0, 1, 2]>;
26
+ export type EncryptionScheme = typeof EncryptionScheme.Type;
27
+ type DistType<P, S extends EncryptionScheme, T extends SupportedFheType> = P extends any ? P & {
28
+ scheme: S;
29
+ type: T;
30
+ } : never;
31
+ export declare const ciphertextEnvelopes: {
32
+ readonly none: 0;
33
+ readonly hadu: 1;
34
+ };
35
+ export declare const CiphertextEnvelope: Schema.SchemaClass<0 | 1, 0 | 1, never>;
36
+ export declare const Ciphertext: Schema.Struct<{
37
+ scheme: Schema.Literal<[0, 1, 2]>;
38
+ type: Schema.SchemaClass<0 | 5 | 8, 0 | 5 | 8, never>;
39
+ value: Schema.TemplateLiteral<`0x${string}`>;
40
+ envelope: Schema.optional<Schema.SchemaClass<0 | 1, 0 | 1, never>>;
41
+ }>;
42
+ export type Ciphertext = typeof Ciphertext.Type;
43
+ export type CiphertextOf<S extends EncryptionScheme, T extends SupportedFheType> = DistType<Ciphertext, S, T>;
44
+ export declare const CiphertextWithContext: Schema.Struct<{
45
+ ciphertext: Schema.Struct<{
46
+ scheme: Schema.Literal<[0, 1, 2]>;
47
+ type: Schema.SchemaClass<0 | 5 | 8, 0 | 5 | 8, never>;
48
+ value: Schema.TemplateLiteral<`0x${string}`>;
49
+ envelope: Schema.optional<Schema.SchemaClass<0 | 1, 0 | 1, never>>;
50
+ }>;
51
+ context: Schema.Struct<{
52
+ hostChainId: typeof Schema.BigInt;
53
+ aclAddress: Schema.TemplateLiteral<`0x${string}`>;
54
+ userAddress: Schema.TemplateLiteral<`0x${string}`>;
55
+ contractAddress: Schema.TemplateLiteral<`0x${string}`>;
56
+ }>;
57
+ }>;
58
+ export type CiphertextWithContext = typeof CiphertextWithContext.Type;
59
+ export type CiphertextWithContextOf<S extends EncryptionScheme, T extends SupportedFheType> = CiphertextWithContext & {
60
+ ciphertext: CiphertextOf<S, T>;
61
+ };
62
+ export declare const EncryptResult: Schema.Struct<{
63
+ ciphertext: Schema.Struct<{
64
+ scheme: Schema.Literal<[0, 1, 2]>;
65
+ type: Schema.SchemaClass<0 | 5 | 8, 0 | 5 | 8, never>;
66
+ value: Schema.TemplateLiteral<`0x${string}`>;
67
+ envelope: Schema.optional<Schema.SchemaClass<0 | 1, 0 | 1, never>>;
68
+ }>;
69
+ context: Schema.Struct<{
70
+ hostChainId: typeof Schema.BigInt;
71
+ aclAddress: Schema.TemplateLiteral<`0x${string}`>;
72
+ userAddress: Schema.TemplateLiteral<`0x${string}`>;
73
+ contractAddress: Schema.TemplateLiteral<`0x${string}`>;
74
+ }>;
75
+ prehandle: Schema.brand<Schema.filter<Schema.transformOrFail<Schema.Union<[typeof Schema.String, Schema.refine<object & Uint8Array<ArrayBufferLike>, Schema.Schema<object, object, never>>]>, Schema.TemplateLiteral<`0x${string}`>, never>>, "Bytes32">;
76
+ handle: Schema.brand<Schema.filter<Schema.transformOrFail<Schema.Union<[typeof Schema.String, Schema.refine<object & Uint8Array<ArrayBufferLike>, Schema.Schema<object, object, never>>]>, Schema.TemplateLiteral<`0x${string}`>, never>>, "Bytes32">;
77
+ }>;
78
+ export type EncryptResult = typeof EncryptResult.Type;
79
+ export type EncryptResultOf<S extends EncryptionScheme, T extends SupportedFheType> = EncryptResult & {
80
+ ciphertext: CiphertextOf<S, T>;
81
+ };
82
+ export declare const Plaintext: Schema.Union<[Schema.Struct<{
83
+ scheme: Schema.Literal<[0, 1, 2]>;
84
+ type: Schema.Literal<[5, 8]>;
85
+ value: typeof Schema.BigInt;
86
+ }>, Schema.Struct<{
87
+ scheme: Schema.Literal<[0, 1, 2]>;
88
+ type: Schema.Literal<[0]>;
89
+ value: typeof Schema.Boolean;
90
+ }>]>;
91
+ export type Plaintext = typeof Plaintext.Type;
92
+ export type PlaintextOf<S extends EncryptionScheme, T extends SupportedFheType> = DistType<Plaintext, S, T>;
93
+ export declare const PlaintextWithContext: Schema.Struct<{
94
+ plaintext: Schema.Union<[Schema.Struct<{
95
+ scheme: Schema.Literal<[0, 1, 2]>;
96
+ type: Schema.Literal<[5, 8]>;
97
+ value: typeof Schema.BigInt;
98
+ }>, Schema.Struct<{
99
+ scheme: Schema.Literal<[0, 1, 2]>;
100
+ type: Schema.Literal<[0]>;
101
+ value: typeof Schema.Boolean;
102
+ }>]>;
103
+ context: Schema.Struct<{
104
+ hostChainId: typeof Schema.BigInt;
105
+ aclAddress: Schema.TemplateLiteral<`0x${string}`>;
106
+ userAddress: Schema.TemplateLiteral<`0x${string}`>;
107
+ contractAddress: Schema.TemplateLiteral<`0x${string}`>;
108
+ }>;
109
+ }>;
110
+ export type PlaintextWithContext = typeof PlaintextWithContext.Type;
111
+ export type PlaintextWithContextOf<S extends EncryptionScheme, T extends SupportedFheType> = PlaintextWithContext & {
112
+ plaintext: PlaintextOf<S, T>;
113
+ };
114
+ export declare function bigintToPlaintext<S extends EncryptionScheme, T extends SupportedFheType>(scheme: S, type: T, bigPt: bigint): PlaintextOf<S, T>;
115
+ export declare function plaintextToBigint(plaintext: Plaintext): bigint;
116
+ export declare function plaintextToBytes32(plaintext: Plaintext): Bytes32;
117
+ export declare function bytes32ToPlaintext(plaintext: Bytes32, scheme: EncryptionScheme, type: SupportedFheType): Plaintext;
118
+ export {};
@@ -0,0 +1 @@
1
+ export * from './encryption';
@@ -0,0 +1,9 @@
1
+ import { Chainish } from '../chain';
2
+ export type Address = `0x${string}`;
3
+ export type FheEnvironment = {
4
+ aclAddress: Address;
5
+ thfeExecutorAddress: Address;
6
+ gatewayAddress: Address;
7
+ kmsVerifierAddress: Address;
8
+ };
9
+ export declare function getFheEnvironment(chainId: Chainish): FheEnvironment;
@@ -0,0 +1,41 @@
1
+ import { Account, Chain, PublicClient, TransactionReceipt, Transport, WalletClient } from 'viem';
2
+ import { SupportedChain } from '../chain';
3
+ export type PublicWalletClient = {
4
+ public: PublicClient<Transport, Chain, Account>;
5
+ wallet: WalletClient<Transport, Chain, Account>;
6
+ };
7
+ export declare function createPublicWalletClient({ account, hostChainRpcUrl, chain, }: {
8
+ account: Account;
9
+ hostChainRpcUrl: string;
10
+ chain: Chain;
11
+ }): PublicWalletClient;
12
+ export declare function getFhevmDeployerClient({ deployer, hostChainRpcUrl, chain, }: {
13
+ deployer: Account;
14
+ hostChainRpcUrl: string;
15
+ chain: SupportedChain;
16
+ }): PublicWalletClient;
17
+ export type PrivateKeys = {
18
+ relayer: string;
19
+ kmsSigner: string;
20
+ deployer: string;
21
+ };
22
+ export type HostChainConfig = {
23
+ privateKeys: PrivateKeys;
24
+ rpcUrl: string;
25
+ };
26
+ export declare function configureFhevmContracts({ chain, hostChain: { privateKeys, rpcUrl }, }: {
27
+ hostChain: HostChainConfig;
28
+ chain: SupportedChain;
29
+ }): Promise<{
30
+ addRelayerTxReceipt: TransactionReceipt | null;
31
+ addKmsSignerTxReceipt: TransactionReceipt | null;
32
+ }>;
33
+ export type L1Config = {
34
+ cometRpcEndpoint: string;
35
+ mnemonic: string;
36
+ grpcEndpoint: string;
37
+ };
38
+ export declare function ensureFheEnvironmentRegistered({ l1, chain, }: {
39
+ l1: L1Config;
40
+ chain: SupportedChain;
41
+ }): Promise<void>;
@@ -0,0 +1,87 @@
1
+ var __create = Object.create;
2
+ var __getProtoOf = Object.getPrototypeOf;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __toESM = (mod, isNodeMode, target) => {
8
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
9
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
+ for (let key of __getOwnPropNames(mod))
11
+ if (!__hasOwnProp.call(to, key))
12
+ __defProp(to, key, {
13
+ get: () => mod[key],
14
+ enumerable: true
15
+ });
16
+ return to;
17
+ };
18
+ var __moduleCache = /* @__PURE__ */ new WeakMap;
19
+ var __toCommonJS = (from) => {
20
+ var entry = __moduleCache.get(from), desc;
21
+ if (entry)
22
+ return entry;
23
+ entry = __defProp({}, "__esModule", { value: true });
24
+ if (from && typeof from === "object" || typeof from === "function")
25
+ __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
26
+ get: () => from[key],
27
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
28
+ }));
29
+ __moduleCache.set(from, entry);
30
+ return entry;
31
+ };
32
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
33
+ var __export = (target, all) => {
34
+ for (var name in all)
35
+ __defProp(target, name, {
36
+ get: all[name],
37
+ enumerable: true,
38
+ configurable: true,
39
+ set: (newValue) => all[name] = () => newValue
40
+ });
41
+ };
42
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
43
+
44
+ // src/fhevm/index.ts
45
+ var exports_fhevm = {};
46
+ __export(exports_fhevm, {
47
+ getFheEnvironment: () => getFheEnvironment
48
+ });
49
+ module.exports = __toCommonJS(exports_fhevm);
50
+
51
+ // src/chain.ts
52
+ var supportedChains = {
53
+ baseSepolia: 84532,
54
+ sepolia: 11155111,
55
+ monadTestnet: 10143
56
+ };
57
+ var fheSupportedChains = { baseSepolia: 84532, sepolia: 11155111 };
58
+ function getSupportedChain(chainish) {
59
+ const found = typeof chainish === "number" || typeof chainish === "bigint" ? Object.entries(supportedChains).find(([, id2]) => id2 === Number(chainish)) : typeof chainish === "object" ? Object.entries(supportedChains).find(([, id2]) => id2 === Number(chainish.id)) : Object.entries(supportedChains).find(([shortName]) => shortName === chainish);
60
+ if (!found) {
61
+ throw new Error(`Supported chain ${JSON.stringify(chainish)} not found`);
62
+ }
63
+ const [name, id] = found;
64
+ return { name, id };
65
+ }
66
+
67
+ // src/generated/fhe-environments.ts
68
+ var FHEEnvironments = {
69
+ baseSepolia: {
70
+ aclAddress: "0xdc8da2854e5275180b9cccb31e498fd5f9ef2b88",
71
+ thfeExecutorAddress: "0x79602c1771081338a0521faf5234037ee41032e5",
72
+ gatewayAddress: "0x28d8d247116c8546d3fe00623c04236b2e35e012",
73
+ kmsVerifierAddress: "0xc3fb9779fbdfa6948429b492111fce4905e6378e"
74
+ },
75
+ sepolia: {
76
+ aclAddress: "0x0e2123e6e99b4bc2eb54b63d2d8edca0566ba49b",
77
+ thfeExecutorAddress: "0xa3e0a77cd87c46ac868138623255011555885c09",
78
+ gatewayAddress: "0x141dbff036daf7ba1ed9c2f04b9096101436100a",
79
+ kmsVerifierAddress: "0x723c2be5e61e7bbec4684defeae63656ad3eaa10"
80
+ }
81
+ };
82
+
83
+ // src/fhevm/fhe-environment.ts
84
+ function getFheEnvironment(chainId) {
85
+ const supportedChain = getSupportedChain(chainId);
86
+ return FHEEnvironments[supportedChain.name];
87
+ }
@@ -0,0 +1 @@
1
+ export * from './fhe-environment';
@@ -0,0 +1,83 @@
1
+ var __create = Object.create;
2
+ var __getProtoOf = Object.getPrototypeOf;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __toESM = (mod, isNodeMode, target) => {
8
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
9
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
+ for (let key of __getOwnPropNames(mod))
11
+ if (!__hasOwnProp.call(to, key))
12
+ __defProp(to, key, {
13
+ get: () => mod[key],
14
+ enumerable: true
15
+ });
16
+ return to;
17
+ };
18
+ var __moduleCache = /* @__PURE__ */ new WeakMap;
19
+ var __toCommonJS = (from) => {
20
+ var entry = __moduleCache.get(from), desc;
21
+ if (entry)
22
+ return entry;
23
+ entry = __defProp({}, "__esModule", { value: true });
24
+ if (from && typeof from === "object" || typeof from === "function")
25
+ __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
26
+ get: () => from[key],
27
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
28
+ }));
29
+ __moduleCache.set(from, entry);
30
+ return entry;
31
+ };
32
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
33
+ var __export = (target, all) => {
34
+ for (var name in all)
35
+ __defProp(target, name, {
36
+ get: all[name],
37
+ enumerable: true,
38
+ configurable: true,
39
+ set: (newValue) => all[name] = () => newValue
40
+ });
41
+ };
42
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
43
+
44
+ // src/chain.ts
45
+ var supportedChains = {
46
+ baseSepolia: 84532,
47
+ sepolia: 11155111,
48
+ monadTestnet: 10143
49
+ };
50
+ var fheSupportedChains = { baseSepolia: 84532, sepolia: 11155111 };
51
+ function getSupportedChain(chainish) {
52
+ const found = typeof chainish === "number" || typeof chainish === "bigint" ? Object.entries(supportedChains).find(([, id2]) => id2 === Number(chainish)) : typeof chainish === "object" ? Object.entries(supportedChains).find(([, id2]) => id2 === Number(chainish.id)) : Object.entries(supportedChains).find(([shortName]) => shortName === chainish);
53
+ if (!found) {
54
+ throw new Error(`Supported chain ${JSON.stringify(chainish)} not found`);
55
+ }
56
+ const [name, id] = found;
57
+ return { name, id };
58
+ }
59
+
60
+ // src/generated/fhe-environments.ts
61
+ var FHEEnvironments = {
62
+ baseSepolia: {
63
+ aclAddress: "0xdc8da2854e5275180b9cccb31e498fd5f9ef2b88",
64
+ thfeExecutorAddress: "0x79602c1771081338a0521faf5234037ee41032e5",
65
+ gatewayAddress: "0x28d8d247116c8546d3fe00623c04236b2e35e012",
66
+ kmsVerifierAddress: "0xc3fb9779fbdfa6948429b492111fce4905e6378e"
67
+ },
68
+ sepolia: {
69
+ aclAddress: "0x0e2123e6e99b4bc2eb54b63d2d8edca0566ba49b",
70
+ thfeExecutorAddress: "0xa3e0a77cd87c46ac868138623255011555885c09",
71
+ gatewayAddress: "0x141dbff036daf7ba1ed9c2f04b9096101436100a",
72
+ kmsVerifierAddress: "0x723c2be5e61e7bbec4684defeae63656ad3eaa10"
73
+ }
74
+ };
75
+
76
+ // src/fhevm/fhe-environment.ts
77
+ function getFheEnvironment(chainId) {
78
+ const supportedChain = getSupportedChain(chainId);
79
+ return FHEEnvironments[supportedChain.name];
80
+ }
81
+ export {
82
+ getFheEnvironment
83
+ };
@@ -0,0 +1,20 @@
1
+ import { Account, Address, Chain, Transport, WalletClient } from 'viem';
2
+ import { CryptoboxScheme } from '../encryption/encryption';
3
+ import type { Reencryptor, ReencryptorArgs } from '../reencryption';
4
+ import type { PubKeyEncodable } from '../reencryption/types';
5
+ export interface EphemeralCryptoBoxKeypair extends PubKeyEncodable {
6
+ scheme: CryptoboxScheme;
7
+ publicKey: Uint8Array;
8
+ privateKey: Uint8Array;
9
+ }
10
+ export interface ZamaReencryptorArgs extends ReencryptorArgs {
11
+ gatewayUrl: string;
12
+ unsafeSkipVerifyKMSSignatures?: boolean;
13
+ walletClient: WalletClient<Transport, Chain, Account>;
14
+ contractAddress: Address;
15
+ chainId: bigint;
16
+ kmsSigners: Address[];
17
+ userAddress: Address;
18
+ }
19
+ export declare function zamaReencryptor({ chainId, gatewayUrl, walletClient, unsafeSkipVerifyKMSSignatures, contractAddress, kmsSigners, userAddress, }: ZamaReencryptorArgs): Promise<Reencryptor<CryptoboxScheme>>;
20
+ export declare function generateCryptoBoxEphemeralKeyPair(): EphemeralCryptoBoxKeypair;