Reduce TCB, compiled artifact size, compilation speed

This documents ways to reduce the TCB and compiled artifact size, and tracks a few leads.

Dependencies

  • Use fewer
  • Avoid duplicates in the build tree (see Cargo.lock, or cargo tree)
  • Replace dependencies with similar ones that are already in our build tree
    • replace xxhash with ahash (see #1074)
    • memsec with zeroize (+ sth for the constant time comparisons)
    • replace sha2 with provided implementation (see pgp-cert-d#52)
  • make features (and dependencies) optional

Code size

  • Reduce opportunities for monomorphization:
    • Don't make arguments compile-time polymorphic
    • Exception: small public functions for ergonomics, implementation should be an internal function which only uses concrete types
  • Reduce code duplication
  • Reduce code duplication caused by the use of macros

Useful tools

  • cargo tree
  • cargo bloat