-
Notifications
You must be signed in to change notification settings - Fork 69
support pqcrypto in wasm unknown unknown #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support pqcrypto in wasm unknown unknown #94
Conversation
thomwiggers
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, on first glance this looks pretty good. Could you please confirm the following:
- You modified the templates (which is the correct move); can you confirm you ran
generate-implementations.pyinstead of making manual changes to schemes (i.e., running that on this branch should not create a
Secondly, could you please add this to CI, so that it won't get out of date? I don't have a wasm32 build environment locally.
Yes, correct. I think it makes sense to add the step in ci confirming equality of code compared to generated one(if it's not done yet)
Should it be clippy, check, build or all three? |
|
Checking idempotency of code generation is a good idea, we don't have that yet! If you want to have a go at it, a separate PR sounds great. Let's not let it block this PR. I think building the WASM target is most important, that covers checking. I don't think there are code paths that would be hidden from clippy in the other build targets, so running Clippy is not that important — but otoh it's pretty free to add, so might as well? |
…wasm_js` and add missing `?/serialization` suffixes so `serialization` only enables indirect `serialization` features instead of enabling crates itself
|
@thomwiggers I added ci job here. #95 |
PR Description
This PR adds support for the
wasm32-unknown-unknowntarget to mostpqcrypto-*crates (ML-KEM, ML-DSA, Falcon, HQC, SPHINCS+),Motivation
Rust's
wasm32-unknown-unknowntarget is commonly used for WebAssembly applications (e.g., viawasm-bindgen). Previously,pqcryptocrates did not compile on this targetWhat this PR does
Removes the unconditional dependency on the
libccrate.Switches FFI types from
libc::c_inttocore::ffi::c_int(libc itself will reexport core according to the issue: Remove thelibcversion ofcore::ffiprimitives rust-lang/libc#4257)For the
wasm32-unknown-unknowntarget, adds a conditional dependency onwasm32-unknown-unknown-openbsd-libc = "0.2"(see https://github.com/trevyn/wasm32-unknown-unknown-openbsd-libc).Adds
build.rslogic to include the libc port's headers and link against it when targeting wasm, enabling compilation of C code in wasm.Introduces a
getrandom_wasm_jsfeature that enablesgetrandom = { features = ["wasm_js"] }.Updates templates.
Propagates the feature to the umbrella
pqcryptocrate.This allows successful compilation and execution in WASM. simple example
Usage examples
Compile a single crate: