taurushq-io / multi-party-sig

Implementation of protocols for threshold signatures
Apache License 2.0
311 stars 120 forks source link

docs: how to run in web assembly #14

Closed davidp94 closed 1 year ago

davidp94 commented 3 years ago

Is this project wasm compatible?

johnthethird commented 3 years ago

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.

adr1anh commented 3 years ago

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.