test-for-nlp-00011000004215675 / ghost_engine_configs.py
Severian's picture
Update ghost_engine_configs.py
825aa88 verified
#!/usr/bin/env python3
"""
Ghostprint Engine Configuration
==================================
This file contains customizable parameters for the Ghostprint engine,
allowing users to fine-tune compression, encryption, and AI poisoning
settings to meet their specific needs.
"""
from typing import Dict, Any
# -----------------
# Core Engine Behavior
# -----------------
# Default lens function for CMT transformation
# Options: "gamma", "airy", "bessel"
DEFAULT_LENS_FUNCTION = "bessel"
# Number of CMT views for holographic field reconstruction
# Higher numbers increase processing time but may improve pattern detection
NUM_CMT_VIEWS = 3
# -----------------
# Compression Settings
# -----------------
# Compression level for zlib
# 0-9 (9 is highest compression)
COMPRESSION_LEVEL = 9
# -----------------
# Encryption Settings
# -----------------
# Number of iterations for PBKDF2 key derivation
# Higher numbers increase security but slow down encryption/decryption
PBKDF2_ITERATIONS = 100000
# Length of the derived encryption key in bytes
# 32 bytes = 256 bits
ENCRYPTION_KEY_LENGTH = 32
# -----------------
# AI Poisoning Parameters
# -----------------
# Default AI poisoning strength
# 0.0 (no poisoning) to 10.0 (max poisoning)
DEFAULT_POISON_STRENGTH = 2.0
# Default AI poisoning type
# Options: "harmonic", "geometric", "holographic", "adaptive"
DEFAULT_POISON_TYPE = "holographic"
# Homoglyph substitution ratio (base value)
# This is scaled by the poison strength
BASE_HOMOGLYPH_RATIO = 0.15
# Maximum perturbation for byte-level poisoning
# This value is scaled by the poison strength
MAX_BYTE_PERTURBATION = 7
# -----------------
# Image Protection (Invisible Armor) Settings
# -----------------
# CRITICAL: Mid-band frequency targeting for maximum ML disruption
# Mid-band (normalized radius 0.10-0.40) is where CNNs are most vulnerable
# because it disrupts edge detection and feature extraction layers
# Target mid-band energy ratio (0.0 to 1.0)
# Higher values = more ML disruption, less human visibility impact
# Recommended: 0.70-0.90 for optimal ML poisoning
TARGET_MID_BAND_ENERGY = 0.85
# Low-band energy ratio (0.0 to 1.0)
# Low frequencies (< 0.10 radius) carry semantic/shape information
# Keep minimal to preserve human perception
TARGET_LOW_BAND_ENERGY = 0.05
# High-band energy ratio (0.0 to 1.0)
# High frequencies (> 0.40 radius) are fine details/noise
# Keep minimal as they're easily removed by compression
TARGET_HIGH_BAND_ENERGY = 0.10
# Default image protection strength (1.0 to 5.0)
# 1.0 = Invisible to humans, moderate AI disruption
# 3.0 = Barely visible, strong AI disruption (70%+ mid-band)
# 5.0 = Slight artifacts, maximum AI confusion (85%+ mid-band)
DEFAULT_IMAGE_ARMOR_STRENGTH = 3.0
# -----------------
# Advanced Configuration
# -----------------
# Dictionary to store all configuration parameters
GHOST_CONFIG: Dict[str, Any] = {
"default_lens_function": DEFAULT_LENS_FUNCTION,
"num_cmt_views": NUM_CMT_VIEWS,
"compression_level": COMPRESSION_LEVEL,
"pbkdf2_iterations": PBKDF2_ITERATIONS,
"encryption_key_length": ENCRYPTION_KEY_LENGTH,
"default_poison_strength": DEFAULT_POISON_STRENGTH,
"default_poison_type": DEFAULT_POISON_TYPE,
"base_homoglyph_ratio": BASE_HOMOGLYPH_RATIO,
"max_byte_perturbation": MAX_BYTE_PERTURBATION,
# Image armor frequency targets
"target_mid_band_energy": TARGET_MID_BAND_ENERGY,
"target_low_band_energy": TARGET_LOW_BAND_ENERGY,
"target_high_band_energy": TARGET_HIGH_BAND_ENERGY,
"default_image_armor_strength": DEFAULT_IMAGE_ARMOR_STRENGTH,
}
def get_config(key: str) -> Any:
"""Retrieve a configuration parameter by key."""
return GHOST_CONFIG.get(key)
def set_config(key: str, value: Any) -> None:
"""Update a configuration parameter."""
if key in GHOST_CONFIG:
GHOST_CONFIG[key] = value
else:
raise KeyError(f"Configuration key '{key}' not found.")
__all__ = ["GHOST_CONFIG", "get_config", "set_config"]