zama-ai / tfhe-rs

TFHE-rs: A Pure Rust implementation of the TFHE Scheme for Boolean and Integer Arithmetics Over Encrypted Data.
Other
938 stars 145 forks source link

Does`tfhe` support compiled deployment on `wasm`? #1111

Open vladilen11 opened 6 months ago

vladilen11 commented 6 months ago

Does tfhe support compiled deployment on wasm? I'm trying to reference the tfhe lib in the wasm environment.

code:

tfhe = { version = "0.6.1", features = [ "boolean","shortint", "integer", "aarch64-unix"] }

build log:

  --- stderr
     Compiling getrandom v0.2.12
     Compiling concrete-csprng v0.4.0
     Compiling tfhe v0.6.1
  error: the wasm*-unknown-unknown targets are not supported by default, you may need to enable the "js" feature. For more information see: https://docs.rs/getrandom/#webassembly-support
     --> /Users/feng/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/getrandom-0.2.12/src/lib.rs:291:9
      |
  291 | /         compile_error!("the wasm*-unknown-unknown targets are not supported by \
  292 | |                         default, you may need to enable the \"js\" feature. \
  293 | |                         For more information see: \
  294 | |                         https://docs.rs/getrandom/#webassembly-support");
      | |________________________________________________________________________^

  error[E0433]: failed to resolve: use of undeclared crate or module `imp`
     --> /Users/feng/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/getrandom-0.2.12/src/lib.rs:347:9
      |
  347 |         imp::getrandom_inner(dest)?;
      |         ^^^ use of undeclared crate or module `imp`

  For more information about this error, try `rustc --explain E0433`.
  error: could not compile `getrandom` (lib) due to 2 previous errors
  warning: build failed, waiting for other jobs to finish...
  error: failed to run custom build command for `concrete-csprng v0.4.0`

  Caused by:
    process didn't exit successfully: `/Users/feng/Desktop/obelisk/substrate/substrate-node-template/target/release/wbuild/node-template-runtime/target/release/build/concrete-csprng-12ac4374190b88c7/build-script-build` (exit status: 101)
    --- stderr
    thread 'main' panicked at /Users/feng/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/concrete-csprng-0.4.0/build.rs:42:17:
    Feature `seeder_unix` requires target_family `unix`, current cfg: `wasm`
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
IceTDrinker commented 6 months ago

Hello @vladilen11

remove the aarch64-unix as wasm32 is its own target.

You will likely miss an entropy source but I don't think the wasm32 target provides one at the moment by default.

We don't support wasm32 and it's not in our roadmap see https://github.com/zama-ai/tfhe-rs/issues/1034#issuecomment-2022889357

Cheers

IceTDrinker commented 6 months ago

What is your use case btw ?

IceTDrinker commented 5 months ago

@vladilen11 could you confirm it was a feature issue for the compilation problem you are facing ?

vladilen11 commented 5 months ago

@vladilen11 could you confirm it was a feature issue for the compilation problem you are facing ?

@IceTDrinker Sorry to delay, yeah, I'm a developer from the substrate ecosystem, and I'm trying to compile the tfhe module into the substrate runtime (wasm32-unknown-unknown environment) so that tfhe's functionality is supported by the substrate chain.

As far as I know, both ICP and CosmWasm require the code to be compiled into wasm32, so I think tfhe support to wasm32 is a very important thing. 🤔

Zombieliu commented 5 months ago

Yes, I am also a multichain related developer from the ecosystem described above, and I believe that zama's support for fhe wasm could reach this large crypto developer community on a much larger scale using fhe's functionality and not just evm computation related implementations.