KMS.AsymmetricCrypto (kms v0.1.0)

Copy Markdown View Source

Small ECDH envelope helper.

Keys are raw elliptic-curve key material encoded with Base64. Payload encryption uses KMS.Crypto with a key derived from the ECDH shared secret.

Envelopes derive AES-GCM keys with HKDF-style context binding. :key_size (or :symmetric_key_size) may be 16, 24, or 32 bytes and defaults to 16 bytes for compatibility. :info should identify the caller's envelope purpose and stable resource context.

The default :legacy KDF is preserved for existing envelopes. Callers may opt in to kdf: :hpke_labeled for RFC 9180-inspired labeled extract/expand domain separation. This is HPKE-aligned ECDH envelope encryption, not a complete RFC 9180 HPKE implementation.

Summary

Functions

decrypt_with_private_key(ciphertext, peer_public_key, private_key, opts \\ [])

derive_public_key(private_key, curve \\ :prime256v1)

encrypt_for_public_key(plaintext, public_key, opts \\ [])

generate_keypair(curve \\ :prime256v1)

generate_private_key(curve \\ :prime256v1)

supported_curves()