dfns / cggmp21

State-of-art threshold ECDSA in Rust
Apache License 2.0
41 stars 6 forks source link

Support for wasm32-unknown-unknown #73

Open tmpfs opened 5 months ago

tmpfs commented 5 months ago

Hi @survived,

I am looking into using this in a webassembly context, currently the build fails due to gmp-mpfr-sys:

error: failed to run custom build command for `gmp-mpfr-sys v1.6.1`

Caused by:
  process didn't exit successfully: `/Users/muji/git/forks/cggmp21/target/debug/build/gmp-mpfr-sys-18f237700e2fce47/build-script-build` (exit status: 101)
  --- stderr
  thread 'main' panicked at /Users/muji/.cargo/registry/src/index.crates.io-6f17d22bba15001f/gmp-mpfr-sys-1.6.1/build.rs:105:9:
  Cross compilation from aarch64-apple-darwin to wasm32-unknown-unknown not supported! Use the `force-cross` feature to cross compile anyway.
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

Has anyone tried with the force-cross feature for wasm32-unknown-unknown? Is it known to work?

Or would it be better to use a different GMP implementation for WASM behind a feature flag? Are you interested in supporting the wasm32-unknown-unknown target?

survived commented 5 months ago

We are interested in adding wasm32-unknown-unknown support, but rug library to my knowledge does not support it. I think it's the only blocker, so whenever rug becomes wasm-friendly, we'll do too. See gmp-mpfr-sys#18

survived commented 5 months ago

However, we do not consider changing big numbers library, or adding another one behind feature flag. It seems to be a big change.

shekohex commented 4 months ago

However, we do not consider changing big numbers library, or adding another one behind feature flag. It seems to be a big change.

One of the libs that could be the one here is https://crates.io/crates/malachite, https://github.com/mhogrefe/malachite, it is fully no_std by default.

survived commented 4 months ago

It does look nice, but rug and this one expose different interfaces, so it'll be difficult to unify them (especially, unify them in the way so we can still benefit from optimizations in each backend).