Argyle-Software/kyber

API Redesign & Ergonomics

mberry opened this issue · 1 comments

The current API emulates the NIST code to follow along with the standardisation process. Now that is all done we can do a proper cleanup to make it more idiomatic along with general quality of life improvements. A non-comprehensive list of to-do's:

  • Keypair with no visible fields
  • Remove redundant public key field from Keypair
  • Runtime public key function to extract from secret key
  • Generate new Keypair struct from existing private key
  • Generate new Keypair struct from 64 byte seed
  • Encapsulation/Decapsulation function arguments accepting impl AsRef<PublicKey> / impl AsRef<SecretKey>
  • Keypair - impl Hash - For public key only, non-cryptographic hashes often used
  • Keypair - impl Debug - For public key only, elide secret key from any possible logging
  • Keypair - impl PartialEq - For public key only, make note in docs that it is not constant time
  • Keypair - impl Eq
  • Keypair - impl Zeroize - will require an alternative api using Pin/ Box along with documentation. Needs a locally instantiated SecretBuffer by the end user to prevent return value optimisations copying everything willynilly.
  • Replace type alias for SharedSecret with a concrete type, implement the same traits as for Keypair above.

Related to #59, it's preferable to get this all wrapped up into one release.

Quite a few of these already exist in the draft PR here: #67