feagi-api 0.0.8

FEAGI REST API layer with HTTP and ZMQ transport adapters
Documentation
// Copyright 2025 Neuraville Inc.
// SPDX-License-Identifier: Apache-2.0

/// Application-level message encryption (stub for future ChaCha20-Poly1305)
pub struct MessageEncryptor {
    #[allow(dead_code)]
    secret_key: [u8; 32],
    #[allow(dead_code)]
    public_key: [u8; 32],
}

impl MessageEncryptor {
    /// Create new encryptor (stub - keys generated but not used)
    pub fn new() -> Self {
        // Stub: Generate keys but don't use them yet
        Self {
            secret_key: [0u8; 32],
            public_key: [0u8; 32],
        }
    }

    /// Encrypt message (stub - returns plaintext for now)
    pub fn encrypt(&self, plaintext: &[u8]) -> Result<Vec<u8>, EncryptionError> {
        // Stub: Return plaintext for now
        // Future: Implement ChaCha20-Poly1305 encryption
        Ok(plaintext.to_vec())
    }

    /// Decrypt message (stub - returns ciphertext for now)
    pub fn decrypt(&self, ciphertext: &[u8]) -> Result<Vec<u8>, EncryptionError> {
        // Stub: Return ciphertext for now
        // Future: Implement ChaCha20-Poly1305 decryption
        Ok(ciphertext.to_vec())
    }
}

impl Default for MessageEncryptor {
    fn default() -> Self {
        Self::new()
    }
}

/// Encryption error (stub)
#[derive(Debug, Clone)]
pub struct EncryptionError {
    pub message: String,
}

impl EncryptionError {
    pub fn new(message: impl Into<String>) -> Self {
        Self {
            message: message.into(),
        }
    }
}

impl std::fmt::Display for EncryptionError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{}", self.message)
    }
}

impl std::error::Error for EncryptionError {}