@fhevm/sdk 1.0.0-alpha.3 → 1.0.0-alpha.5

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 (288) hide show
  1. package/_cjs/core/_version.js +1 -1
  2. package/_cjs/core/actions/base/fetchEncryptedValues.js +18 -0
  3. package/_cjs/core/actions/base/fetchEncryptedValues.js.map +1 -0
  4. package/_cjs/core/actions/base/index.js +3 -1
  5. package/_cjs/core/actions/base/index.js.map +1 -1
  6. package/_cjs/core/actions/chain/createKmsDelegatedUserDecryptEip712.js.map +1 -1
  7. package/_cjs/core/actions/chain/createKmsUserDecryptEip712.js.map +1 -1
  8. package/_cjs/core/actions/chain/index.js +5 -5
  9. package/_cjs/core/actions/chain/parseSignedDecryptionPermit.js +2 -2
  10. package/_cjs/core/actions/chain/parseSignedDecryptionPermit.js.map +1 -1
  11. package/_cjs/core/actions/chain/parseTransportKeyPair.js +8 -0
  12. package/_cjs/core/actions/chain/parseTransportKeyPair.js.map +1 -0
  13. package/_cjs/core/actions/chain/serializeTransportKeyPair.js +8 -0
  14. package/_cjs/core/actions/chain/serializeTransportKeyPair.js.map +1 -0
  15. package/_cjs/core/actions/decrypt/generateTransportKeyPair.js +8 -0
  16. package/_cjs/core/actions/decrypt/generateTransportKeyPair.js.map +1 -0
  17. package/_cjs/core/actions/decrypt/index.js +3 -3
  18. package/_cjs/core/actions/decrypt/index.js.map +1 -1
  19. package/_cjs/core/actions/encrypt/generateZkProof.js.map +1 -1
  20. package/_cjs/core/base/address.js.map +1 -1
  21. package/_cjs/core/base/fetch.js +2 -2
  22. package/_cjs/core/base/fetch.js.map +1 -1
  23. package/_cjs/core/base/index.js +0 -5
  24. package/_cjs/core/base/index.js.map +1 -1
  25. package/_cjs/core/base/sign.js +12 -6
  26. package/_cjs/core/base/sign.js.map +1 -1
  27. package/_cjs/core/base/typedValue.js +20 -6
  28. package/_cjs/core/base/typedValue.js.map +1 -1
  29. package/_cjs/core/base/uint.js +23 -0
  30. package/_cjs/core/base/uint.js.map +1 -1
  31. package/_cjs/core/base/wasm.js +1 -1
  32. package/_cjs/core/base/wasm.js.map +1 -1
  33. package/_cjs/core/clients/decorators/base.js +4 -4
  34. package/_cjs/core/clients/decorators/decrypt.js +2 -2
  35. package/_cjs/core/coprocessor/ZkProof-p.js +2 -1
  36. package/_cjs/core/coprocessor/ZkProof-p.js.map +1 -1
  37. package/_cjs/core/handle/EncryptedValue.js +0 -4
  38. package/_cjs/core/handle/EncryptedValue.js.map +1 -1
  39. package/_cjs/core/handle/FheType.js.map +1 -1
  40. package/_cjs/core/host-contracts/canDecryptValuesFromPairs.js +3 -3
  41. package/_cjs/core/host-contracts/checkDelegation.js +13 -0
  42. package/_cjs/core/host-contracts/checkDelegation.js.map +1 -1
  43. package/_cjs/core/host-contracts/constants.js +5 -0
  44. package/_cjs/core/host-contracts/constants.js.map +1 -0
  45. package/_cjs/core/kms/SignedDecryptionPermit-p.js +9 -9
  46. package/_cjs/core/kms/SignedDecryptionPermit-p.js.map +1 -1
  47. package/_cjs/core/kms/{TransportKeypair-p.js → TransportKeyPair-p.js} +48 -48
  48. package/_cjs/core/kms/{TransportKeypair-p.js.map → TransportKeyPair-p.js.map} +1 -1
  49. package/_cjs/core/kms/decryptKmsSignedcryptedShares-p.js +3 -3
  50. package/_cjs/core/kms/decryptKmsSignedcryptedShares-p.js.map +1 -1
  51. package/_cjs/core/kms/decryptValuesFromPairs.js +2 -2
  52. package/_cjs/core/kms/decryptValuesFromPairs.js.map +1 -1
  53. package/_cjs/core/kms/index.js +0 -1
  54. package/_cjs/core/modules/decrypt/mock.js.map +1 -1
  55. package/_cjs/core/modules/decrypt/module/init-p.js +3 -7
  56. package/_cjs/core/modules/decrypt/module/init-p.js.map +1 -1
  57. package/_cjs/core/modules/encrypt/mock.js.map +1 -1
  58. package/_cjs/core/modules/encrypt/module/api-p.js.map +1 -1
  59. package/_cjs/core/modules/encrypt/module/index.js.map +1 -1
  60. package/_cjs/core/modules/encrypt/module/init-p.js +18 -13
  61. package/_cjs/core/modules/encrypt/module/init-p.js.map +1 -1
  62. package/_cjs/core/modules/relayer/module/fetchPublicDecrypt.js.map +1 -1
  63. package/_cjs/core/modules/relayer/module/fetchUserDecrypt.js.map +1 -1
  64. package/_cjs/core/modules/relayer/module/guards/RelayerErrorBody.js +27 -0
  65. package/_cjs/core/modules/relayer/module/guards/RelayerErrorBody.js.map +1 -0
  66. package/_cjs/core/types/index.js +4 -0
  67. package/_cjs/core/types/index.js.map +1 -1
  68. package/_cjs/core/utils-p/decrypt/assertPermitMatchesKeyPair.js +14 -0
  69. package/_cjs/core/utils-p/decrypt/{assertPermitMatchesKeypair.js.map → assertPermitMatchesKeyPair.js.map} +1 -1
  70. package/_cjs/core/utils-p/decrypt/verifyTkmsPublicKey.js +1 -1
  71. package/_esm/core/_version.js +1 -1
  72. package/_esm/core/actions/base/fetchEncryptedValues.js +16 -0
  73. package/_esm/core/actions/base/fetchEncryptedValues.js.map +1 -0
  74. package/_esm/core/actions/base/index.js +1 -0
  75. package/_esm/core/actions/base/index.js.map +1 -1
  76. package/_esm/core/actions/chain/createKmsDelegatedUserDecryptEip712.js.map +1 -1
  77. package/_esm/core/actions/chain/createKmsUserDecryptEip712.js.map +1 -1
  78. package/_esm/core/actions/chain/index.js +2 -2
  79. package/_esm/core/actions/chain/parseSignedDecryptionPermit.js +3 -3
  80. package/_esm/core/actions/chain/parseSignedDecryptionPermit.js.map +1 -1
  81. package/_esm/core/actions/chain/parseTransportKeyPair.js +5 -0
  82. package/_esm/core/actions/chain/parseTransportKeyPair.js.map +1 -0
  83. package/_esm/core/actions/chain/serializeTransportKeyPair.js +5 -0
  84. package/_esm/core/actions/chain/{serializeTransportKeypair.js.map → serializeTransportKeyPair.js.map} +1 -1
  85. package/_esm/core/actions/decrypt/generateTransportKeyPair.js +6 -0
  86. package/_esm/core/actions/decrypt/{generateTransportKeypair.js.map → generateTransportKeyPair.js.map} +1 -1
  87. package/_esm/core/actions/decrypt/index.js +3 -1
  88. package/_esm/core/actions/decrypt/index.js.map +1 -1
  89. package/_esm/core/actions/encrypt/generateZkProof.js.map +1 -1
  90. package/_esm/core/base/address.js.map +1 -1
  91. package/_esm/core/base/fetch.js +2 -2
  92. package/_esm/core/base/fetch.js.map +1 -1
  93. package/_esm/core/base/index.js +1 -1
  94. package/_esm/core/base/index.js.map +1 -1
  95. package/_esm/core/base/sign.js +15 -8
  96. package/_esm/core/base/sign.js.map +1 -1
  97. package/_esm/core/base/typedValue.js +24 -7
  98. package/_esm/core/base/typedValue.js.map +1 -1
  99. package/_esm/core/base/uint.js +21 -0
  100. package/_esm/core/base/uint.js.map +1 -1
  101. package/_esm/core/base/wasm.js +1 -1
  102. package/_esm/core/base/wasm.js.map +1 -1
  103. package/_esm/core/clients/decorators/base.js +4 -4
  104. package/_esm/core/clients/decorators/decrypt.js +2 -2
  105. package/_esm/core/coprocessor/ZkProof-p.js +3 -2
  106. package/_esm/core/coprocessor/ZkProof-p.js.map +1 -1
  107. package/_esm/core/handle/EncryptedValue.js +0 -3
  108. package/_esm/core/handle/EncryptedValue.js.map +1 -1
  109. package/_esm/core/handle/FheType.js +10 -17
  110. package/_esm/core/handle/FheType.js.map +1 -1
  111. package/_esm/core/host-contracts/canDecryptValuesFromPairs.js +3 -3
  112. package/_esm/core/host-contracts/checkDelegation.js +19 -5
  113. package/_esm/core/host-contracts/checkDelegation.js.map +1 -1
  114. package/_esm/core/host-contracts/constants.js +2 -0
  115. package/_esm/core/host-contracts/constants.js.map +1 -0
  116. package/_esm/core/kms/SignedDecryptionPermit-p.js +9 -9
  117. package/_esm/core/kms/SignedDecryptionPermit-p.js.map +1 -1
  118. package/_esm/core/kms/{TransportKeypair-p.js → TransportKeyPair-p.js} +55 -55
  119. package/_esm/core/kms/{TransportKeypair-p.js.map → TransportKeyPair-p.js.map} +1 -1
  120. package/_esm/core/kms/decryptKmsSignedcryptedShares-p.js +4 -4
  121. package/_esm/core/kms/decryptKmsSignedcryptedShares-p.js.map +1 -1
  122. package/_esm/core/kms/decryptValuesFromPairs.js +2 -2
  123. package/_esm/core/kms/decryptValuesFromPairs.js.map +1 -1
  124. package/_esm/core/modules/decrypt/mock.js.map +1 -1
  125. package/_esm/core/modules/decrypt/module/init-p.js +13 -11
  126. package/_esm/core/modules/decrypt/module/init-p.js.map +1 -1
  127. package/_esm/core/modules/encrypt/mock.js.map +1 -1
  128. package/_esm/core/modules/encrypt/module/api-p.js.map +1 -1
  129. package/_esm/core/modules/encrypt/module/index.js.map +1 -1
  130. package/_esm/core/modules/encrypt/module/init-p.js +34 -17
  131. package/_esm/core/modules/encrypt/module/init-p.js.map +1 -1
  132. package/_esm/core/modules/relayer/module/fetchPublicDecrypt.js.map +1 -1
  133. package/_esm/core/modules/relayer/module/fetchUserDecrypt.js.map +1 -1
  134. package/_esm/core/modules/relayer/module/guards/RelayerErrorBody.js +24 -0
  135. package/_esm/core/modules/relayer/module/guards/RelayerErrorBody.js.map +1 -0
  136. package/_esm/core/types/index.js +1 -1
  137. package/_esm/core/types/index.js.map +1 -1
  138. package/_esm/core/utils-p/decrypt/assertPermitMatchesKeyPair.js +19 -0
  139. package/_esm/core/utils-p/decrypt/{assertPermitMatchesKeypair.js.map → assertPermitMatchesKeyPair.js.map} +1 -1
  140. package/_esm/core/utils-p/decrypt/verifyTkmsPublicKey.js +1 -1
  141. package/_types/core/actions/base/fetchEncryptedValues.d.ts +16 -0
  142. package/_types/core/actions/base/fetchEncryptedValues.d.ts.map +1 -0
  143. package/_types/core/actions/base/index.d.ts +1 -0
  144. package/_types/core/actions/base/index.d.ts.map +1 -1
  145. package/_types/core/actions/chain/createKmsDelegatedUserDecryptEip712.d.ts.map +1 -1
  146. package/_types/core/actions/chain/createKmsUserDecryptEip712.d.ts.map +1 -1
  147. package/_types/core/actions/chain/index.d.ts +2 -2
  148. package/_types/core/actions/chain/parseSignedDecryptionPermit.d.ts +4 -4
  149. package/_types/core/actions/chain/parseSignedDecryptionPermit.d.ts.map +1 -1
  150. package/_types/core/actions/chain/{parseTransportKeypair.d.ts → parseTransportKeyPair.d.ts} +5 -5
  151. package/_types/core/actions/chain/{parseTransportKeypair.d.ts.map → parseTransportKeyPair.d.ts.map} +1 -1
  152. package/_types/core/actions/chain/{serializeTransportKeypair.d.ts → serializeTransportKeyPair.d.ts} +6 -6
  153. package/_types/core/actions/chain/{serializeTransportKeypair.d.ts.map → serializeTransportKeyPair.d.ts.map} +1 -1
  154. package/_types/core/actions/decrypt/canDecryptValue.d.ts +4 -4
  155. package/_types/core/actions/decrypt/canDecryptValues.d.ts +2 -2
  156. package/_types/core/actions/decrypt/canDecryptValuesFromPairs.d.ts +2 -2
  157. package/_types/core/actions/decrypt/decryptKmsSignedcryptedShares.d.ts +2 -2
  158. package/_types/core/actions/decrypt/decryptValue.d.ts +2 -2
  159. package/_types/core/actions/decrypt/decryptValues.d.ts +2 -2
  160. package/_types/core/actions/decrypt/decryptValuesFromPairs.d.ts +2 -2
  161. package/_types/core/actions/decrypt/{generateTransportKeypair.d.ts → generateTransportKeyPair.d.ts} +4 -4
  162. package/_types/core/actions/decrypt/{generateTransportKeypair.d.ts.map → generateTransportKeyPair.d.ts.map} +1 -1
  163. package/_types/core/actions/decrypt/index.d.ts +3 -1
  164. package/_types/core/actions/decrypt/index.d.ts.map +1 -1
  165. package/_types/core/actions/encrypt/encryptValue.d.ts +5 -2
  166. package/_types/core/actions/encrypt/encryptValue.d.ts.map +1 -1
  167. package/_types/core/actions/encrypt/encryptValues.d.ts +5 -2
  168. package/_types/core/actions/encrypt/encryptValues.d.ts.map +1 -1
  169. package/_types/core/actions/encrypt/generateZkProof.d.ts +4 -2
  170. package/_types/core/actions/encrypt/generateZkProof.d.ts.map +1 -1
  171. package/_types/core/base/address.d.ts.map +1 -1
  172. package/_types/core/base/errors/InvalidTypeError.d.ts +1 -1
  173. package/_types/core/base/errors/InvalidTypeError.d.ts.map +1 -1
  174. package/_types/core/base/index.d.ts +1 -1
  175. package/_types/core/base/index.d.ts.map +1 -1
  176. package/_types/core/base/sign.d.ts.map +1 -1
  177. package/_types/core/base/typedValue.d.ts +3 -13
  178. package/_types/core/base/typedValue.d.ts.map +1 -1
  179. package/_types/core/base/uint.d.ts +4 -0
  180. package/_types/core/base/uint.d.ts.map +1 -1
  181. package/_types/core/clients/decorators/base.d.ts +6 -6
  182. package/_types/core/clients/decorators/base.d.ts.map +1 -1
  183. package/_types/core/clients/decorators/decrypt.d.ts +2 -2
  184. package/_types/core/coprocessor/ZkProof-p.d.ts +2 -1
  185. package/_types/core/coprocessor/ZkProof-p.d.ts.map +1 -1
  186. package/_types/core/handle/EncryptedValue.d.ts +0 -1
  187. package/_types/core/handle/EncryptedValue.d.ts.map +1 -1
  188. package/_types/core/handle/FheType.d.ts +10 -17
  189. package/_types/core/handle/FheType.d.ts.map +1 -1
  190. package/_types/core/host-contracts/canDecryptValuesFromPairs.d.ts +2 -2
  191. package/_types/core/host-contracts/checkDelegation.d.ts.map +1 -1
  192. package/_types/core/host-contracts/constants.d.ts +3 -0
  193. package/_types/core/host-contracts/constants.d.ts.map +1 -0
  194. package/_types/core/kms/SignedDecryptionPermit-p.d.ts +6 -6
  195. package/_types/core/kms/{TransportKeypair-p.d.ts → TransportKeyPair-p.d.ts} +23 -23
  196. package/_types/core/kms/{TransportKeypair-p.d.ts.map → TransportKeyPair-p.d.ts.map} +1 -1
  197. package/_types/core/kms/decryptKmsSignedcryptedShares-p.d.ts +2 -2
  198. package/_types/core/kms/decryptValuesFromPairs.d.ts +3 -3
  199. package/_types/core/kms/index.d.ts +1 -1
  200. package/_types/core/kms/index.d.ts.map +1 -1
  201. package/_types/core/modules/decrypt/module/init-p.d.ts.map +1 -1
  202. package/_types/core/modules/encrypt/mock.d.ts +2 -2
  203. package/_types/core/modules/encrypt/mock.d.ts.map +1 -1
  204. package/_types/core/modules/encrypt/module/api-p.d.ts +2 -2
  205. package/_types/core/modules/encrypt/module/api-p.d.ts.map +1 -1
  206. package/_types/core/modules/encrypt/module/init-p.d.ts.map +1 -1
  207. package/_types/core/modules/encrypt/types.d.ts +2 -2
  208. package/_types/core/modules/encrypt/types.d.ts.map +1 -1
  209. package/_types/core/modules/relayer/module/fetchUserDecrypt.d.ts.map +1 -1
  210. package/_types/core/modules/relayer/module/guards/RelayerErrorBody.d.ts +13 -0
  211. package/_types/core/modules/relayer/module/guards/RelayerErrorBody.d.ts.map +1 -0
  212. package/_types/core/types/index.d.ts +2 -0
  213. package/_types/core/types/index.d.ts.map +1 -1
  214. package/_types/core/types/primitives.d.ts +4 -0
  215. package/_types/core/types/primitives.d.ts.map +1 -1
  216. package/_types/core/utils-p/decrypt/assertPermitMatchesKeyPair.d.ts +12 -0
  217. package/_types/core/utils-p/decrypt/{assertPermitMatchesKeypair.d.ts.map → assertPermitMatchesKeyPair.d.ts.map} +1 -1
  218. package/core/_version.ts +1 -1
  219. package/core/actions/base/fetchEncryptedValues.ts +42 -0
  220. package/core/actions/base/index.ts +6 -0
  221. package/core/actions/chain/createKmsDelegatedUserDecryptEip712.ts +1 -2
  222. package/core/actions/chain/createKmsUserDecryptEip712.ts +1 -2
  223. package/core/actions/chain/index.ts +8 -8
  224. package/core/actions/chain/parseSignedDecryptionPermit.ts +6 -6
  225. package/core/actions/chain/{parseTransportKeypair.ts → parseTransportKeyPair.ts} +7 -7
  226. package/core/actions/chain/{serializeTransportKeypair.ts → serializeTransportKeyPair.ts} +10 -10
  227. package/core/actions/decrypt/canDecryptValue.ts +4 -4
  228. package/core/actions/decrypt/canDecryptValues.ts +2 -2
  229. package/core/actions/decrypt/canDecryptValuesFromPairs.ts +2 -2
  230. package/core/actions/decrypt/decryptKmsSignedcryptedShares.ts +2 -2
  231. package/core/actions/decrypt/decryptValue.ts +2 -2
  232. package/core/actions/decrypt/decryptValues.ts +2 -2
  233. package/core/actions/decrypt/decryptValuesFromPairs.ts +2 -2
  234. package/core/actions/decrypt/{generateTransportKeypair.ts → generateTransportKeyPair.ts} +7 -7
  235. package/core/actions/decrypt/index.ts +8 -4
  236. package/core/actions/encrypt/encryptValue.ts +2 -2
  237. package/core/actions/encrypt/encryptValues.ts +2 -2
  238. package/core/actions/encrypt/generateZkProof.ts +1 -2
  239. package/core/base/address.ts +2 -2
  240. package/core/base/errors/InvalidTypeError.ts +1 -1
  241. package/core/base/fetch.ts +2 -2
  242. package/core/base/index.ts +0 -1
  243. package/core/base/sign.ts +16 -8
  244. package/core/base/typedValue.ts +32 -25
  245. package/core/base/uint.ts +30 -0
  246. package/core/base/wasm.ts +1 -1
  247. package/core/clients/decorators/base.ts +18 -18
  248. package/core/clients/decorators/decrypt.ts +4 -4
  249. package/core/coprocessor/ZkProof-p.ts +6 -6
  250. package/core/handle/EncryptedValue.ts +0 -4
  251. package/core/handle/FheType.ts +10 -17
  252. package/core/host-contracts/canDecryptValuesFromPairs.ts +5 -5
  253. package/core/host-contracts/checkDelegation.ts +20 -5
  254. package/core/host-contracts/constants.ts +3 -0
  255. package/core/kms/SignedDecryptionPermit-p.ts +13 -13
  256. package/core/kms/{TransportKeypair-p.ts → TransportKeyPair-p.ts} +42 -42
  257. package/core/kms/decryptKmsSignedcryptedShares-p.ts +6 -6
  258. package/core/kms/decryptValuesFromPairs.ts +5 -5
  259. package/core/kms/index.ts +0 -1
  260. package/core/modules/decrypt/mock.ts +3 -3
  261. package/core/modules/decrypt/module/init-p.ts +13 -14
  262. package/core/modules/encrypt/mock.ts +4 -6
  263. package/core/modules/encrypt/module/api-p.ts +4 -6
  264. package/core/modules/encrypt/module/index.ts +2 -2
  265. package/core/modules/encrypt/module/init-p.ts +37 -21
  266. package/core/modules/encrypt/types.ts +2 -2
  267. package/core/modules/relayer/module/fetchPublicDecrypt.ts +2 -2
  268. package/core/modules/relayer/module/fetchUserDecrypt.ts +1 -2
  269. package/core/modules/relayer/module/guards/RelayerErrorBody.ts +33 -0
  270. package/core/types/index.ts +2 -0
  271. package/core/types/primitives.ts +4 -0
  272. package/core/utils-p/decrypt/{assertPermitMatchesKeypair.ts → assertPermitMatchesKeyPair.ts} +9 -9
  273. package/core/utils-p/decrypt/verifyTkmsPublicKey.ts +1 -1
  274. package/package.json +3 -2
  275. package/_cjs/core/actions/chain/parseTransportKeypair.js +0 -8
  276. package/_cjs/core/actions/chain/parseTransportKeypair.js.map +0 -1
  277. package/_cjs/core/actions/chain/serializeTransportKeypair.js +0 -8
  278. package/_cjs/core/actions/chain/serializeTransportKeypair.js.map +0 -1
  279. package/_cjs/core/actions/decrypt/generateTransportKeypair.js +0 -8
  280. package/_cjs/core/actions/decrypt/generateTransportKeypair.js.map +0 -1
  281. package/_cjs/core/utils-p/decrypt/assertPermitMatchesKeypair.js +0 -14
  282. package/_esm/core/actions/chain/parseTransportKeypair.js +0 -5
  283. package/_esm/core/actions/chain/parseTransportKeypair.js.map +0 -1
  284. package/_esm/core/actions/chain/serializeTransportKeypair.js +0 -5
  285. package/_esm/core/actions/decrypt/generateTransportKeypair.js +0 -6
  286. package/_esm/core/utils-p/decrypt/assertPermitMatchesKeypair.js +0 -19
  287. package/_types/core/utils-p/decrypt/assertPermitMatchesKeypair.d.ts +0 -12
  288. package/tsconfig.json +0 -9
@@ -1,6 +1,6 @@
1
1
  import type { FhevmChain } from '../types/fhevmChain.js';
2
2
  import type { SignedDelegatedDecryptionPermit, SignedSelfDecryptionPermit } from '../types/signedDecryptionPermit.js';
3
- import type { TransportKeypair } from '../kms/TransportKeypair-p.js';
3
+ import type { TransportKeyPair } from '../kms/TransportKeyPair-p.js';
4
4
  import type { ChecksummedAddress, Uint64BigInt } from '../types/primitives.js';
5
5
  import type { FhevmRuntime } from '../types/coreFhevmRuntime.js';
6
6
  import type { Handle } from '../types/encryptedTypes-p.js';
@@ -10,7 +10,7 @@ import {
10
10
  assertIsSignedDecryptionPermit,
11
11
  assertPermitIncludesContractAddresses,
12
12
  } from '../kms/SignedDecryptionPermit-p.js';
13
- import { assertPermitMatchesKeypair } from '../utils-p/decrypt/assertPermitMatchesKeypair.js';
13
+ import { assertPermitMatchesKeyPair } from '../utils-p/decrypt/assertPermitMatchesKeyPair.js';
14
14
  import { isUserDecryptable } from '../host-contracts/isUserDecryptable.js';
15
15
 
16
16
  ////////////////////////////////////////////////////////////////////////////////
@@ -30,7 +30,7 @@ type Parameters =
30
30
  | {
31
31
  readonly pairs: ReadonlyArray<{ readonly handle: Handle; readonly contractAddress: ChecksummedAddress }>;
32
32
  readonly signedPermit: SignedSelfDecryptionPermit | SignedDelegatedDecryptionPermit;
33
- readonly transportKeypair?: TransportKeypair | undefined;
33
+ readonly transportKeyPair?: TransportKeyPair | undefined;
34
34
  };
35
35
 
36
36
  type ReturnType = {
@@ -66,8 +66,8 @@ export async function canDecryptValuesFromPairs(context: Context, parameters: Pa
66
66
  signedPermit.assertNotExpired();
67
67
  assertPermitIncludesContractAddresses(signedPermit, contractAddresses);
68
68
 
69
- if (parameters.transportKeypair !== undefined) {
70
- assertPermitMatchesKeypair(signedPermit, parameters.transportKeypair);
69
+ if (parameters.transportKeyPair !== undefined) {
70
+ assertPermitMatchesKeyPair(signedPermit, parameters.transportKeyPair);
71
71
  }
72
72
 
73
73
  userAddress = signedPermit.encryptedDataOwnerAddress;
@@ -4,6 +4,7 @@ import type { ChecksummedAddress } from '../types/primitives.js';
4
4
  import type { HandleContractPair } from '../types/other-p.js';
5
5
  import { AclUserDecryptionError } from '../errors/AclError.js';
6
6
  import { isHandleDelegatedForUserDecryption } from './isHandleDelegatedForUserDecryption-p.js';
7
+ import { WILDCARD_DELEGATION_ADDRESS } from './constants.js';
7
8
 
8
9
  ////////////////////////////////////////////////////////////////////////////////
9
10
 
@@ -45,7 +46,21 @@ export async function checkDelegation(context: Context, parameters: Parameters):
45
46
  });
46
47
  }
47
48
 
48
- // 2. Verify rules: delegator !== contractAddress & delegate !== contractAddress
49
+ // 2. Verify rule: delegate !== WILDCARD_CONTRACT
50
+ if (delegate.toLowerCase() === WILDCARD_DELEGATION_ADDRESS.toLowerCase()) {
51
+ throw new AclUserDecryptionError({
52
+ contractAddress: address,
53
+ message: `delegate cannot be equal to wildcard contract address`,
54
+ });
55
+ }
56
+ if (delegator.toLowerCase() === WILDCARD_DELEGATION_ADDRESS.toLowerCase()) {
57
+ throw new AclUserDecryptionError({
58
+ contractAddress: address,
59
+ message: `delegator cannot be equal to wildcard contract address`,
60
+ });
61
+ }
62
+
63
+ // 3. Verify rules: delegator !== contractAddress & delegate !== contractAddress
49
64
  for (const pair of handleContractPairs) {
50
65
  if (delegator.toLowerCase() === pair.contractAddress.toLowerCase()) {
51
66
  throw new AclUserDecryptionError({
@@ -61,7 +76,7 @@ export async function checkDelegation(context: Context, parameters: Parameters):
61
76
  }
62
77
  }
63
78
 
64
- // 3. Collect all unique (contractAddress, handle) pairs to avoid duplicate RPC calls
79
+ // 4. Collect all unique (contractAddress, handle) pairs to avoid duplicate RPC calls
65
80
  const allChecks: HandleContractPair[] = [];
66
81
  const seenKeys = new Set<string>();
67
82
 
@@ -81,7 +96,7 @@ export async function checkDelegation(context: Context, parameters: Parameters):
81
96
  throw new Error('checkDelegation: no delegation checks to perform (unexpected empty dedup result)');
82
97
  }
83
98
 
84
- // 4. Single batched RPC call for all unique checks
99
+ // 5. Single batched RPC call for all unique checks
85
100
  const allResults = await isHandleDelegatedForUserDecryption(context, {
86
101
  address,
87
102
  delegator,
@@ -89,7 +104,7 @@ export async function checkDelegation(context: Context, parameters: Parameters):
89
104
  pairs: allChecks,
90
105
  });
91
106
 
92
- // 5. Build result map for lookup
107
+ // 6. Build result map for lookup
93
108
  const resultMap = new Map<string, boolean>();
94
109
  for (const [i, check] of allChecks.entries()) {
95
110
  const result = allResults[i];
@@ -101,7 +116,7 @@ export async function checkDelegation(context: Context, parameters: Parameters):
101
116
  resultMap.set(key, result);
102
117
  }
103
118
 
104
- // 6. Verify delegation for each requested pair
119
+ // 7. Verify delegation for each requested pair
105
120
  for (const pair of handleContractPairs) {
106
121
  const key = getKey(pair.contractAddress, pair.handle.bytes32Hex);
107
122
  if (resultMap.get(key) !== true) {
@@ -0,0 +1,3 @@
1
+ import type { ChecksummedAddress } from '../types/primitives.js';
2
+
3
+ export const WILDCARD_DELEGATION_ADDRESS = '0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF' as ChecksummedAddress;
@@ -29,7 +29,7 @@ import {
29
29
  createKmsDelegatedUserDecryptEip712,
30
30
  } from './createKmsDelegatedUserDecryptEip712.js';
31
31
  import { assertRecordStringProperty } from '../base/string.js';
32
- import { assertIsTransportKeypair, type TransportKeypair } from './TransportKeypair-p.js';
32
+ import { assertIsTransportKeyPair, type TransportKeyPair } from './TransportKeyPair-p.js';
33
33
  import { assertKmsEIP712DeadlineValidity } from './utils.js';
34
34
  import { readKmsSignersContext } from '../host-contracts/readKmsSignersContext-p.js';
35
35
  import { kmsSignersContextToExtraData } from '../host-contracts/KmsSignersContext-p.js';
@@ -301,7 +301,7 @@ type SignDecryptionPermitCommonParameters = {
301
301
  readonly durationDays: number;
302
302
  readonly signerAddress: string;
303
303
  readonly signer: NativeSigner;
304
- readonly transportKeypair: TransportKeypair;
304
+ readonly transportKeyPair: TransportKeyPair;
305
305
  };
306
306
 
307
307
  export type SignSelfDecryptionPermitParameters = SignDecryptionPermitCommonParameters & {
@@ -324,10 +324,10 @@ export type SignDecryptionPermitParameters =
324
324
  * to decrypt encrypted values belonging to the `delegatorAddress` account.
325
325
  * Otherwise, creates a standard permit where the signer decrypts their own values.
326
326
  *
327
- * The EIP-712 message includes the keypair's public key, allowing the gateway
328
- * to encrypt the decrypted result for this specific keypair.
327
+ * The EIP-712 message includes the key pair's public key, allowing the gateway
328
+ * to encrypt the decrypted result for this specific key pair.
329
329
  *
330
- * @throws If the signer, address, or keypair is invalid.
330
+ * @throws If the signer, address, or key pair is invalid.
331
331
  * @throws If the signature verification fails.
332
332
  */
333
333
  export async function signDecryptionPermit(
@@ -353,12 +353,12 @@ export async function signDecryptionPermit(
353
353
  startTimestamp,
354
354
  durationDays,
355
355
  signerAddress: signerAddressArg,
356
- transportKeypair,
356
+ transportKeyPair: transportKeyPair,
357
357
  signer,
358
358
  delegatorAddress,
359
359
  } = parameters;
360
360
 
361
- assertIsTransportKeypair(transportKeypair, {});
361
+ assertIsTransportKeyPair(transportKeyPair, {});
362
362
  assertIsAddress(signerAddressArg, {});
363
363
 
364
364
  if (delegatorAddress !== undefined) {
@@ -380,7 +380,7 @@ export async function signDecryptionPermit(
380
380
  durationDays,
381
381
  startTimestamp,
382
382
  extraData,
383
- publicKey: transportKeypair.publicKey,
383
+ publicKey: transportKeyPair.publicKey,
384
384
  };
385
385
 
386
386
  const eip712 =
@@ -414,10 +414,10 @@ export async function parseSignedDecryptionPermit(
414
414
  readonly client: NonNullable<object>;
415
415
  readonly options: { readonly batchRpcCalls: boolean };
416
416
  },
417
- transportKeypair: TransportKeypair,
417
+ transportKeyPair: TransportKeyPair,
418
418
  permit: unknown,
419
419
  ): Promise<SignedDecryptionPermit> {
420
- assertIsTransportKeypair(transportKeypair, {});
420
+ assertIsTransportKeyPair(transportKeyPair, {});
421
421
 
422
422
  const permitName = 'permit';
423
423
  const options = {};
@@ -438,10 +438,10 @@ export async function parseSignedDecryptionPermit(
438
438
  throw new Error(`Unknown permit primaryType: ${primaryType}`);
439
439
  }
440
440
 
441
- if (eip712.message.publicKey.toLowerCase() !== transportKeypair.publicKey.toLowerCase()) {
441
+ if (eip712.message.publicKey.toLowerCase() !== transportKeyPair.publicKey.toLowerCase()) {
442
442
  throw new Error(
443
- "The permit's publicKey does not match the E2eTransportKeypair's publicKey. " +
444
- 'Ensure the permit was signed with the same keypair.',
443
+ "The permit's publicKey does not match the E2eTransportKeyPair's publicKey. " +
444
+ 'Ensure the permit was signed with the same key pair.',
445
445
  );
446
446
  }
447
447
 
@@ -10,22 +10,22 @@ import { verifyTkmsPublicKey } from '../utils-p/decrypt/verifyTkmsPublicKey.js';
10
10
 
11
11
  ////////////////////////////////////////////////////////////////////////////////
12
12
 
13
- const PRIVATE_TOKEN = Symbol('TransportKeypair.token');
13
+ const PRIVATE_TOKEN = Symbol('TransportKeyPair.token');
14
14
 
15
15
  ////////////////////////////////////////////////////////////////////////////////
16
16
 
17
- declare const TransportKeypairBrand: unique symbol;
17
+ declare const TransportKeyPairBrand: unique symbol;
18
18
 
19
- export type TransportKeypair = {
19
+ export type TransportKeyPair = {
20
20
  readonly publicKey: BytesHex;
21
- readonly [TransportKeypairBrand]: true;
21
+ readonly [TransportKeyPairBrand]: true;
22
22
  };
23
23
 
24
24
  ////////////////////////////////////////////////////////////////////////////////
25
- // TransportKeypairImpl
25
+ // TransportKeyPairImpl
26
26
  //
27
27
  // Unexported class wrapping closures that bind a tkmsPrivateKey.
28
- // - Class: enables instanceof checks (isTransportKeypair)
28
+ // - Class: enables instanceof checks (isTransportKeyPair)
29
29
  // - Closures: methods capture privateKey without exposing it
30
30
  // - Frozen: instance, class, and prototype are all immutable
31
31
  // - Tree-shakable: unused exports are eliminated by bundlers
@@ -35,8 +35,8 @@ export type TransportKeypair = {
35
35
  const GetTkmsPrivateKeyFn = Symbol();
36
36
  const SerializeFn = Symbol();
37
37
 
38
- class TransportKeypairImpl implements TransportKeypair {
39
- declare readonly [TransportKeypairBrand]: true;
38
+ class TransportKeyPairImpl implements TransportKeyPair {
39
+ declare readonly [TransportKeyPairBrand]: true;
40
40
 
41
41
  readonly #publicKeyBytesHex: BytesHex;
42
42
  readonly #privateKeyBytes: Bytes;
@@ -82,7 +82,7 @@ class TransportKeypairImpl implements TransportKeypair {
82
82
  throw new Error('Unauthorized');
83
83
  }
84
84
  // If the runtime was GC'd, deref() returns undefined, which !== expectedRuntime → throws.
85
- // This is intentional: a GC'd runtime means the keypair is stale.
85
+ // This is intentional: a GC'd runtime means the key pair is stale.
86
86
  if (expectedRuntime !== this.#runtime.deref()) {
87
87
  throw new Error('Invalid runtime');
88
88
  }
@@ -109,7 +109,7 @@ class TransportKeypairImpl implements TransportKeypair {
109
109
  }
110
110
 
111
111
  /**
112
- * Hidden method (Symbol key) that serializes the keypair including the private key.
112
+ * Hidden method (Symbol key) that serializes the key pair including the private key.
113
113
  *
114
114
  * Access is protected by the Symbol key (not exported) and the private token.
115
115
  */
@@ -135,29 +135,29 @@ class TransportKeypairImpl implements TransportKeypair {
135
135
  }
136
136
  }
137
137
 
138
- Object.freeze(TransportKeypairImpl);
139
- Object.freeze(TransportKeypairImpl.prototype);
138
+ Object.freeze(TransportKeyPairImpl);
139
+ Object.freeze(TransportKeyPairImpl.prototype);
140
140
 
141
141
  ////////////////////////////////////////////////////////////////////////////////
142
142
 
143
143
  /** Type guard. */
144
- export function isTransportKeypair(value: unknown): value is TransportKeypair {
145
- return value instanceof TransportKeypairImpl;
144
+ export function isTransportKeyPair(value: unknown): value is TransportKeyPair {
145
+ return value instanceof TransportKeyPairImpl;
146
146
  }
147
147
 
148
148
  ////////////////////////////////////////////////////////////////////////////////
149
149
 
150
- /** Throws {@link InvalidTypeError} if value is not a valid {@link TransportKeypair}. */
151
- export function assertIsTransportKeypair(
150
+ /** Throws {@link InvalidTypeError} if value is not a valid {@link TransportKeyPair}. */
151
+ export function assertIsTransportKeyPair(
152
152
  value: unknown,
153
153
  options: { subject?: string } & ErrorMetadataParams,
154
- ): asserts value is TransportKeypair {
155
- if (!isTransportKeypair(value)) {
154
+ ): asserts value is TransportKeyPair {
155
+ if (!isTransportKeyPair(value)) {
156
156
  throw new InvalidTypeError(
157
157
  {
158
158
  subject: options.subject,
159
159
  type: typeof value,
160
- expectedType: 'TransportKeypair',
160
+ expectedType: 'TransportKeyPair',
161
161
  },
162
162
  options,
163
163
  );
@@ -166,14 +166,14 @@ export function assertIsTransportKeypair(
166
166
 
167
167
  ////////////////////////////////////////////////////////////////////////////////
168
168
 
169
- /** Generates a fresh {@link TransportKeypair}. */
170
- export async function generateTransportKeypair(context: { readonly runtime: WithDecrypt }): Promise<TransportKeypair> {
169
+ /** Generates a fresh {@link TransportKeyPair}. */
170
+ export async function generateTransportKeyPair(context: { readonly runtime: WithDecrypt }): Promise<TransportKeyPair> {
171
171
  const tkmsPrivateKey = await context.runtime.decrypt.generateTkmsPrivateKey();
172
172
  const tkmsPrivateKeyBytes = await context.runtime.decrypt.serializeTkmsPrivateKey({ tkmsPrivateKey });
173
173
  const tkmsPublicKeyBytesHex = await context.runtime.decrypt.getTkmsPublicKeyHex({
174
174
  tkmsPrivateKey,
175
175
  });
176
- return new TransportKeypairImpl(PRIVATE_TOKEN, context.runtime, {
176
+ return new TransportKeyPairImpl(PRIVATE_TOKEN, context.runtime, {
177
177
  privateKeyBytes: tkmsPrivateKeyBytes,
178
178
  publicKeyBytesHex: tkmsPublicKeyBytesHex,
179
179
  tkmsPrivateKey,
@@ -181,25 +181,25 @@ export async function generateTransportKeypair(context: { readonly runtime: With
181
181
  }
182
182
 
183
183
  /**
184
- * Converts an unknown value into a {@link TransportKeypair}.
184
+ * Converts an unknown value into a {@link TransportKeyPair}.
185
185
  *
186
186
  * Accepted inputs:
187
- * - An existing {@link TransportKeypair} (returned as-is)
187
+ * - An existing {@link TransportKeyPair} (returned as-is)
188
188
  * - A plain object `{ publicKey, privateKey }` where each is `Bytes` or `BytesHex`
189
189
  *
190
- * @throws {InvalidTypeError} If `value` is not a recognized keypair shape.
190
+ * @throws {InvalidTypeError} If `value` is not a recognized key pair shape.
191
191
  */
192
- export async function toTransportKeypair(
192
+ export async function toTransportKeyPair(
193
193
  context: { readonly runtime: FhevmRuntime },
194
194
  value: unknown,
195
- ): Promise<TransportKeypair> {
196
- if (isTransportKeypair(value)) {
195
+ ): Promise<TransportKeyPair> {
196
+ if (isTransportKeyPair(value)) {
197
197
  // Force realize
198
- await (value as TransportKeypairImpl)[GetTkmsPrivateKeyFn](PRIVATE_TOKEN, context.runtime);
198
+ await (value as TransportKeyPairImpl)[GetTkmsPrivateKeyFn](PRIVATE_TOKEN, context.runtime);
199
199
  return value;
200
200
  }
201
201
 
202
- const name = 'TransportKeypair';
202
+ const name = 'TransportKeyPair';
203
203
  const options = {};
204
204
 
205
205
  assertRecordNonNullableProperty(value, 'publicKey', name, {
@@ -240,7 +240,7 @@ export async function toTransportKeypair(
240
240
  await verifyTkmsPublicKey({ runtime: runtimeWithDecrypt }, { tkmsPrivateKey, tkmsPublicKeyBytesHex });
241
241
  }
242
242
 
243
- return new TransportKeypairImpl(PRIVATE_TOKEN, context.runtime, {
243
+ return new TransportKeyPairImpl(PRIVATE_TOKEN, context.runtime, {
244
244
  privateKeyBytes: tkmsPrivateKeyBytes,
245
245
  publicKeyBytesHex: tkmsPublicKeyBytesHex,
246
246
  tkmsPrivateKey,
@@ -248,31 +248,31 @@ export async function toTransportKeypair(
248
248
  }
249
249
 
250
250
  /**
251
- * Serializes an {@link TransportKeypair} including the private key.
251
+ * Serializes an {@link TransportKeyPair} including the private key.
252
252
  *
253
253
  * **The output contains sensitive key material — handle and store securely.**
254
254
  *
255
- * @throws {InvalidTypeError} If `value` is not a valid {@link TransportKeypair}.
255
+ * @throws {InvalidTypeError} If `value` is not a valid {@link TransportKeyPair}.
256
256
  */
257
- export function serializeTransportKeypair(value: TransportKeypair): {
257
+ export function serializeTransportKeyPair(value: TransportKeyPair): {
258
258
  publicKey: BytesHex;
259
259
  privateKey: BytesHex;
260
260
  } {
261
- assertIsTransportKeypair(value, {});
262
- return (value as TransportKeypairImpl)[SerializeFn](PRIVATE_TOKEN);
261
+ assertIsTransportKeyPair(value, {});
262
+ return (value as TransportKeyPairImpl)[SerializeFn](PRIVATE_TOKEN);
263
263
  }
264
264
 
265
265
  /**
266
- * Extracts the deserialized TKMS private key from an {@link TransportKeypair}.
266
+ * Extracts the deserialized TKMS private key from an {@link TransportKeyPair}.
267
267
  * Lazily deserializes and verifies the key on first access.
268
268
  *
269
- * @throws {InvalidTypeError} If `value` is not a valid {@link TransportKeypair}.
269
+ * @throws {InvalidTypeError} If `value` is not a valid {@link TransportKeyPair}.
270
270
  * @throws If the runtime does not match or the key verification fails.
271
271
  */
272
- export async function transportKeypairToTkmsPrivateKey(
272
+ export async function transportKeyPairToTkmsPrivateKey(
273
273
  context: { readonly runtime: FhevmRuntime },
274
- value: TransportKeypair,
274
+ value: TransportKeyPair,
275
275
  ): Promise<TkmsPrivateKey> {
276
- assertIsTransportKeypair(value, {});
277
- return await (value as TransportKeypairImpl)[GetTkmsPrivateKeyFn](PRIVATE_TOKEN, context.runtime);
276
+ assertIsTransportKeyPair(value, {});
277
+ return await (value as TransportKeyPairImpl)[GetTkmsPrivateKeyFn](PRIVATE_TOKEN, context.runtime);
278
278
  }
@@ -1,8 +1,8 @@
1
1
  import type { WithDecrypt } from '../types/coreFhevmRuntime.js';
2
2
  import type { KmsSigncryptedShares } from '../types/kms.js';
3
3
  import type { ClearValue } from '../types/encryptedTypes-p.js';
4
- import type { TransportKeypair } from './TransportKeypair-p.js';
5
- import { transportKeypairToTkmsPrivateKey } from './TransportKeypair-p.js';
4
+ import type { TransportKeyPair } from './TransportKeyPair-p.js';
5
+ import { transportKeyPairToTkmsPrivateKey } from './TransportKeyPair-p.js';
6
6
 
7
7
  ////////////////////////////////////////////////////////////////////////////////
8
8
  // decryptKmsSignedcryptedShares (with privateKey)
@@ -14,7 +14,7 @@ type Context = {
14
14
 
15
15
  type Parameters = {
16
16
  readonly kmsSigncryptedShares: KmsSigncryptedShares;
17
- readonly transportKeypair: TransportKeypair;
17
+ readonly transportKeyPair: TransportKeyPair;
18
18
  };
19
19
 
20
20
  type ReturnType = readonly ClearValue[];
@@ -22,10 +22,10 @@ type ReturnType = readonly ClearValue[];
22
22
  ////////////////////////////////////////////////////////////////////////////////
23
23
 
24
24
  export async function decryptKmsSignedcryptedShares(context: Context, parameters: Parameters): Promise<ReturnType> {
25
- const { transportKeypair, kmsSigncryptedShares } = parameters;
25
+ const { transportKeyPair: transportKeyPair, kmsSigncryptedShares } = parameters;
26
26
 
27
- // also validates `transportKeypair`
28
- const tkmsPrivateKey = await transportKeypairToTkmsPrivateKey(context, transportKeypair);
27
+ // also validates `transportKeyPair`
28
+ const tkmsPrivateKey = await transportKeyPairToTkmsPrivateKey(context, transportKeyPair);
29
29
 
30
30
  // Using the `KmsSigncryptedShares` decrypt and reconstruct clear values
31
31
  const orderedDecryptedHandles: readonly ClearValue[] = await context.runtime.decrypt.decryptAndReconstruct({
@@ -7,7 +7,7 @@ import type { KmsSigncryptedShares } from '../types/kms.js';
7
7
  import type { ChecksummedAddress, TypedValue } from '../types/primitives.js';
8
8
  import type { RelayerDelegatedUserDecryptOptions, RelayerUserDecryptOptions } from '../types/relayer.js';
9
9
  import type { SignedDelegatedDecryptionPermit, SignedSelfDecryptionPermit } from '../types/signedDecryptionPermit.js';
10
- import type { TransportKeypair } from './TransportKeypair-p.js';
10
+ import type { TransportKeyPair } from './TransportKeyPair-p.js';
11
11
  import { decryptKmsSignedcryptedShares } from './decryptKmsSignedcryptedShares-p.js';
12
12
  import { fetchKmsSignedcryptedShares } from './fetchKmsSignedcryptedShares-p.js';
13
13
 
@@ -27,7 +27,7 @@ type Parameters =
27
27
  readonly contractAddress: ChecksummedAddress;
28
28
  }>;
29
29
  readonly signedPermit: SignedSelfDecryptionPermit;
30
- readonly transportKeypair: TransportKeypair;
30
+ readonly transportKeyPair: TransportKeyPair;
31
31
  readonly options?: RelayerUserDecryptOptions | undefined;
32
32
  }
33
33
  | {
@@ -36,7 +36,7 @@ type Parameters =
36
36
  readonly contractAddress: ChecksummedAddress;
37
37
  }>;
38
38
  readonly signedPermit: SignedDelegatedDecryptionPermit;
39
- readonly transportKeypair: TransportKeypair;
39
+ readonly transportKeyPair: TransportKeyPair;
40
40
  readonly options?: RelayerDelegatedUserDecryptOptions | undefined;
41
41
  };
42
42
 
@@ -45,13 +45,13 @@ export type ReturnType = readonly TypedValue[];
45
45
  ////////////////////////////////////////////////////////////////////////////////
46
46
 
47
47
  export async function decryptValuesFromPairs(fhevm: Context, parameters: Parameters): Promise<ReturnType> {
48
- const { transportKeypair } = parameters;
48
+ const { transportKeyPair: transportKeyPair } = parameters;
49
49
 
50
50
  const kmsSigncryptedShares: KmsSigncryptedShares = await fetchKmsSignedcryptedShares(fhevm, parameters);
51
51
 
52
52
  // Using the `KmsSigncryptedShares` decrypt and reconstruct clear values
53
53
  return decryptKmsSignedcryptedShares(fhevm, {
54
54
  kmsSigncryptedShares,
55
- transportKeypair,
55
+ transportKeyPair: transportKeyPair,
56
56
  });
57
57
  }
package/core/kms/index.ts CHANGED
@@ -1 +0,0 @@
1
- export type { TransportKeypair } from './TransportKeypair-p.ts';
@@ -53,7 +53,7 @@ export async function decryptAndReconstruct(
53
53
  const cleartextEthereumModule = runtime.ethereum as CleartextEthereumModule;
54
54
  const { tkmsPrivateKey, shares } = parameters;
55
55
 
56
- const privateKeySecp256k1 = asBytesHex(tkmsPrivateKey as unknown);
56
+ const privateKeySecp256k1 = asBytesHex(tkmsPrivateKey);
57
57
  const publicKeySecp256k1 = cleartextEthereumModule.getPublicKey({ privateKey: privateKeySecp256k1 });
58
58
 
59
59
  const metadata: KmsSigncryptedSharesMetadata = getMetadata(shares);
@@ -149,7 +149,7 @@ export async function getTkmsPublicKeyHex(
149
149
  parameters: GetTkmsPublicKeyHexParameters,
150
150
  ): Promise<GetTkmsPublicKeyHexReturnType> {
151
151
  const { tkmsPrivateKey } = parameters;
152
- const privateKeySecp256k1 = asBytesHex(tkmsPrivateKey as unknown);
152
+ const privateKeySecp256k1 = asBytesHex(tkmsPrivateKey);
153
153
  const cleartextEthereumModule = runtime.ethereum as CleartextEthereumModule;
154
154
  const publicKeySecp256k1 = cleartextEthereumModule.getPublicKey({ privateKey: privateKeySecp256k1 });
155
155
  return Promise.resolve(publicKeySecp256k1);
@@ -164,7 +164,7 @@ export async function serializeTkmsPrivateKey(
164
164
  parameters: SerializeTkmsPrivateKeyParameters,
165
165
  ): Promise<SerializeTkmsPrivateKeyReturnType> {
166
166
  const { tkmsPrivateKey } = parameters;
167
- const privateKeySecp256k1 = asBytesHex(tkmsPrivateKey as unknown);
167
+ const privateKeySecp256k1 = asBytesHex(tkmsPrivateKey);
168
168
  const privateKeySecp256k1Bytes = hexToBytes(privateKeySecp256k1);
169
169
  return Promise.resolve(privateKeySecp256k1Bytes);
170
170
  }
@@ -109,22 +109,21 @@ export async function initTkmsModule(runtime: FhevmRuntime): Promise<void> {
109
109
 
110
110
  ownerUid = runtime.uid;
111
111
 
112
- if (cachedTkmsModulePromise !== undefined) {
113
- return cachedTkmsModulePromise;
112
+ // Cache the TKMS initialization promise once and keep it cached even if it
113
+ // rejects.
114
+ //
115
+ // Retry is not supported:
116
+ // -----------------------
117
+ // The underlying KMS/WASM bindings
118
+ // keep module-level state that cannot be reset reliably after a partial
119
+ // initialization failure; later callers should observe the original error
120
+ // instead of retrying against half-initialized state.
121
+ if (cachedTkmsModulePromise === undefined) {
122
+ // resolve is sync
123
+ const cfg = _getOrResolveTkmsModuleConfig(runtime);
124
+ cachedTkmsModulePromise = _initTkmsModule(cfg);
114
125
  }
115
126
 
116
- // Use existing config if already set, otherwise resolve from runtime
117
- const cfg = _getOrResolveTkmsModuleConfig(runtime);
118
-
119
- cachedTkmsModulePromise = _initTkmsModule(cfg);
120
-
121
- // This is purely theoretical. Retry is not yet possible since the `_initTkmsModule`
122
- // does not support retry (see kms lib internal global variables).
123
- cachedTkmsModulePromise.catch(() => {
124
- // Clear cache on failure so retry is possible
125
- cachedTkmsModulePromise = undefined;
126
- });
127
-
128
127
  return cachedTkmsModulePromise;
129
128
  }
130
129
 
@@ -6,15 +6,13 @@ import type { FhevmRuntime } from '../../types/coreFhevmRuntime.js';
6
6
  import type {
7
7
  FheEncryptionCrs,
8
8
  FheEncryptionCrsBrand,
9
- FheEncryptionCrsBytes,
10
9
  FheEncryptionKeyBytes,
11
10
  FheEncryptionPublicKey,
12
11
  FheEncryptionPublicKeyBrand,
13
- FheEncryptionPublicKeyBytes,
14
12
  } from '../../types/fheEncryptionKey.js';
15
13
  import type { Bytes, BytesHex, UintNumber } from '../../types/primitives.js';
16
14
  import type {
17
- BuildWithProofPackedReturnTypeParameters,
15
+ BuildWithProofPackedParameters,
18
16
  BuildWithProofPackedReturnType,
19
17
  ParseTFHEProvenCompactCiphertextListParameters,
20
18
  ParseTFHEProvenCompactCiphertextListReturnType,
@@ -123,7 +121,7 @@ export async function parseTFHEProvenCompactCiphertextList(
123
121
  ////////////////////////////////////////////////////////////////////////////////
124
122
 
125
123
  export async function buildWithProofPacked(
126
- parameters: BuildWithProofPackedReturnTypeParameters,
124
+ parameters: BuildWithProofPackedParameters,
127
125
  ): Promise<BuildWithProofPackedReturnType> {
128
126
  const { fheEncryptionKey: publicEncryptionParams, metaData, typedValues, extraData } = parameters;
129
127
 
@@ -219,7 +217,7 @@ export async function serializeFheEncryptionPublicKey(
219
217
  return Object.freeze({
220
218
  id: tfhePublicKey.id,
221
219
  bytes: tfhePublicKeyBytes,
222
- }) as FheEncryptionPublicKeyBytes;
220
+ });
223
221
  }
224
222
 
225
223
  ////////////////////////////////////////////////////////////////////////////////
@@ -246,7 +244,7 @@ export async function serializeFheEncryptionCrs(
246
244
  id: tfheCrs.id,
247
245
  capacity: tfheCrs.capacity,
248
246
  bytes: tfheCrsBytes,
249
- }) as FheEncryptionCrsBytes;
247
+ });
250
248
  }
251
249
 
252
250
  ////////////////////////////////////////////////////////////////////////////////
@@ -1,5 +1,5 @@
1
1
  import type {
2
- BuildWithProofPackedReturnTypeParameters,
2
+ BuildWithProofPackedParameters,
3
3
  BuildWithProofPackedReturnType,
4
4
  ParseTFHEProvenCompactCiphertextListParameters,
5
5
  ParseTFHEProvenCompactCiphertextListReturnType,
@@ -17,11 +17,9 @@ import type {
17
17
  import type {
18
18
  FheEncryptionCrs,
19
19
  FheEncryptionCrsBrand,
20
- FheEncryptionCrsBytes,
21
20
  FheEncryptionKeyBytes,
22
21
  FheEncryptionPublicKey,
23
22
  FheEncryptionPublicKeyBrand,
24
- FheEncryptionPublicKeyBytes,
25
23
  } from '../../../types/fheEncryptionKey.js';
26
24
  import type { CompactCiphertextListBuilder } from '../../../../wasm/tfhe/tfhe.v1.5.3.js';
27
25
  import type { Bytes, UintNumber } from '../../../types/primitives.js';
@@ -195,7 +193,7 @@ export async function parseTFHEProvenCompactCiphertextList(
195
193
 
196
194
  export async function buildWithProofPacked(
197
195
  runtime: FhevmRuntime,
198
- parameters: BuildWithProofPackedReturnTypeParameters,
196
+ parameters: BuildWithProofPackedParameters,
199
197
  ): Promise<BuildWithProofPackedReturnType> {
200
198
  await initTfheModule(runtime);
201
199
 
@@ -359,7 +357,7 @@ export async function serializeFheEncryptionPublicKey(
359
357
  return Object.freeze({
360
358
  id: tfhePublicKey.id,
361
359
  bytes: tfhePublicKeyBytes,
362
- }) as FheEncryptionPublicKeyBytes;
360
+ });
363
361
  }
364
362
 
365
363
  ////////////////////////////////////////////////////////////////////////////////
@@ -389,7 +387,7 @@ export async function serializeFheEncryptionCrs(
389
387
  id: tfheCrs.id,
390
388
  capacity: tfheCrs.capacity,
391
389
  bytes: tfheCrsBytes,
392
- }) as FheEncryptionCrsBytes;
390
+ });
393
391
  }
394
392
 
395
393
  ////////////////////////////////////////////////////////////////////////////////
@@ -1,6 +1,6 @@
1
1
  import type { FhevmRuntime } from '../../../types/coreFhevmRuntime.js';
2
2
  import type {
3
- BuildWithProofPackedReturnTypeParameters,
3
+ BuildWithProofPackedParameters,
4
4
  DeserializeFheEncryptionCrsParameters,
5
5
  DeserializeFheEncryptionPublicKeyParameters,
6
6
  EncryptModuleFactory,
@@ -31,7 +31,7 @@ export const encryptModule: EncryptModuleFactory = (runtime: FhevmRuntime) => {
31
31
  getTfheModuleInfo: () => getTfheModuleInfo(),
32
32
  parseTFHEProvenCompactCiphertextList: (args: ParseTFHEProvenCompactCiphertextListParameters) =>
33
33
  parseTFHEProvenCompactCiphertextList(runtime, args),
34
- buildWithProofPacked: (args: BuildWithProofPackedReturnTypeParameters) => buildWithProofPacked(runtime, args),
34
+ buildWithProofPacked: (args: BuildWithProofPackedParameters) => buildWithProofPacked(runtime, args),
35
35
  serializeFheEncryptionKey: (args: SerializeFheEncryptionKeyParameters) =>
36
36
  serializeFheEncryptionKey(runtime, args),
37
37
  serializeFheEncryptionPublicKey: (args: SerializeFheEncryptionPublicKeyParameters) =>