multi-party-sig icon indicating copy to clipboard operation
multi-party-sig copied to clipboard

docs: how to run in web assembly

Open davidp94 opened this issue 4 years ago • 2 comments

Is this project wasm compatible?

davidp94 avatar Jul 15 '21 09:07 davidp94

I was able to get the example to run in a browser, using this compile command

GOOS=js GOARCH=wasm go build -o main.wasm -tags math_big_pure_go *.go

But wow is it slow. On my i9 MacBook Pro the example took about 10min to complete. Best to run it in a worker to get it off the main thread. Obviously it would be faster if each party was running in its own thread, but that is an experiment for another day.

johnthethird avatar Jul 30 '21 17:07 johnthethird

Thank you @johnthethird for reporting these results! The example was designed to show the user how the library can be implemented, and as you mentioned, does not reflect a real world scenario.

Unfortunately, I've never experimented with WASM before, so it might be a while before we start officially supporting it. But as we continue to optimize the code, things should get faster in the WASM world as well.

I think one issue that definitely needs investigating is the use of specialized assembly for safenum. Since modular exponentiations of safenum.Nat is currently one of the main bottlenecks, this might be an easy way of speeding things up.

adr1anh avatar Jul 31 '21 09:07 adr1anh