This repository contains the implementation of a novel system for secure medical image encryption using high-entropy keys generated by Wasserstein Generative Adversarial Networks with Gradient Penalty (WGAN-GP). The encryption framework leverages WGAN-GP's training stability and the randomness of chaotic maps for secure and robust cryptographic key generation.
Traditional key generation techniques often suffer from low entropy or training instability when using machine learning models. To address this, we propose a two-stage cryptosystem:
- Key Generation using WGAN-GP: Generates a one-time pad style high-entropy key by training on transformation domain images.
- Encryption using ACM + XOR Diffusion: Applies Arnold's Cat Map for confusion and XOR operation for diffusion.
This system ensures strong encryption, reduced correlation, high unpredictability, and superior performance compared to classical models.
📁 Draw.io files → Architecture and diagram sources
📁 Final_Training → Final training data, logs or models
📁 Medical_Images_for_rough_test → Sample medical images used for testing
📁 Models → Saved Checkpoint after training it for ~250 epochs
📁 ppts → Project presentation slides
📁 WGAN_GP_working → WGAN-GP training and evaluation logic
📁 PythonFiles → Utility and core implementation scripts
│
├── Utils.py → Common utility functions used across the project.
├── Utils_.py → Variant of Utils with additional or experimental utilities.
├── cryptoSystem.py → Core encryption and decryption system logic.
├── decrypt_randomness.py → Functions for randomness handling during decryption.
├── desktop.ini → System-generated file storing folder view settings (not project-related).
├── graphs.py → Code for plotting evaluation graphs and metrics.
├── index.py → Main entry script for orchestrating model execution.
├── metrices.csv → Stores recorded model evaluation metrics (e.g. accuracy, loss).
├── nist__python.py → Implements NIST randomness tests (version 1).
├── nist_py.py → Implements NIST randomness tests (version 2 or updated).
├── nist_test.py → Executes and evaluates NIST test suite results.
├── one_time_pad_test.py → Testing logic for one-time pad encryption methods.
├── otp_thesis.py → Thesis-specific code applying OTP logic in real scenarios.
├── paper.py → Script used to generate or analyze content for research paper.
├── ui.py → Basic UI interactions for user inputs and actions.
├── wgan_gp.py → Implements WGAN-GP model logic and training routines.
└── wgp.py → Additional or refined implementation of WGAN-GP or helper model.
📄 simple_ui_using_TKinter.py → UI demo for image-key generation
📄 README.md → This file
- Python
- PyTorch
- TorchVision
- NumPy & SciPy
- Matplotlib
- Tkinter (for GUI)
-
TC1: Key Entropy Validation
Each generated key was assessed for entropy using histogram distribution, ensuring values spread uniformly across grayscale (0–255). This verified randomness essential for cryptographic strength. -
TC2: One-Time Pad Behavior
Unique keys were produced for every input image, and reusing the same image under retraining led to different keys — confirming non-reproducibility and effective one-time pad simulation. -
TC3: Correct Decryption Verification
The original medical image was successfully recovered after decryption, verifying complete reversibility through inverse ACM and XOR operations. -
TC4: Structural Quality Analysis
Decrypted image quality was validated using SSIM and MSE metrics, confirming structural similarity with plaintext. -
TC5: Ciphertext Confusion & Diffusion
Correlation between adjacent pixels in ciphertext was drastically reduced, with high NPCR and UACI scores indicating successful pixel scrambling and value diffusion.
- NPCR (Number of Pixel Change Rate)
- UACI (Unified Average Changing Intensity)
- MSE (Mean Squared Error)
- SSIM (Structural Similarity Index)
- Correlation Coefficient (between adjacent pixels)
The implementation was executed through four core phases:
-
Adversarial Training (WGAN-GP)
- Trained on source medical images and target spectrograms.
- Generator learns to produce key-like images indistinguishable by the critic.
- Gradient penalty ensures stable training and prevents mode collapse.
-
Key Generation
- A 256×256×3 key is produced for each medical image via the trained generator.
- Generated keys mimic transformation-domain features for maximum entropy.
-
Image Encryption
- Step 1: ACM Scrambling — Pixel positions in the medical image are iteratively shuffled using Arnold’s Cat Map.
- Step 2: XOR Diffusion — The scrambled image is XORed with the generated key to produce ciphertext.
-
Decryption
- XOR is applied again with the key to reverse diffusion.
- ACM is reversed to restore original pixel positions, reconstructing the original image.
All training and encryption processes were carried out using Google Colab Pro with TPU for accelerated computation.
The system was evaluated using standard cryptographic and image processing metrics:
Metric | GAN + XOR | WGAN-GP + ACM + XOR |
---|---|---|
NPCR | ~78% | 99.5% |
UACI | Moderate | High |
MSE | Higher deviation | Lower |
SSIM | ~0.61 | ~0.92 |
Correlation | Strong | Minimal/None |
Key Observations:
- WGAN-GP produced high-entropy keys that outperformed traditional GAN-generated keys.
- Histogram plots confirmed uniform distribution of key values, supporting randomness.
- Ciphertext exhibited significantly reduced correlation between adjacent pixels.
- The model avoided common pitfalls like mode collapse and overfitting.
Overall, the model demonstrates superior cryptographic reliability, efficiency, and practical applicability for secure medical image encryption.
- Malarvannan M (2022503011)
- Maanasa Prathap Chander (2022503065)
- Kalaidharun R (2022503009)
Guided by: Dr. R. Kathiroli, Assistant Professor, Dept of Computer Technology, MIT, Anna University
- Improve robustness by training further epochs.
- Prepare for conference paper submission.
- Extend support to multiple medical modalities and key-image mapping techniques.
This project is for academic purposes under Anna University and is not licensed for commercial use unless specified.