Skip to content

Proposing a host call

The host API is small on purpose: every call is a promise kept for every codec, forever. A new one is welcome when it is:

Pure Deterministic, no I/O, clock, storage or network
A named standard An algorithm or format with a specification: X25519 (RFC 7748), ChaCha20-Poly1305 (RFC 8439), DEFLATE (RFC 1951)
Expensive in the sandbox Too slow or too large to carry in every codec as JavaScript
Testable The standard’s own test vectors exist

Something that fails the last two (a byte reader, a protocol’s framing) belongs in a library, which anyone can publish today.

Open a host call proposal:

  • the call as a codec would use it, pulzr.ecdh('x25519', priv, peerPub);
  • the standard, by name and section;
  • the device and the use case: what it does, and why plain JavaScript will not do (too slow for the 50 ms budget, too large to carry);
  • test vectors from the standard.

Say whether you will write it or would like the maintainers to.

A pull request:

  1. adds the import to src/host.rs under a new call or algorithm number; numbers are never reused, and a call never changes in place;
  2. adds the JavaScript binding to engine/js/prelude.js, and the Rust one to pulzr-codec-sdk if native codecs need it;
  3. adds the standard’s vectors to tests/vectors.rs, citing their section;
  4. documents it on the host API page and in the README’s table.

A host without the call answers -1 for its number, and a native module that imports it is refused there, so a codec can tell what it runs on.