# HeroCrypt Technical Specifications This document provides the low-level technical details for the HeroCrypt library, including the underlying Redis commands used to interact with HeroDB's AGE cryptography features. ## Communication Protocol HeroCrypt communicates with HeroDB using the standard Redis protocol. All commands are sent as RESP (Redis Serialization Protocol) arrays. ## Stateless (Ephemeral) AGE Operations These commands are used when the client manages its own keys. ### Encryption - **`AGE GENENC`**: Generates an ephemeral encryption keypair. - **Returns**: An array containing the recipient (public key) and the identity (secret key). - **`AGE ENCRYPT `**: Encrypts a message using the recipient's public key. - **``**: The public key (`age1...`). - **``**: The plaintext message to encrypt. - **Returns**: A base64-encoded ciphertext. - **`AGE DECRYPT `**: Decrypts a ciphertext using the identity (secret key). - **``**: The secret key (`AGE-SECRET-KEY-1...`). - **``**: The base64-encoded ciphertext. - **Returns**: The decrypted plaintext message. ### Signing - **`AGE GENSIGN`**: Generates an ephemeral signing keypair. - **Returns**: An array containing the public verification key (base64) and the secret signing key (base64). - **`AGE SIGN `**: Signs a message with the secret key. - **``**: The base64-encoded secret signing key. - **``**: The message to sign. - **Returns**: A base64-encoded signature. - **`AGE VERIFY `**: Verifies a signature. - **``**: The base64-encoded public verification key. - **``**: The original message. - **``**: The base64-encoded signature. - **Returns**: `1` if the signature is valid, `0` otherwise. ## Key-Managed (Persistent, Named) AGE Operations These commands are used when HeroDB manages the keys. ### Encryption - **`AGE KEYGEN `**: Generates and persists a named encryption keypair. - **``**: A unique name for the key. - **Returns**: An array containing the recipient and identity (for initial export, if needed). - **`AGE ENCRYPTNAME `**: Encrypts a message using a named key. - **``**: The name of the stored key. - **``**: The plaintext message. - **Returns**: A base64-encoded ciphertext. - **`AGE DECRYPTNAME `**: Decrypts a ciphertext using a named key. - **``**: The name of the stored key. - **``**: The base64-encoded ciphertext. - **Returns**: The decrypted plaintext message. ### Signing - **`AGE SIGNKEYGEN `**: Generates and persists a named signing keypair. - **``**: A unique name for the key. - **Returns**: An array containing the public and secret keys (for initial export). - **`AGE SIGNNAME `**: Signs a message using a named key. - **``**: The name of the stored key. - **``**: The message to sign. - **Returns**: A base64-encoded signature. - **`AGE VERIFYNAME `**: Verifies a signature using a named key. - **``**: The name of the stored key. - **``**: The original message. - **``**: The base64-encoded signature. - **Returns**: `1` if the signature is valid, `0` otherwise. ### Key Listing - **`AGE LIST`**: Lists all stored AGE keys. - **Returns**: An array of key names.