-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ZK-559: Add wasm implementation for CryptoClient #80
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I have to say in Polish "kawał dobrej roboty", somehow similar phrases in English don't sound the same. Just a few small comments to clarify.
// 1. Our proxy returns the hasher object directly from the worker | ||
// 2. Comlink then wraps hasher's methods for cross-thread communication | ||
// This way, only method calls are transferred between threads, not entire objects. | ||
const exposed = new Proxy(wasmClientWorker, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, this improves the worker interface a lot, we're not forced to do everything through worker methods anymore, awesome!
@@ -0,0 +1,39 @@ | |||
import * as singleThreadedWasm from "shielder-wasm/web-singlethreaded"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really happy to get rid of all these blocks
constructor(caller: Caller) {
this.caller = caller;
if (caller == "web_singlethreaded") {
this.wasmModule = singleThreadedWasm;
} else if (caller == "web_multithreaded") {
this.wasmModule = multiThreadedWasm;
} else {
throw new Error("Invalid caller");
}
}
!
This pull request includes a new package
shielder-sdk-crypto-wasm
which is basically a standalone/crypto
module fromshielder-sdk
, implementingCryptoClient
interface for WASM web target.Main Changes
Most of the code is similar to
/crypto
module, however:src/utils/wasmModuleLoader.ts
base classes to reduce a lot of code duplications/src/wasmClientWorker.ts
and/src/wasmClient.ts
Vite Patch
During the extension build with WXT framework (which uses vite under the hood) it was found out that
shielder-sdk
didn't properly bundle:To adress this issue I added
./vite
,./wasm_singlethreaded
and./wasm_multithreaded
entrypoints in package, which would allow to use the vite distribution, which is basically the original distribution with vite-suggested WebWorkers declaration (as currently used in extension). The usage is documented in README.md