Add WIT equivalent of WITX 0.10 spec#94
Conversation
These are made to mimick the current conventions from witx. In WIT we would normally use destructors instead of close methods, but I'll keep that change for a follow-up PR. This also required removal of the opt-options and opt-symmetric key because they cant be borrowed.
|
This is great! Thank you so much for taking this on! One concern I have is that losing memory-hard key derivation support and in-place encryption/decryption would be significant regressions. Beyond performance, this will have a major impact on memory usage, requiring twice as much memory as before. That may make it difficult, or even impossible, for some existing applications to move to the new interface as-is. Given that, I think it may be better to wait for WASI 0.3 restoring caller/guest-supplied buffers before making this the new source of truth. It would also be really valuable to have at least two implementations before we treat the WIT version as authoritative. Implementing it is often the best way to find out whether the specification is actually implementable and ergonomic, especially outside of Rust. Maybe this could live in a separate branch for now? That would let us keep exploring the WIT/component-model version while allowing the documentation to stay aligned. Thanks again! This feels like a really useful step forward. |
|
My initial suggestion was mostly to get some WIT version out the door to serve as a source of truth (which I would not want to do without it being tested on at least one implementation). I agree with your observation that some of the regressions would be significant, though I would argue that these shortcomings are not uncommon in current production libraries. I'm ok though with moving it to a separate branch for now. That way I have the freedom to make the WIT API more idiomatic, without making review more difficult. Seems especially useful while I'm creating the implementation. Since having two implementations is only part of phase 3, I would prefer to focus on a Nevertheless, here is a short rundown of the runtimes I considered:
A lot of the other runtimes seem to either embed Thanks for the quick response btw! |
The following PR introduces the WIT equivalent of the WITX 0.10 specification, aiming to stick as close to the WITX 0.10 version as possible.
I hope this makes the change easier to review by allowing direct comparison to the current spec.
Closes #56
This was partially done through a quick-and-dirty transpiler I wrote using the
[witnext](https://crates.io/crates/witnext)and[wit-encoder](https://crates.io/crates/wit-encoder)crates.An overview of the changes required to move from WITX to WIT, including automatic mapping vs. manual changes, can be found in the README in the WIT directory.
Regressions when compared to the WITX version:
size: no longer backed by ausize, but au32instead.options-set-guest-buffer: not possible in WIT to provide guest memory to the host (i.e. it does not count toward the guest's memory budget anymore).list<u8>, but is marked as deprecated.symmetric-state-encrypt,symmetric-state-encrypt-detached,symmetric-state-decrypt, andsymmetric-state-decrypt-detached; the ability to encrypt in-place had to be removedversion: no longer stored in oneu64but instead as avariant._batch: these make use ofout-bufferandin-bufferwhich are not defined in the WITX files.list<u8>s instead.The interface is currently not tested on an implementation.
The syntax itself was quickly verified using
wasm-tools component wit.I'm more than happy to try and adapt the
wasi-cryptoexample implementation or try and link to another crypto library, but wanted to discuss this first.This is also the main reason why this is in draft.
If this PR lands, I propose to make this WIT specification the new source of truth.
To keep this PR manageable, I suggest handling modernizations in follow-up PRs/Zulip discussions.
Examples of this would include:
closefunctions, usingdestructors insteadI'm completely open to feedback and happy to make adjustments where needed!
My goal is to help push
wasi-cryptofurther in the standardization process for which I hope this is a good first step :)