@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.
- package/README.md +198 -0
- package/dist/abis/acl.abi.d.ts +379 -0
- package/dist/abis/acl.abi.js +495 -0
- package/dist/abis/acl.abi.js.map +1 -0
- package/dist/abis/alphatrion_reward.abi.d.ts +407 -0
- package/dist/abis/alphatrion_reward.abi.js +532 -0
- package/dist/abis/alphatrion_reward.abi.js.map +1 -0
- package/dist/abis/ciphertext_digests.abi.d.ts +336 -0
- package/dist/abis/ciphertext_digests.abi.js +444 -0
- package/dist/abis/ciphertext_digests.abi.js.map +1 -0
- package/dist/abis/ciphertext_verification.abi.d.ts +637 -0
- package/dist/abis/ciphertext_verification.abi.js +830 -0
- package/dist/abis/ciphertext_verification.abi.js.map +1 -0
- package/dist/abis/convert_token.abi.d.ts +922 -0
- package/dist/abis/convert_token.abi.js +1208 -0
- package/dist/abis/convert_token.abi.js.map +1 -0
- package/dist/abis/decryption.abi.d.ts +956 -0
- package/dist/abis/decryption.abi.js +1244 -0
- package/dist/abis/decryption.abi.js.map +1 -0
- package/dist/abis/erc20.abi.d.ts +265 -0
- package/dist/abis/erc20.abi.js +350 -0
- package/dist/abis/erc20.abi.js.map +1 -0
- package/dist/abis/fhe_executor.abi.d.ts +1535 -0
- package/dist/abis/fhe_executor.abi.js +1962 -0
- package/dist/abis/fhe_executor.abi.js.map +1 -0
- package/dist/abis/space_bridge_config.abi.d.ts +792 -0
- package/dist/abis/space_bridge_config.abi.js +1032 -0
- package/dist/abis/space_bridge_config.abi.js.map +1 -0
- package/dist/abis/token.abi.d.ts +630 -0
- package/dist/abis/token.abi.js +828 -0
- package/dist/abis/token.abi.js.map +1 -0
- package/dist/cli/eusdc.d.ts +2 -0
- package/dist/cli/eusdc.js +41 -0
- package/dist/cli/eusdc.js.map +1 -0
- package/dist/contract/callbacks.d.ts +59 -0
- package/dist/contract/callbacks.js +2 -0
- package/dist/contract/callbacks.js.map +1 -0
- package/dist/contract/convert-token.d.ts +107 -0
- package/dist/contract/convert-token.js +249 -0
- package/dist/contract/convert-token.js.map +1 -0
- package/dist/contract/token.d.ts +167 -0
- package/dist/contract/token.js +404 -0
- package/dist/contract/token.js.map +1 -0
- package/dist/contract/transaction.d.ts +29 -0
- package/dist/contract/transaction.js +2 -0
- package/dist/contract/transaction.js.map +1 -0
- package/dist/core/address.d.ts +118 -0
- package/dist/core/address.js +200 -0
- package/dist/core/address.js.map +1 -0
- package/dist/core/auth.d.ts +68 -0
- package/dist/core/auth.js +58 -0
- package/dist/core/auth.js.map +1 -0
- package/dist/core/bytes.d.ts +48 -0
- package/dist/core/bytes.js +117 -0
- package/dist/core/bytes.js.map +1 -0
- package/dist/core/cache-manager.d.ts +138 -0
- package/dist/core/cache-manager.js +440 -0
- package/dist/core/cache-manager.js.map +1 -0
- package/dist/core/chain.d.ts +41 -0
- package/dist/core/chain.js +59 -0
- package/dist/core/chain.js.map +1 -0
- package/dist/core/constants.d.ts +24 -0
- package/dist/core/constants.js +25 -0
- package/dist/core/constants.js.map +1 -0
- package/dist/core/error.d.ts +2 -0
- package/dist/core/error.js +14 -0
- package/dist/core/error.js.map +1 -0
- package/dist/core/errors/error-catalog.d.ts +29 -0
- package/dist/core/errors/error-catalog.js +84 -0
- package/dist/core/errors/error-catalog.js.map +1 -0
- package/dist/core/errors/error-codes.d.ts +52 -0
- package/dist/core/errors/error-codes.js +61 -0
- package/dist/core/errors/error-codes.js.map +1 -0
- package/dist/core/errors/error-utils.d.ts +27 -0
- package/dist/core/errors/error-utils.js +110 -0
- package/dist/core/errors/error-utils.js.map +1 -0
- package/dist/core/errors/fhe-error.d.ts +98 -0
- package/dist/core/errors/fhe-error.js +190 -0
- package/dist/core/errors/fhe-error.js.map +1 -0
- package/dist/core/errors/index.d.ts +4 -0
- package/dist/core/errors/index.js +5 -0
- package/dist/core/errors/index.js.map +1 -0
- package/dist/core/estimate.d.ts +39 -0
- package/dist/core/estimate.js +111 -0
- package/dist/core/estimate.js.map +1 -0
- package/dist/core/event.d.ts +212 -0
- package/dist/core/event.js +42 -0
- package/dist/core/event.js.map +1 -0
- package/dist/core/fhe-type.d.ts +75 -0
- package/dist/core/fhe-type.js +115 -0
- package/dist/core/fhe-type.js.map +1 -0
- package/dist/core/fhe.d.ts +11 -0
- package/dist/core/fhe.js +23 -0
- package/dist/core/fhe.js.map +1 -0
- package/dist/core/handle.d.ts +42 -0
- package/dist/core/handle.js +99 -0
- package/dist/core/handle.js.map +1 -0
- package/dist/core/json-utils.d.ts +18 -0
- package/dist/core/json-utils.js +37 -0
- package/dist/core/json-utils.js.map +1 -0
- package/dist/core/kms.d.ts +42 -0
- package/dist/core/kms.js +70 -0
- package/dist/core/kms.js.map +1 -0
- package/dist/core/logger.d.ts +3 -0
- package/dist/core/logger.js +11 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/pretty-print.d.ts +18 -0
- package/dist/core/pretty-print.js +84 -0
- package/dist/core/pretty-print.js.map +1 -0
- package/dist/core/primitives.d.ts +22 -0
- package/dist/core/primitives.js +2 -0
- package/dist/core/primitives.js.map +1 -0
- package/dist/core/retryable-handler.d.ts +74 -0
- package/dist/core/retryable-handler.js +227 -0
- package/dist/core/retryable-handler.js.map +1 -0
- package/dist/core/signer-address-info.d.ts +15 -0
- package/dist/core/signer-address-info.js +33 -0
- package/dist/core/signer-address-info.js.map +1 -0
- package/dist/core/string.d.ts +28 -0
- package/dist/core/string.js +33 -0
- package/dist/core/string.js.map +1 -0
- package/dist/core/swallow.d.ts +23 -0
- package/dist/core/swallow.js +37 -0
- package/dist/core/swallow.js.map +1 -0
- package/dist/core/system-contract-info.d.ts +17 -0
- package/dist/core/system-contract-info.js +41 -0
- package/dist/core/system-contract-info.js.map +1 -0
- package/dist/core/ttl-cache.d.ts +81 -0
- package/dist/core/ttl-cache.js +113 -0
- package/dist/core/ttl-cache.js.map +1 -0
- package/dist/core/tx-error-parser.d.ts +40 -0
- package/dist/core/tx-error-parser.js +83 -0
- package/dist/core/tx-error-parser.js.map +1 -0
- package/dist/core/utils.d.ts +62 -0
- package/dist/core/utils.js +143 -0
- package/dist/core/utils.js.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/jazz/encrypt-key-p.d.ts +65 -0
- package/dist/jazz/encrypt-key-p.js +283 -0
- package/dist/jazz/encrypt-key-p.js.map +1 -0
- package/dist/jazz/encrypt-p.d.ts +82 -0
- package/dist/jazz/encrypt-p.js +139 -0
- package/dist/jazz/encrypt-p.js.map +1 -0
- package/dist/jazz/encrypt.d.ts +58 -0
- package/dist/jazz/encrypt.js +155 -0
- package/dist/jazz/encrypt.js.map +1 -0
- package/dist/jazz/input-proof-p.d.ts +122 -0
- package/dist/jazz/input-proof-p.js +265 -0
- package/dist/jazz/input-proof-p.js.map +1 -0
- package/dist/jazz/jazz-client-i.d.ts +16 -0
- package/dist/jazz/jazz-client-i.js +2 -0
- package/dist/jazz/jazz-client-i.js.map +1 -0
- package/dist/jazz/jazz-client.d.ts +18 -0
- package/dist/jazz/jazz-client.js +24 -0
- package/dist/jazz/jazz-client.js.map +1 -0
- package/dist/jazz/key-pair.d.ts +50 -0
- package/dist/jazz/key-pair.js +166 -0
- package/dist/jazz/key-pair.js.map +1 -0
- package/dist/jazz/mock/fake.d.ts +3 -0
- package/dist/jazz/mock/fake.js +23 -0
- package/dist/jazz/mock/fake.js.map +1 -0
- package/dist/jazz/mock/fetch-input-proof.d.ts +4 -0
- package/dist/jazz/mock/fetch-input-proof.js +63 -0
- package/dist/jazz/mock/fetch-input-proof.js.map +1 -0
- package/dist/jazz/mock/fetch-key-url.d.ts +3 -0
- package/dist/jazz/mock/fetch-key-url.js +15 -0
- package/dist/jazz/mock/fetch-key-url.js.map +1 -0
- package/dist/jazz/mock/fetch-public-decrypt.d.ts +3 -0
- package/dist/jazz/mock/fetch-public-decrypt.js +81 -0
- package/dist/jazz/mock/fetch-public-decrypt.js.map +1 -0
- package/dist/jazz/mock/fetch-user-decrypt.d.ts +4 -0
- package/dist/jazz/mock/fetch-user-decrypt.js +174 -0
- package/dist/jazz/mock/fetch-user-decrypt.js.map +1 -0
- package/dist/jazz/module/fetch-input-proof.d.ts +19 -0
- package/dist/jazz/module/fetch-input-proof.js +72 -0
- package/dist/jazz/module/fetch-input-proof.js.map +1 -0
- package/dist/jazz/module/fetch-key-url.d.ts +17 -0
- package/dist/jazz/module/fetch-key-url.js +46 -0
- package/dist/jazz/module/fetch-key-url.js.map +1 -0
- package/dist/jazz/module/fetch-public-decrypt.d.ts +19 -0
- package/dist/jazz/module/fetch-public-decrypt.js +65 -0
- package/dist/jazz/module/fetch-public-decrypt.js.map +1 -0
- package/dist/jazz/module/fetch-user-decrypt.d.ts +19 -0
- package/dist/jazz/module/fetch-user-decrypt.js +109 -0
- package/dist/jazz/module/fetch-user-decrypt.js.map +1 -0
- package/dist/jazz/module/jazz-async-request.d.ts +102 -0
- package/dist/jazz/module/jazz-async-request.js +515 -0
- package/dist/jazz/module/jazz-async-request.js.map +1 -0
- package/dist/jazz/module/jazz-p.d.ts +61 -0
- package/dist/jazz/module/jazz-p.js +33 -0
- package/dist/jazz/module/jazz-p.js.map +1 -0
- package/dist/jazz/module/s3-download.d.ts +85 -0
- package/dist/jazz/module/s3-download.js +293 -0
- package/dist/jazz/module/s3-download.js.map +1 -0
- package/dist/jazz/permit.d.ts +200 -0
- package/dist/jazz/permit.js +319 -0
- package/dist/jazz/permit.js.map +1 -0
- package/dist/jazz/public-decrypt-p.d.ts +96 -0
- package/dist/jazz/public-decrypt-p.js +258 -0
- package/dist/jazz/public-decrypt-p.js.map +1 -0
- package/dist/jazz/public-decrypt.d.ts +48 -0
- package/dist/jazz/public-decrypt.js +156 -0
- package/dist/jazz/public-decrypt.js.map +1 -0
- package/dist/jazz/read-contract.d.ts +81 -0
- package/dist/jazz/read-contract.js +125 -0
- package/dist/jazz/read-contract.js.map +1 -0
- package/dist/jazz/types/common.d.ts +17 -0
- package/dist/jazz/types/common.js +2 -0
- package/dist/jazz/types/common.js.map +1 -0
- package/dist/jazz/types/input-proof.d.ts +76 -0
- package/dist/jazz/types/input-proof.js +2 -0
- package/dist/jazz/types/input-proof.js.map +1 -0
- package/dist/jazz/types/key-url.d.ts +68 -0
- package/dist/jazz/types/key-url.js +5 -0
- package/dist/jazz/types/key-url.js.map +1 -0
- package/dist/jazz/types/public-decrypt.d.ts +61 -0
- package/dist/jazz/types/public-decrypt.js +2 -0
- package/dist/jazz/types/public-decrypt.js.map +1 -0
- package/dist/jazz/types/user-decrypt.d.ts +123 -0
- package/dist/jazz/types/user-decrypt.js +2 -0
- package/dist/jazz/types/user-decrypt.js.map +1 -0
- package/dist/jazz/user-decrypt-p.d.ts +111 -0
- package/dist/jazz/user-decrypt-p.js +280 -0
- package/dist/jazz/user-decrypt-p.js.map +1 -0
- package/dist/jazz/user-decrypt.d.ts +74 -0
- package/dist/jazz/user-decrypt.js +143 -0
- package/dist/jazz/user-decrypt.js.map +1 -0
- package/dist/native/fhe-api.js +5959 -0
- package/dist/native/fhe-api.node.cjs +6167 -0
- package/dist/native/fhe-api.node.worker.cjs +210 -0
- package/dist/native/fhe-api.wasm +0 -0
- package/dist/native/fhe-api.worker.js +164 -0
- package/dist/native/kms/node/kms_lib.d.ts +38 -0
- package/dist/native/kms/node/kms_lib.js +356 -0
- package/dist/native/kms/node/kms_lib_bg.wasm +0 -0
- package/dist/native/kms/node/kms_lib_bg.wasm.d.ts +21 -0
- package/dist/native/kms/node/package.json +11 -0
- package/dist/native/kms/web/kms_lib.d.ts +84 -0
- package/dist/native/kms/web/kms_lib.js +443 -0
- package/dist/native/kms/web/kms_lib_bg.wasm +0 -0
- package/dist/native/kms/web/kms_lib_bg.wasm.d.ts +21 -0
- package/dist/native/kms/web/package.json +15 -0
- package/dist/runtime/browser.d.ts +36 -0
- package/dist/runtime/browser.js +115 -0
- package/dist/runtime/browser.js.map +1 -0
- package/dist/runtime/node.d.ts +30 -0
- package/dist/runtime/node.js +95 -0
- package/dist/runtime/node.js.map +1 -0
- package/dist/sdk/fhetransform-sdk-b.d.ts +102 -0
- package/dist/sdk/fhetransform-sdk-b.js +294 -0
- package/dist/sdk/fhetransform-sdk-b.js.map +1 -0
- package/dist/sdk/fhetransform-sdk.d.ts +87 -0
- package/dist/sdk/fhetransform-sdk.js +135 -0
- package/dist/sdk/fhetransform-sdk.js.map +1 -0
- package/dist/sdk/jazz-service.d.ts +13 -0
- package/dist/sdk/jazz-service.js +58 -0
- package/dist/sdk/jazz-service.js.map +1 -0
- package/dist/sdk/permit-service.d.ts +45 -0
- package/dist/sdk/permit-service.js +144 -0
- package/dist/sdk/permit-service.js.map +1 -0
- package/dist/wasm/fhe-wasm-client.d.ts +19 -0
- package/dist/wasm/fhe-wasm-client.js +23 -0
- package/dist/wasm/fhe-wasm-client.js.map +1 -0
- package/dist/wasm/fhe-wasm-module.d.ts +24 -0
- package/dist/wasm/fhe-wasm-module.js +141 -0
- package/dist/wasm/fhe-wasm-module.js.map +1 -0
- package/dist/wasm/fhe-wasm-type.d.ts +59 -0
- package/dist/wasm/fhe-wasm-type.js +244 -0
- package/dist/wasm/fhe-wasm-type.js.map +1 -0
- package/dist/wasm/wasm-loader.browser.d.ts +21 -0
- package/dist/wasm/wasm-loader.browser.js +143 -0
- package/dist/wasm/wasm-loader.browser.js.map +1 -0
- package/dist/wasm/wasm-loader.node.d.ts +24 -0
- package/dist/wasm/wasm-loader.node.js +114 -0
- package/dist/wasm/wasm-loader.node.js.map +1 -0
- package/dist/wasm/worker-client.browser.d.ts +6 -0
- package/dist/wasm/worker-client.browser.js +21 -0
- package/dist/wasm/worker-client.browser.js.map +1 -0
- package/dist/wasm/worker-client.d.ts +34 -0
- package/dist/wasm/worker-client.js +160 -0
- package/dist/wasm/worker-client.js.map +1 -0
- package/dist/wasm/worker-client.node.d.ts +6 -0
- package/dist/wasm/worker-client.node.js +20 -0
- package/dist/wasm/worker-client.node.js.map +1 -0
- package/dist/wasm/worker-message.d.ts +61 -0
- package/dist/wasm/worker-message.js +2 -0
- package/dist/wasm/worker-message.js.map +1 -0
- package/dist/wasm/worker-transport.browser.d.ts +15 -0
- package/dist/wasm/worker-transport.browser.js +35 -0
- package/dist/wasm/worker-transport.browser.js.map +1 -0
- package/dist/wasm/worker-transport.d.ts +6 -0
- package/dist/wasm/worker-transport.js +2 -0
- package/dist/wasm/worker-transport.js.map +1 -0
- package/dist/wasm/worker-transport.node.d.ts +17 -0
- package/dist/wasm/worker-transport.node.js +39 -0
- package/dist/wasm/worker-transport.node.js.map +1 -0
- package/dist/wasm/worker.d.ts +1 -0
- package/dist/wasm/worker.js +69 -0
- package/dist/wasm/worker.js.map +1 -0
- 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;
|