@primuslabs/fhetransform-sdk 0.4.0

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 (302) hide show
  1. package/README.md +198 -0
  2. package/dist/abis/acl.abi.d.ts +379 -0
  3. package/dist/abis/acl.abi.js +495 -0
  4. package/dist/abis/acl.abi.js.map +1 -0
  5. package/dist/abis/alphatrion_reward.abi.d.ts +407 -0
  6. package/dist/abis/alphatrion_reward.abi.js +532 -0
  7. package/dist/abis/alphatrion_reward.abi.js.map +1 -0
  8. package/dist/abis/ciphertext_digests.abi.d.ts +336 -0
  9. package/dist/abis/ciphertext_digests.abi.js +444 -0
  10. package/dist/abis/ciphertext_digests.abi.js.map +1 -0
  11. package/dist/abis/ciphertext_verification.abi.d.ts +637 -0
  12. package/dist/abis/ciphertext_verification.abi.js +830 -0
  13. package/dist/abis/ciphertext_verification.abi.js.map +1 -0
  14. package/dist/abis/convert_token.abi.d.ts +922 -0
  15. package/dist/abis/convert_token.abi.js +1208 -0
  16. package/dist/abis/convert_token.abi.js.map +1 -0
  17. package/dist/abis/decryption.abi.d.ts +956 -0
  18. package/dist/abis/decryption.abi.js +1244 -0
  19. package/dist/abis/decryption.abi.js.map +1 -0
  20. package/dist/abis/erc20.abi.d.ts +265 -0
  21. package/dist/abis/erc20.abi.js +350 -0
  22. package/dist/abis/erc20.abi.js.map +1 -0
  23. package/dist/abis/fhe_executor.abi.d.ts +1535 -0
  24. package/dist/abis/fhe_executor.abi.js +1962 -0
  25. package/dist/abis/fhe_executor.abi.js.map +1 -0
  26. package/dist/abis/space_bridge_config.abi.d.ts +792 -0
  27. package/dist/abis/space_bridge_config.abi.js +1032 -0
  28. package/dist/abis/space_bridge_config.abi.js.map +1 -0
  29. package/dist/abis/token.abi.d.ts +630 -0
  30. package/dist/abis/token.abi.js +828 -0
  31. package/dist/abis/token.abi.js.map +1 -0
  32. package/dist/cli/eusdc.d.ts +2 -0
  33. package/dist/cli/eusdc.js +41 -0
  34. package/dist/cli/eusdc.js.map +1 -0
  35. package/dist/contract/callbacks.d.ts +59 -0
  36. package/dist/contract/callbacks.js +2 -0
  37. package/dist/contract/callbacks.js.map +1 -0
  38. package/dist/contract/convert-token.d.ts +107 -0
  39. package/dist/contract/convert-token.js +249 -0
  40. package/dist/contract/convert-token.js.map +1 -0
  41. package/dist/contract/token.d.ts +167 -0
  42. package/dist/contract/token.js +404 -0
  43. package/dist/contract/token.js.map +1 -0
  44. package/dist/contract/transaction.d.ts +29 -0
  45. package/dist/contract/transaction.js +2 -0
  46. package/dist/contract/transaction.js.map +1 -0
  47. package/dist/core/address.d.ts +118 -0
  48. package/dist/core/address.js +200 -0
  49. package/dist/core/address.js.map +1 -0
  50. package/dist/core/auth.d.ts +68 -0
  51. package/dist/core/auth.js +58 -0
  52. package/dist/core/auth.js.map +1 -0
  53. package/dist/core/bytes.d.ts +48 -0
  54. package/dist/core/bytes.js +117 -0
  55. package/dist/core/bytes.js.map +1 -0
  56. package/dist/core/cache-manager.d.ts +138 -0
  57. package/dist/core/cache-manager.js +440 -0
  58. package/dist/core/cache-manager.js.map +1 -0
  59. package/dist/core/chain.d.ts +41 -0
  60. package/dist/core/chain.js +59 -0
  61. package/dist/core/chain.js.map +1 -0
  62. package/dist/core/constants.d.ts +24 -0
  63. package/dist/core/constants.js +25 -0
  64. package/dist/core/constants.js.map +1 -0
  65. package/dist/core/error.d.ts +2 -0
  66. package/dist/core/error.js +14 -0
  67. package/dist/core/error.js.map +1 -0
  68. package/dist/core/errors/error-catalog.d.ts +29 -0
  69. package/dist/core/errors/error-catalog.js +84 -0
  70. package/dist/core/errors/error-catalog.js.map +1 -0
  71. package/dist/core/errors/error-codes.d.ts +52 -0
  72. package/dist/core/errors/error-codes.js +61 -0
  73. package/dist/core/errors/error-codes.js.map +1 -0
  74. package/dist/core/errors/error-utils.d.ts +27 -0
  75. package/dist/core/errors/error-utils.js +110 -0
  76. package/dist/core/errors/error-utils.js.map +1 -0
  77. package/dist/core/errors/fhe-error.d.ts +98 -0
  78. package/dist/core/errors/fhe-error.js +190 -0
  79. package/dist/core/errors/fhe-error.js.map +1 -0
  80. package/dist/core/errors/index.d.ts +4 -0
  81. package/dist/core/errors/index.js +5 -0
  82. package/dist/core/errors/index.js.map +1 -0
  83. package/dist/core/estimate.d.ts +39 -0
  84. package/dist/core/estimate.js +111 -0
  85. package/dist/core/estimate.js.map +1 -0
  86. package/dist/core/event.d.ts +212 -0
  87. package/dist/core/event.js +42 -0
  88. package/dist/core/event.js.map +1 -0
  89. package/dist/core/fhe-type.d.ts +75 -0
  90. package/dist/core/fhe-type.js +115 -0
  91. package/dist/core/fhe-type.js.map +1 -0
  92. package/dist/core/fhe.d.ts +11 -0
  93. package/dist/core/fhe.js +23 -0
  94. package/dist/core/fhe.js.map +1 -0
  95. package/dist/core/handle.d.ts +42 -0
  96. package/dist/core/handle.js +99 -0
  97. package/dist/core/handle.js.map +1 -0
  98. package/dist/core/json-utils.d.ts +18 -0
  99. package/dist/core/json-utils.js +37 -0
  100. package/dist/core/json-utils.js.map +1 -0
  101. package/dist/core/kms.d.ts +42 -0
  102. package/dist/core/kms.js +70 -0
  103. package/dist/core/kms.js.map +1 -0
  104. package/dist/core/logger.d.ts +3 -0
  105. package/dist/core/logger.js +11 -0
  106. package/dist/core/logger.js.map +1 -0
  107. package/dist/core/pretty-print.d.ts +18 -0
  108. package/dist/core/pretty-print.js +84 -0
  109. package/dist/core/pretty-print.js.map +1 -0
  110. package/dist/core/primitives.d.ts +22 -0
  111. package/dist/core/primitives.js +2 -0
  112. package/dist/core/primitives.js.map +1 -0
  113. package/dist/core/retryable-handler.d.ts +74 -0
  114. package/dist/core/retryable-handler.js +227 -0
  115. package/dist/core/retryable-handler.js.map +1 -0
  116. package/dist/core/signer-address-info.d.ts +15 -0
  117. package/dist/core/signer-address-info.js +33 -0
  118. package/dist/core/signer-address-info.js.map +1 -0
  119. package/dist/core/string.d.ts +28 -0
  120. package/dist/core/string.js +33 -0
  121. package/dist/core/string.js.map +1 -0
  122. package/dist/core/swallow.d.ts +23 -0
  123. package/dist/core/swallow.js +37 -0
  124. package/dist/core/swallow.js.map +1 -0
  125. package/dist/core/system-contract-info.d.ts +17 -0
  126. package/dist/core/system-contract-info.js +41 -0
  127. package/dist/core/system-contract-info.js.map +1 -0
  128. package/dist/core/ttl-cache.d.ts +81 -0
  129. package/dist/core/ttl-cache.js +113 -0
  130. package/dist/core/ttl-cache.js.map +1 -0
  131. package/dist/core/tx-error-parser.d.ts +40 -0
  132. package/dist/core/tx-error-parser.js +83 -0
  133. package/dist/core/tx-error-parser.js.map +1 -0
  134. package/dist/core/utils.d.ts +62 -0
  135. package/dist/core/utils.js +143 -0
  136. package/dist/core/utils.js.map +1 -0
  137. package/dist/index.d.ts +40 -0
  138. package/dist/index.js +48 -0
  139. package/dist/index.js.map +1 -0
  140. package/dist/jazz/encrypt-key-p.d.ts +65 -0
  141. package/dist/jazz/encrypt-key-p.js +283 -0
  142. package/dist/jazz/encrypt-key-p.js.map +1 -0
  143. package/dist/jazz/encrypt-p.d.ts +82 -0
  144. package/dist/jazz/encrypt-p.js +139 -0
  145. package/dist/jazz/encrypt-p.js.map +1 -0
  146. package/dist/jazz/encrypt.d.ts +58 -0
  147. package/dist/jazz/encrypt.js +155 -0
  148. package/dist/jazz/encrypt.js.map +1 -0
  149. package/dist/jazz/input-proof-p.d.ts +122 -0
  150. package/dist/jazz/input-proof-p.js +265 -0
  151. package/dist/jazz/input-proof-p.js.map +1 -0
  152. package/dist/jazz/jazz-client-i.d.ts +16 -0
  153. package/dist/jazz/jazz-client-i.js +2 -0
  154. package/dist/jazz/jazz-client-i.js.map +1 -0
  155. package/dist/jazz/jazz-client.d.ts +18 -0
  156. package/dist/jazz/jazz-client.js +24 -0
  157. package/dist/jazz/jazz-client.js.map +1 -0
  158. package/dist/jazz/key-pair.d.ts +50 -0
  159. package/dist/jazz/key-pair.js +166 -0
  160. package/dist/jazz/key-pair.js.map +1 -0
  161. package/dist/jazz/mock/fake.d.ts +3 -0
  162. package/dist/jazz/mock/fake.js +23 -0
  163. package/dist/jazz/mock/fake.js.map +1 -0
  164. package/dist/jazz/mock/fetch-input-proof.d.ts +4 -0
  165. package/dist/jazz/mock/fetch-input-proof.js +63 -0
  166. package/dist/jazz/mock/fetch-input-proof.js.map +1 -0
  167. package/dist/jazz/mock/fetch-key-url.d.ts +3 -0
  168. package/dist/jazz/mock/fetch-key-url.js +15 -0
  169. package/dist/jazz/mock/fetch-key-url.js.map +1 -0
  170. package/dist/jazz/mock/fetch-public-decrypt.d.ts +3 -0
  171. package/dist/jazz/mock/fetch-public-decrypt.js +81 -0
  172. package/dist/jazz/mock/fetch-public-decrypt.js.map +1 -0
  173. package/dist/jazz/mock/fetch-user-decrypt.d.ts +4 -0
  174. package/dist/jazz/mock/fetch-user-decrypt.js +174 -0
  175. package/dist/jazz/mock/fetch-user-decrypt.js.map +1 -0
  176. package/dist/jazz/module/fetch-input-proof.d.ts +19 -0
  177. package/dist/jazz/module/fetch-input-proof.js +72 -0
  178. package/dist/jazz/module/fetch-input-proof.js.map +1 -0
  179. package/dist/jazz/module/fetch-key-url.d.ts +17 -0
  180. package/dist/jazz/module/fetch-key-url.js +46 -0
  181. package/dist/jazz/module/fetch-key-url.js.map +1 -0
  182. package/dist/jazz/module/fetch-public-decrypt.d.ts +19 -0
  183. package/dist/jazz/module/fetch-public-decrypt.js +65 -0
  184. package/dist/jazz/module/fetch-public-decrypt.js.map +1 -0
  185. package/dist/jazz/module/fetch-user-decrypt.d.ts +19 -0
  186. package/dist/jazz/module/fetch-user-decrypt.js +109 -0
  187. package/dist/jazz/module/fetch-user-decrypt.js.map +1 -0
  188. package/dist/jazz/module/jazz-async-request.d.ts +102 -0
  189. package/dist/jazz/module/jazz-async-request.js +515 -0
  190. package/dist/jazz/module/jazz-async-request.js.map +1 -0
  191. package/dist/jazz/module/jazz-p.d.ts +61 -0
  192. package/dist/jazz/module/jazz-p.js +33 -0
  193. package/dist/jazz/module/jazz-p.js.map +1 -0
  194. package/dist/jazz/module/s3-download.d.ts +85 -0
  195. package/dist/jazz/module/s3-download.js +293 -0
  196. package/dist/jazz/module/s3-download.js.map +1 -0
  197. package/dist/jazz/permit.d.ts +200 -0
  198. package/dist/jazz/permit.js +319 -0
  199. package/dist/jazz/permit.js.map +1 -0
  200. package/dist/jazz/public-decrypt-p.d.ts +96 -0
  201. package/dist/jazz/public-decrypt-p.js +258 -0
  202. package/dist/jazz/public-decrypt-p.js.map +1 -0
  203. package/dist/jazz/public-decrypt.d.ts +48 -0
  204. package/dist/jazz/public-decrypt.js +156 -0
  205. package/dist/jazz/public-decrypt.js.map +1 -0
  206. package/dist/jazz/read-contract.d.ts +81 -0
  207. package/dist/jazz/read-contract.js +125 -0
  208. package/dist/jazz/read-contract.js.map +1 -0
  209. package/dist/jazz/types/common.d.ts +17 -0
  210. package/dist/jazz/types/common.js +2 -0
  211. package/dist/jazz/types/common.js.map +1 -0
  212. package/dist/jazz/types/input-proof.d.ts +76 -0
  213. package/dist/jazz/types/input-proof.js +2 -0
  214. package/dist/jazz/types/input-proof.js.map +1 -0
  215. package/dist/jazz/types/key-url.d.ts +68 -0
  216. package/dist/jazz/types/key-url.js +5 -0
  217. package/dist/jazz/types/key-url.js.map +1 -0
  218. package/dist/jazz/types/public-decrypt.d.ts +61 -0
  219. package/dist/jazz/types/public-decrypt.js +2 -0
  220. package/dist/jazz/types/public-decrypt.js.map +1 -0
  221. package/dist/jazz/types/user-decrypt.d.ts +123 -0
  222. package/dist/jazz/types/user-decrypt.js +2 -0
  223. package/dist/jazz/types/user-decrypt.js.map +1 -0
  224. package/dist/jazz/user-decrypt-p.d.ts +111 -0
  225. package/dist/jazz/user-decrypt-p.js +280 -0
  226. package/dist/jazz/user-decrypt-p.js.map +1 -0
  227. package/dist/jazz/user-decrypt.d.ts +74 -0
  228. package/dist/jazz/user-decrypt.js +143 -0
  229. package/dist/jazz/user-decrypt.js.map +1 -0
  230. package/dist/native/fhe-api.js +5959 -0
  231. package/dist/native/fhe-api.node.cjs +6167 -0
  232. package/dist/native/fhe-api.node.worker.cjs +210 -0
  233. package/dist/native/fhe-api.wasm +0 -0
  234. package/dist/native/fhe-api.worker.js +164 -0
  235. package/dist/native/kms/node/kms_lib.d.ts +38 -0
  236. package/dist/native/kms/node/kms_lib.js +356 -0
  237. package/dist/native/kms/node/kms_lib_bg.wasm +0 -0
  238. package/dist/native/kms/node/kms_lib_bg.wasm.d.ts +21 -0
  239. package/dist/native/kms/node/package.json +11 -0
  240. package/dist/native/kms/web/kms_lib.d.ts +84 -0
  241. package/dist/native/kms/web/kms_lib.js +443 -0
  242. package/dist/native/kms/web/kms_lib_bg.wasm +0 -0
  243. package/dist/native/kms/web/kms_lib_bg.wasm.d.ts +21 -0
  244. package/dist/native/kms/web/package.json +15 -0
  245. package/dist/runtime/browser.d.ts +36 -0
  246. package/dist/runtime/browser.js +115 -0
  247. package/dist/runtime/browser.js.map +1 -0
  248. package/dist/runtime/node.d.ts +30 -0
  249. package/dist/runtime/node.js +95 -0
  250. package/dist/runtime/node.js.map +1 -0
  251. package/dist/sdk/fhetransform-sdk-b.d.ts +102 -0
  252. package/dist/sdk/fhetransform-sdk-b.js +294 -0
  253. package/dist/sdk/fhetransform-sdk-b.js.map +1 -0
  254. package/dist/sdk/fhetransform-sdk.d.ts +87 -0
  255. package/dist/sdk/fhetransform-sdk.js +135 -0
  256. package/dist/sdk/fhetransform-sdk.js.map +1 -0
  257. package/dist/sdk/jazz-service.d.ts +13 -0
  258. package/dist/sdk/jazz-service.js +58 -0
  259. package/dist/sdk/jazz-service.js.map +1 -0
  260. package/dist/sdk/permit-service.d.ts +45 -0
  261. package/dist/sdk/permit-service.js +144 -0
  262. package/dist/sdk/permit-service.js.map +1 -0
  263. package/dist/wasm/fhe-wasm-client.d.ts +19 -0
  264. package/dist/wasm/fhe-wasm-client.js +23 -0
  265. package/dist/wasm/fhe-wasm-client.js.map +1 -0
  266. package/dist/wasm/fhe-wasm-module.d.ts +24 -0
  267. package/dist/wasm/fhe-wasm-module.js +141 -0
  268. package/dist/wasm/fhe-wasm-module.js.map +1 -0
  269. package/dist/wasm/fhe-wasm-type.d.ts +59 -0
  270. package/dist/wasm/fhe-wasm-type.js +244 -0
  271. package/dist/wasm/fhe-wasm-type.js.map +1 -0
  272. package/dist/wasm/wasm-loader.browser.d.ts +21 -0
  273. package/dist/wasm/wasm-loader.browser.js +143 -0
  274. package/dist/wasm/wasm-loader.browser.js.map +1 -0
  275. package/dist/wasm/wasm-loader.node.d.ts +24 -0
  276. package/dist/wasm/wasm-loader.node.js +114 -0
  277. package/dist/wasm/wasm-loader.node.js.map +1 -0
  278. package/dist/wasm/worker-client.browser.d.ts +6 -0
  279. package/dist/wasm/worker-client.browser.js +21 -0
  280. package/dist/wasm/worker-client.browser.js.map +1 -0
  281. package/dist/wasm/worker-client.d.ts +34 -0
  282. package/dist/wasm/worker-client.js +160 -0
  283. package/dist/wasm/worker-client.js.map +1 -0
  284. package/dist/wasm/worker-client.node.d.ts +6 -0
  285. package/dist/wasm/worker-client.node.js +20 -0
  286. package/dist/wasm/worker-client.node.js.map +1 -0
  287. package/dist/wasm/worker-message.d.ts +61 -0
  288. package/dist/wasm/worker-message.js +2 -0
  289. package/dist/wasm/worker-message.js.map +1 -0
  290. package/dist/wasm/worker-transport.browser.d.ts +15 -0
  291. package/dist/wasm/worker-transport.browser.js +35 -0
  292. package/dist/wasm/worker-transport.browser.js.map +1 -0
  293. package/dist/wasm/worker-transport.d.ts +6 -0
  294. package/dist/wasm/worker-transport.js +2 -0
  295. package/dist/wasm/worker-transport.js.map +1 -0
  296. package/dist/wasm/worker-transport.node.d.ts +17 -0
  297. package/dist/wasm/worker-transport.node.js +39 -0
  298. package/dist/wasm/worker-transport.node.js.map +1 -0
  299. package/dist/wasm/worker.d.ts +1 -0
  300. package/dist/wasm/worker.js +69 -0
  301. package/dist/wasm/worker.js.map +1 -0
  302. package/package.json +81 -0
@@ -0,0 +1,210 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2015 The Emscripten Authors
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+
7
+ // Pthread Web Worker startup routine:
8
+ // This is the entry point file that is loaded first by each Web Worker
9
+ // that executes pthreads on the Emscripten application.
10
+
11
+ 'use strict';
12
+
13
+ var Module = {};
14
+
15
+ // Node.js support
16
+ var ENVIRONMENT_IS_NODE = typeof process == 'object' && typeof process.versions == 'object' && typeof process.versions.node == 'string';
17
+ if (ENVIRONMENT_IS_NODE) {
18
+ // Create as web-worker-like an environment as we can.
19
+
20
+ var nodeWorkerThreads = require('worker_threads');
21
+
22
+ var parentPort = nodeWorkerThreads.parentPort;
23
+
24
+ parentPort.on('message', (data) => onmessage({ data: data }));
25
+
26
+ var fs = require('fs');
27
+
28
+ Object.assign(global, {
29
+ self: global,
30
+ require: require,
31
+ Module: Module,
32
+ location: {
33
+ href: __filename
34
+ },
35
+ Worker: nodeWorkerThreads.Worker,
36
+ importScripts: function(f) {
37
+ (0, eval)(fs.readFileSync(f, 'utf8') + '//# sourceURL=' + f);
38
+ },
39
+ postMessage: function(msg) {
40
+ parentPort.postMessage(msg);
41
+ },
42
+ performance: global.performance || {
43
+ now: function() {
44
+ return Date.now();
45
+ }
46
+ },
47
+ });
48
+ }
49
+
50
+ // Thread-local guard variable for one-time init of the JS state
51
+ var initializedJS = false;
52
+
53
+ // Proxying queues that were notified before the thread started and need to be
54
+ // executed as part of startup.
55
+ var pendingNotifiedProxyingQueues = [];
56
+
57
+ function threadPrintErr() {
58
+ var text = Array.prototype.slice.call(arguments).join(' ');
59
+ // See https://github.com/emscripten-core/emscripten/issues/14804
60
+ if (ENVIRONMENT_IS_NODE) {
61
+ fs.writeSync(2, text + '\n');
62
+ return;
63
+ }
64
+ console.error(text);
65
+ }
66
+ function threadAlert() {
67
+ var text = Array.prototype.slice.call(arguments).join(' ');
68
+ postMessage({cmd: 'alert', text: text, threadId: Module['_pthread_self']()});
69
+ }
70
+ var err = threadPrintErr;
71
+ self.alert = threadAlert;
72
+
73
+ Module['instantiateWasm'] = (info, receiveInstance) => {
74
+ // Instantiate from the module posted from the main thread.
75
+ // We can just use sync instantiation in the worker.
76
+ var instance = new WebAssembly.Instance(Module['wasmModule'], info);
77
+ // TODO: Due to Closure regression https://github.com/google/closure-compiler/issues/3193,
78
+ // the above line no longer optimizes out down to the following line.
79
+ // When the regression is fixed, we can remove this if/else.
80
+ receiveInstance(instance);
81
+ // We don't need the module anymore; new threads will be spawned from the main thread.
82
+ Module['wasmModule'] = null;
83
+ return instance.exports;
84
+ }
85
+
86
+ // Turn unhandled rejected promises into errors so that the main thread will be
87
+ // notified about them.
88
+ self.onunhandledrejection = (e) => {
89
+ throw e.reason ?? e;
90
+ };
91
+
92
+ function handleMessage(e) {
93
+ try {
94
+ if (e.data.cmd === 'load') { // Preload command that is called once per worker to parse and load the Emscripten code.
95
+
96
+ // Until we initialize the runtime, queue up any further incoming messages.
97
+ let messageQueue = [];
98
+ self.onmessage = (e) => messageQueue.push(e);
99
+
100
+ // And add a callback for when the runtime is initialized.
101
+ self.startWorker = (instance) => {
102
+ Module = instance;
103
+ // Notify the main thread that this thread has loaded.
104
+ postMessage({ 'cmd': 'loaded' });
105
+ // Process any messages that were queued before the thread was ready.
106
+ for (let msg of messageQueue) {
107
+ handleMessage(msg);
108
+ }
109
+ // Restore the real message handler.
110
+ self.onmessage = handleMessage;
111
+ };
112
+
113
+ // Module and memory were sent from main thread
114
+ Module['wasmModule'] = e.data.wasmModule;
115
+
116
+ // Use `const` here to ensure that the variable is scoped only to
117
+ // that iteration, allowing safe reference from a closure.
118
+ for (const handler of e.data.handlers) {
119
+ Module[handler] = function() {
120
+ postMessage({ cmd: 'callHandler', handler, args: [...arguments] });
121
+ }
122
+ }
123
+
124
+ Module['wasmMemory'] = e.data.wasmMemory;
125
+
126
+ Module['buffer'] = Module['wasmMemory'].buffer;
127
+
128
+ Module['ENVIRONMENT_IS_PTHREAD'] = true;
129
+
130
+ if (typeof e.data.urlOrBlob == 'string') {
131
+ importScripts(e.data.urlOrBlob);
132
+ } else {
133
+ var objectUrl = URL.createObjectURL(e.data.urlOrBlob);
134
+ importScripts(objectUrl);
135
+ URL.revokeObjectURL(objectUrl);
136
+ }
137
+ fheModule(Module);
138
+ } else if (e.data.cmd === 'run') {
139
+ // Pass the thread address to wasm to store it for fast access.
140
+ Module['__emscripten_thread_init'](e.data.pthread_ptr, /*isMainBrowserThread=*/0, /*isMainRuntimeThread=*/0, /*canBlock=*/1);
141
+
142
+ // Also call inside JS module to set up the stack frame for this pthread in JS module scope
143
+ Module['establishStackSpace']();
144
+ Module['PThread'].receiveObjectTransfer(e.data);
145
+ Module['PThread'].threadInitTLS();
146
+
147
+ if (!initializedJS) {
148
+
149
+ // Execute any proxied work that came in before the thread was
150
+ // initialized. Only do this once because it is only possible for
151
+ // proxying notifications to arrive before thread initialization on
152
+ // fresh workers.
153
+ pendingNotifiedProxyingQueues.forEach(queue => {
154
+ Module['executeNotifiedProxyingQueue'](queue);
155
+ });
156
+ pendingNotifiedProxyingQueues = [];
157
+ initializedJS = true;
158
+ }
159
+
160
+ try {
161
+ Module['invokeEntryPoint'](e.data.start_routine, e.data.arg);
162
+ } catch(ex) {
163
+ if (ex != 'unwind') {
164
+ // ExitStatus not present in MINIMAL_RUNTIME
165
+ if (ex instanceof Module['ExitStatus']) {
166
+ if (Module['keepRuntimeAlive']()) {
167
+ } else {
168
+ Module['__emscripten_thread_exit'](ex.status);
169
+ }
170
+ }
171
+ else
172
+ {
173
+ // The pthread "crashed". Do not call `_emscripten_thread_exit` (which
174
+ // would make this thread joinable. Instead, re-throw the exception
175
+ // and let the top level handler propagate it back to the main thread.
176
+ throw ex;
177
+ }
178
+ }
179
+ }
180
+ } else if (e.data.cmd === 'cancel') { // Main thread is asking for a pthread_cancel() on this thread.
181
+ if (Module['_pthread_self']()) {
182
+ Module['__emscripten_thread_exit'](-1);
183
+ }
184
+ } else if (e.data.target === 'setimmediate') {
185
+ // no-op
186
+ } else if (e.data.cmd === 'processProxyingQueue') {
187
+ if (initializedJS) {
188
+ Module['executeNotifiedProxyingQueue'](e.data.queue);
189
+ } else {
190
+ // Defer executing this queue until the runtime is initialized.
191
+ pendingNotifiedProxyingQueues.push(e.data.queue);
192
+ }
193
+ } else if (e.data.cmd) {
194
+ // The received message looks like something that should be handled by this message
195
+ // handler, (since there is a e.data.cmd field present), but is not one of the
196
+ // recognized commands:
197
+ err('worker.js received unknown command ' + e.data.cmd);
198
+ err(e.data);
199
+ }
200
+ } catch(ex) {
201
+ if (Module['__emscripten_thread_crashed']) {
202
+ Module['__emscripten_thread_crashed']();
203
+ }
204
+ throw ex;
205
+ }
206
+ };
207
+
208
+ self.onmessage = handleMessage;
209
+
210
+
Binary file
@@ -0,0 +1,164 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2015 The Emscripten Authors
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+
7
+ // Pthread Web Worker startup routine:
8
+ // This is the entry point file that is loaded first by each Web Worker
9
+ // that executes pthreads on the Emscripten application.
10
+
11
+ 'use strict';
12
+
13
+ var Module = {};
14
+
15
+ // Thread-local guard variable for one-time init of the JS state
16
+ var initializedJS = false;
17
+
18
+ // Proxying queues that were notified before the thread started and need to be
19
+ // executed as part of startup.
20
+ var pendingNotifiedProxyingQueues = [];
21
+
22
+ function threadPrintErr() {
23
+ var text = Array.prototype.slice.call(arguments).join(' ');
24
+ console.error(text);
25
+ }
26
+ function threadAlert() {
27
+ var text = Array.prototype.slice.call(arguments).join(' ');
28
+ postMessage({cmd: 'alert', text: text, threadId: Module['_pthread_self']()});
29
+ }
30
+ var err = threadPrintErr;
31
+ self.alert = threadAlert;
32
+
33
+ Module['instantiateWasm'] = (info, receiveInstance) => {
34
+ // Instantiate from the module posted from the main thread.
35
+ // We can just use sync instantiation in the worker.
36
+ var instance = new WebAssembly.Instance(Module['wasmModule'], info);
37
+ // TODO: Due to Closure regression https://github.com/google/closure-compiler/issues/3193,
38
+ // the above line no longer optimizes out down to the following line.
39
+ // When the regression is fixed, we can remove this if/else.
40
+ receiveInstance(instance);
41
+ // We don't need the module anymore; new threads will be spawned from the main thread.
42
+ Module['wasmModule'] = null;
43
+ return instance.exports;
44
+ }
45
+
46
+ // Turn unhandled rejected promises into errors so that the main thread will be
47
+ // notified about them.
48
+ self.onunhandledrejection = (e) => {
49
+ throw e.reason ?? e;
50
+ };
51
+
52
+ function handleMessage(e) {
53
+ try {
54
+ if (e.data.cmd === 'load') { // Preload command that is called once per worker to parse and load the Emscripten code.
55
+
56
+ // Until we initialize the runtime, queue up any further incoming messages.
57
+ let messageQueue = [];
58
+ self.onmessage = (e) => messageQueue.push(e);
59
+
60
+ // And add a callback for when the runtime is initialized.
61
+ self.startWorker = (instance) => {
62
+ Module = instance;
63
+ // Notify the main thread that this thread has loaded.
64
+ postMessage({ 'cmd': 'loaded' });
65
+ // Process any messages that were queued before the thread was ready.
66
+ for (let msg of messageQueue) {
67
+ handleMessage(msg);
68
+ }
69
+ // Restore the real message handler.
70
+ self.onmessage = handleMessage;
71
+ };
72
+
73
+ // Module and memory were sent from main thread
74
+ Module['wasmModule'] = e.data.wasmModule;
75
+
76
+ // Use `const` here to ensure that the variable is scoped only to
77
+ // that iteration, allowing safe reference from a closure.
78
+ for (const handler of e.data.handlers) {
79
+ Module[handler] = function() {
80
+ postMessage({ cmd: 'callHandler', handler, args: [...arguments] });
81
+ }
82
+ }
83
+
84
+ Module['wasmMemory'] = e.data.wasmMemory;
85
+
86
+ Module['buffer'] = Module['wasmMemory'].buffer;
87
+
88
+ Module['ENVIRONMENT_IS_PTHREAD'] = true;
89
+
90
+ (e.data.urlOrBlob ? import(e.data.urlOrBlob) : import('./fhe-api.js'))
91
+ .then(exports => exports.default(Module));
92
+ } else if (e.data.cmd === 'run') {
93
+ // Pass the thread address to wasm to store it for fast access.
94
+ Module['__emscripten_thread_init'](e.data.pthread_ptr, /*isMainBrowserThread=*/0, /*isMainRuntimeThread=*/0, /*canBlock=*/1);
95
+
96
+ // Also call inside JS module to set up the stack frame for this pthread in JS module scope
97
+ Module['establishStackSpace']();
98
+ Module['PThread'].receiveObjectTransfer(e.data);
99
+ Module['PThread'].threadInitTLS();
100
+
101
+ if (!initializedJS) {
102
+
103
+ // Execute any proxied work that came in before the thread was
104
+ // initialized. Only do this once because it is only possible for
105
+ // proxying notifications to arrive before thread initialization on
106
+ // fresh workers.
107
+ pendingNotifiedProxyingQueues.forEach(queue => {
108
+ Module['executeNotifiedProxyingQueue'](queue);
109
+ });
110
+ pendingNotifiedProxyingQueues = [];
111
+ initializedJS = true;
112
+ }
113
+
114
+ try {
115
+ Module['invokeEntryPoint'](e.data.start_routine, e.data.arg);
116
+ } catch(ex) {
117
+ if (ex != 'unwind') {
118
+ // ExitStatus not present in MINIMAL_RUNTIME
119
+ if (ex instanceof Module['ExitStatus']) {
120
+ if (Module['keepRuntimeAlive']()) {
121
+ } else {
122
+ Module['__emscripten_thread_exit'](ex.status);
123
+ }
124
+ }
125
+ else
126
+ {
127
+ // The pthread "crashed". Do not call `_emscripten_thread_exit` (which
128
+ // would make this thread joinable. Instead, re-throw the exception
129
+ // and let the top level handler propagate it back to the main thread.
130
+ throw ex;
131
+ }
132
+ }
133
+ }
134
+ } else if (e.data.cmd === 'cancel') { // Main thread is asking for a pthread_cancel() on this thread.
135
+ if (Module['_pthread_self']()) {
136
+ Module['__emscripten_thread_exit'](-1);
137
+ }
138
+ } else if (e.data.target === 'setimmediate') {
139
+ // no-op
140
+ } else if (e.data.cmd === 'processProxyingQueue') {
141
+ if (initializedJS) {
142
+ Module['executeNotifiedProxyingQueue'](e.data.queue);
143
+ } else {
144
+ // Defer executing this queue until the runtime is initialized.
145
+ pendingNotifiedProxyingQueues.push(e.data.queue);
146
+ }
147
+ } else if (e.data.cmd) {
148
+ // The received message looks like something that should be handled by this message
149
+ // handler, (since there is a e.data.cmd field present), but is not one of the
150
+ // recognized commands:
151
+ err('worker.js received unknown command ' + e.data.cmd);
152
+ err(e.data);
153
+ }
154
+ } catch(ex) {
155
+ if (Module['__emscripten_thread_crashed']) {
156
+ Module['__emscripten_thread_crashed']();
157
+ }
158
+ throw ex;
159
+ }
160
+ };
161
+
162
+ self.onmessage = handleMessage;
163
+
164
+
@@ -0,0 +1,38 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export function wasm_combine_secret(shares: Array<any>): Uint8Array;
5
+
6
+ export function wasm_decrypt(ciphertext: Uint8Array, sk_bytes: Uint8Array): Uint8Array;
7
+
8
+ export function wasm_enc_keygen(): any;
9
+
10
+ export function wasm_encrypt(plaintext: Uint8Array, pk_bytes: Uint8Array): Uint8Array;
11
+
12
+ /**
13
+ * Signcrypt with an externally generated signature.
14
+ *
15
+ * The signature should be generated externally (e.g. wallet/HSM)
16
+ * over:
17
+ *
18
+ * keccak256(
19
+ * message || signer_address || encryption_public_key
20
+ * )
21
+ *
22
+ * The output format is:
23
+ *
24
+ * encrypted_message || signature
25
+ */
26
+ export function wasm_signcrypt_ex(msg: Uint8Array, address: Uint8Array, signature: Uint8Array, enc_key: Uint8Array): Uint8Array;
27
+
28
+ export function wasm_split_secret(secret: Uint8Array, n: number, threshold: number): any;
29
+
30
+ /**
31
+ * Decrypt and verify a signcrypted message.
32
+ *
33
+ * The signature is recovered from the ciphertext and
34
+ * the signer address is checked internally.
35
+ *
36
+ * Returns the original plaintext.
37
+ */
38
+ export function wasm_unsigncrypt(ct: Uint8Array, signer_address: Uint8Array, dec_key: Uint8Array, enc_key: Uint8Array): Uint8Array;