libcrux icon indicating copy to clipboard operation
libcrux copied to clipboard

Compilation to wasm

Open bshvass opened this issue 1 year ago • 7 comments

Compilation to wasm does not seem to work. I've tried on several machines and with several commands. The wasm job also seems to have been skipped in recent commits.

Running the command

cargo build --features wasm --target wasm32-unknown-unknown

fails with

fatal error: 'string.h' file not found

when compiling the files in sys/hacl/c.

Running the command

CC=emcc AR=emar cargo build --features wasm --target wasm32-unknown-unknown

fails with

emcc: error: unsupported target: wasm32-unknown-unknown (emcc only supports wasm64-unknown-emscripten and wasm32-unknown-emscripten)

Trying with the wasm32-unknown-emscripten target simply freezes.

I get similar errors when I try to compile independent packages, which have libcrux as dependency, to wasm.

I'm not sure what else to try to get things to compile, but I suspect the issue with the Emscripten compilation. What is needed to get this working again?

bshvass avatar Mar 20 '24 13:03 bshvass

WASM support is currently pretty limited because a lot of the underlying C code uses raw 64-bit pointers. We work on integrating a Rust version directly for the legacy C code (see https://github.com/hacl-star/hacl-star/pull/918). But this is work in progress.

Are you interested in a specific algorithm? We could see if we can expose that in the current version.

franziskuskiefer avatar Apr 04 '24 10:04 franziskuskiefer

I was trying to run HMAC compiled to wasm (cf. this pull request)

bshvass avatar Apr 04 '24 11:04 bshvass

I think we could make hmac work, SHA2 should be fine. Do you want to take a stab at it? I'm happy to review or give you more concrete pointer if needed.

franziskuskiefer avatar Apr 08 '24 06:04 franziskuskiefer

@bshvass this is related to getting the bigints to work in rust https://github.com/RustCrypto/crypto-bigint/issues/577#issuecomment-2016550215

spitters avatar Apr 08 '24 08:04 spitters

@bshvass What is the status of this?

spitters avatar May 07 '24 10:05 spitters

I haven't had time to look at it yet, but might have some time soon. @franziskuskiefer, I can take a stab at it; did you have any concrete pointers?

bshvass avatar May 07 '24 13:05 bshvass

@bshvass we should probably try with hacl-rs (including hmac and bignum), as it would compile to wasm.

spitters avatar Jul 23 '24 07:07 spitters

This issue has been marked as stale due to a lack of activity for 60 days. If you believe this issue is still relevant, please provide an update or comment to keep it open. Otherwise, it will be closed in 7 days.

github-actions[bot] avatar Sep 22 '24 02:09 github-actions[bot]

This issue has been closed due to a lack of activity since being marked as stale. If you believe this issue is still relevant, please reopen it with an update or comment.

github-actions[bot] avatar Sep 29 '24 02:09 github-actions[bot]