wasmtime-wasi-crypto

This crate enables support for the [wasi-crypto] APIs in Wasmtime.

The sole purpose of the implementation is to allow bindings and application developers to test the proposed APIs. This implementation is not meant to be used in production. Like the specification, it is currently experimental and its functionality can quickly change.

Since the [wasi-crypto] API is expected to be an optional feature of WASI, this crate is currently separate from the [wasi-common] crate.

Wasmtime integration

Use the Wasmtime APIs to instantiate a Wasm module and link the wasi-crypto modules as follows:

```rust use wasmtimewasicrypto::{ WasiCryptoAsymmetricCommon, WasiCryptoCommon, WasiCryptoCtx, WasiCryptoSignatures, WasiCryptoSymmetric, };

let cxcrypto = WasiCryptoCtx::new(); WasiCryptoCommon::new(linker.store(), cxcrypto.clone()).addtolinker(linker)?; WasiCryptoAsymmetricCommon::new(linker.store(), cxcrypto.clone()).addtolinker(linker)?; WasiCryptoSignatures::new(linker.store(), cxcrypto.clone()).addtolinker(linker)?; WasiCryptoSymmetric::new(linker.store(), cxcrypto.clone()).addto_linker(linker)?;

let wasi = wasmtimewasi::old::snapshot0::Wasi::new(linker.store(), mkcx()?); wasi.addto_linker(linker)?; ```

Building Wasmtime

Wasmtime must be compiled with the wasi-crypto feature flag (disabled by default) in order to include the crypto APIs.

Examples

Example [rust bindings] and [assemblyscript bindings] are provided to demonstrate how these APIs can be used and exposed to applications in an idiomatic way.