Credential Security

This guide provides best practices for managing secrets, API keys, and sensitive configurations within Cyne AI to ensure security and operational efficiency.

Core Concepts

Environment Variables

Cyne AI uses a hierarchical system for environment variables:

  1. Character-specific secrets (highest priority).

  2. Environment variables defined in .env files.

  3. Default values (lowest priority).


Secret Types

Common secrets managed in Cyne AI:

# API Keys
OPENAI_API_KEY=sk-your-openai-key

# Client Authentication
DISCORD_API_TOKEN=your-discord-token
TELEGRAM_BOT_TOKEN=your-telegram-token

# Solana Wallet Credentials
SOLANA_PRIVATE_KEY=example-private-key
SOLANA_PUBLIC_KEY=example-public-key

Implementation Guide

Basic Setup

  1. Create a .env file from the provided template:

  2. Configure environment variable discovery in your code:


Character-Specific Secrets

Define secrets directly in character files for modular configuration:

Access secrets in your code:


Secure Storage

Wallet Management

Handle Solana wallet credentials securely:


Encryption for Secrets

Encrypt sensitive secrets before storage:


Best Practices

1. Environment Segregation

Use separate .env files for different environments:

  • .env.development – Development settings

  • .env.staging – Staging environment

  • .env.production – Production environment


2. Secret Validation

Ensure required secrets are defined:


3. Git Security

Exclude sensitive files from version control by adding the following to .gitignore:


4. Secret Rotation

Regularly rotate secrets to enhance security:


Troubleshooting

Common Issues

  1. Missing Secrets Ensure required environment variables or character-specific secrets are defined:

  2. Invalid Secret Format Validate the format of critical secrets like API keys:

  3. Secret Loading Errors Handle errors gracefully during secret loading:


Security Considerations

1. API Keys Handling

  • Use strong validation logic for keys.

  • Rotate keys periodically to reduce risks.


2. Access Control

  • Restrict access to sensitive secrets using a controlled list.

  • Log unauthorized access attempts for monitoring.


3. Encryption at Rest

  • Encrypt all sensitive data stored on disk.

  • Use AES-256-GCM encryption for strong security.


  • Configuration Guide: General setup instructions.

  • Local Development Guide: Best practices for local environments.

  • Infrastructure Guide: Secure deployment practices.


By following these guidelines, you can manage secrets effectively and securely within the Cyne AI framework, ensuring robust and secure operations.

Last updated