tfhe 0.7.2 → 0.7.4
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tfhe",
|
|
3
3
|
"description": "TFHE-rs is a fully homomorphic encryption (FHE) library that implements Zama's variant of TFHE.",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.4",
|
|
5
5
|
"license": "BSD-3-Clause-Clear",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"files": [
|
|
11
11
|
"tfhe_bg.wasm",
|
|
12
12
|
"tfhe.js",
|
|
13
|
-
"tfhe.d.ts"
|
|
13
|
+
"tfhe.d.ts",
|
|
14
|
+
"snippets"
|
|
14
15
|
],
|
|
15
16
|
"module": "tfhe.js",
|
|
16
17
|
"homepage": "https://zama.ai/",
|
|
@@ -25,4 +26,4 @@
|
|
|
25
26
|
"fhe",
|
|
26
27
|
"cryptography"
|
|
27
28
|
]
|
|
28
|
-
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2022 Google Inc. All Rights Reserved.
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
* See the License for the specific language governing permissions and
|
|
11
|
+
* limitations under the License.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
// Note: this is never used, but necessary to prevent a bug in Firefox
|
|
15
|
+
// (https://bugzilla.mozilla.org/show_bug.cgi?id=1702191) where it collects
|
|
16
|
+
// Web Workers that have a shared WebAssembly memory with the main thread,
|
|
17
|
+
// but are not explicitly rooted via a `Worker` instance.
|
|
18
|
+
//
|
|
19
|
+
// By storing them in a variable, we can keep `Worker` objects around and
|
|
20
|
+
// prevent them from getting GC-d.
|
|
21
|
+
let _workers;
|
|
22
|
+
|
|
23
|
+
export async function startWorkers(module, memory, builder) {
|
|
24
|
+
if (builder.numThreads() === 0) {
|
|
25
|
+
throw new Error(`num_threads must be > 0.`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const workerInit = {
|
|
29
|
+
module,
|
|
30
|
+
memory,
|
|
31
|
+
receiver: builder.receiver()
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
_workers = await Promise.all(
|
|
35
|
+
Array.from({ length: builder.numThreads() }, async () => {
|
|
36
|
+
// Self-spawn into a new Worker.
|
|
37
|
+
//
|
|
38
|
+
// TODO: while `new URL('...', import.meta.url) becomes a semi-standard
|
|
39
|
+
// way to get asset URLs relative to the module across various bundlers
|
|
40
|
+
// and browser, ideally we should switch to `import.meta.resolve`
|
|
41
|
+
// once it becomes a standard.
|
|
42
|
+
const worker = new Worker(
|
|
43
|
+
new URL('./workerHelpers.worker.js', import.meta.url),
|
|
44
|
+
{
|
|
45
|
+
type: 'module'
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
worker.postMessage(workerInit);
|
|
49
|
+
await new Promise(resolve =>
|
|
50
|
+
worker.addEventListener('message', resolve, { once: true })
|
|
51
|
+
);
|
|
52
|
+
return worker;
|
|
53
|
+
})
|
|
54
|
+
);
|
|
55
|
+
builder.build();
|
|
56
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2022 Google Inc. All Rights Reserved.
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
* See the License for the specific language governing permissions and
|
|
11
|
+
* limitations under the License.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
// Note: our JS should have been generated in
|
|
15
|
+
// `[out-dir]/snippets/wasm-bindgen-rayon-[hash]/workerHelpers.worker.js`,
|
|
16
|
+
// resolve the main module via `../../..`.
|
|
17
|
+
//
|
|
18
|
+
// This might need updating if the generated structure changes on wasm-bindgen
|
|
19
|
+
// side ever in the future, but works well with bundlers today. The whole
|
|
20
|
+
// point of this crate, after all, is to abstract away unstable features
|
|
21
|
+
// and temporary bugs so that you don't need to deal with them in your code.
|
|
22
|
+
import initWbg, { wbg_rayon_start_worker } from '../../../';
|
|
23
|
+
|
|
24
|
+
onmessage = async ({ data: { module, memory, receiver } }) => {
|
|
25
|
+
await initWbg(module, memory);
|
|
26
|
+
postMessage(true);
|
|
27
|
+
wbg_rayon_start_worker(receiver);
|
|
28
|
+
};
|