Status
This is a spec-aligned reference. Mojo’s standard library and crypto APIs evolve, so you should pin your toolchain and validate outputs against canonical HKEY v1 test vectors before production use.
Package contents
hkey.mojo—HotkeyEncryptionstruct with chord normalization, sequence encoding, key derivation, keystream generation, and packet emissionREADME.md— parity and usage notes
Conceptual usage
from hkey import HotkeyEncryption
fn demo() raises:
var chords = List[String]()
chords.append("Ctrl+Alt+H")
chords.append("Shift+K")
chords.append("Meta+E")
chords.append("Y")
let h = HotkeyEncryption("lab.freezer.alpha", chords)
let packet = h.encrypt("sensitive payload")
print(packet)
Parity requirements (HKEY v1)
- Normalization: modifier order
Ctrl, Alt, Shift, Metawith canonical key names. - Encoding:
SEQv1:<salt>followed by one chord fingerprint per line (UTF-8). - KDF: PBKDF2-HMAC-SHA256, 210,000 iterations, 32-byte output; subkeys via
HMAC(mk, "hkey:enc:v1")andHMAC(mk, "hkey:mac:v1"). - Keystream:
HMAC(enc_key, nonce || counter_be32)blocks XORed with plaintext. - Tag:
HMAC(mac_key, "HKEYv1" || nonce || ciphertext || uint64_be(len)).
Validation checklist
- Run fixed-nonce vectors shared with PHP/TS/Python and compare packet fields and digests.
- Confirm byte layouts (UTF-8, big-endian counters/length, base64 fields).
- Pin the Mojo toolchain and dependency versions for reproducible builds.
This reference focuses on clarity and interoperability. For production or regulated use, validate thoroughly and integrate audited cryptographic primitives as appropriate.