-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support PQC in the browser with the target wasm32-wasi now supp…
…orted (#26) * Added support for PQC with WebAssembly using target wasm32-wasi * Added a WASM.md file that explains how to compile this routine for WebAssembly * Fixed a linking error on the randombytes call when using wasm32-wasi compile target * Updated the documentation so the user knows how to setup the sysroot * Now using the WASI_SDK_DIR environment variable for the location of sysroot * Removed common.h and duplicated the include lines instead * Did some negative testing on the path change and noticed I'd missed some of the sysroot references, got them all now * Reverted a bunch of the include file updates back to the originals * Fix randombytes implementation * Fix build.rs in pqcrypto-internals for cross-compilation * Refactor pqcrypto-templates build.rs.j2 and ffi.rs.j2 * Resolved merge conflicts * Update from PQClean * Tests should now run on pull requests which will help you do code reviews * Added WASI builds to CI/CD * Fixing a typo in the WASI tests * Fixed a bug in the rust install command * The WASI tests now install the WASI SDK * Fixing some exports on the WASI tests * Added a fix so the submodules are properly pulled * Fixed some mistakes in the CI/CD * More mistakes in the CI/CD that are now fixed * Update WASM.md Co-authored-by: Thom Wiggers <[email protected]> * Update WASM.md Co-authored-by: Thom Wiggers <[email protected]> * Update WASM.md Co-authored-by: Thom Wiggers <[email protected]> * Update WASM.md Co-authored-by: Thom Wiggers <[email protected]> * CI/CD will now trigger on all pull requests rather than just to master * Removed a typo on the code blocks Co-authored-by: Thom Wiggers <[email protected]> Co-authored-by: Robin Winzler <[email protected]> Co-authored-by: Thom Wiggers <[email protected]>
- Loading branch information
1 parent
e1a156c
commit 4bc2ea4
Showing
15 changed files
with
255 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
Support for WebAssembly | ||
======================= | ||
|
||
# Summary | ||
|
||
Due to the need for a standard library to build these quantum routines it is not | ||
possible to compile them as pure no-std WASM. However by using wasi and its standard | ||
library, it becomes possible. | ||
|
||
# Steps | ||
|
||
Download the wasm32-wasi sysroot build from https://github.com/WebAssembly/wasi-sdk | ||
and set the environment variable to point to it. This example installs it globally and makes it | ||
available system-wide. You may also consider adding it to your profile's environment variables | ||
or exporting the environment variable each time manually. | ||
|
||
```sh | ||
sudo mkdir -p /opt/wasi | ||
cd /opt/wasi | ||
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sysroot-12.0.tar.gz -O /tmp/wasi-sysroot-12.0.tar.gz | ||
sudo tar -xvzf /tmp/wasi-sysroot-12.0.tar.gz | ||
rm /tmp/wasi-sysroot-12.0.tar.gz | ||
|
||
sudo tee /etc/profile.d/wasi.sh <<EOF | ||
export WASI_SDK_DIR="/opt/wasi/wasi-sysroot" | ||
EOF | ||
source /etc/profile.d/wasi.sh | ||
``` | ||
|
||
Note: While the source command brings the WASI export variables into your current | ||
terminal any new terminals will miss this until you log out and back in. | ||
|
||
You can now compile the library for linking with WebAssembly using the following | ||
command or via cargo dependencies with the same specifics. | ||
|
||
```sh | ||
cd pqcrypto | ||
cargo build --no-default-features --target wasm32-wasi --features avx2,serialization | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.