diff --git a/README.md b/README.md index 0200075..fe8e18e 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,11 @@

VisualCrypto

-

A framework for image-based secret sharing

+

A toolkit for image-based secret sharing

[![Python 3.8+](https://img.shields.io/badge/Python-3.8%2B-blue)](https://www.python.org/downloads/) -[![Cryptographic Secure](https://img.shields.io/badge/Cryptographic%20Secure-secrets.py-blueviolet)](https://docs.python.org/3/library/secrets.html) [![Documentation Available](https://img.shields.io/badge/Documentation-Available-green)](https://coduri.github.io/VisualCrypto/) [![Contributions Welcome](https://img.shields.io/badge/Contributions-Welcome-orange)](https://coduri.github.io/VisualCrypto/pages/contributing/) [![License](https://img.shields.io/badge/License-MIT-red)](https://github.com/coduri/VisualCrypto/blob/main/LICENSE.txt) @@ -20,22 +19,20 @@
- - ## Overview -**VisualCrypto** is a Python-based framework for **Visual Secret Sharing (VSS)**, a cryptographic technique that divides a secret image into multiple shares. Each share appears as random noise and reveals no information on its own, but when combined, they reconstruct the original image. +**VisualCrypto** is an open-source Python-based toolkit with a web interface designed for **Visual Secret Sharing (VSS)**, a cryptographic technique that splits a secret image into multiple shares. Each share appears as random noise and reveals no information on its own, but when combined, they reconstruct the original image. This repository primarily focuses on **(2,2)-VSS schemes**, where a secret image is split into two shares, both of which are required to reveal the hidden content. - 📌 _For more details on **VisualCrypto**, visit the [Project's Documentation](https://coduri.github.io/VisualCrypto/)._ --- ## Features -- Supports Visual Cryptography (VC) & Random Grid (RG) techniques -- Web-based & script-based execution -- Easily extendable for new algorithms +- Support for Visual Cryptography (VC) & Random Grid (RG) techniques +- Web-based & script-based execution for ease of use +- Easily extendable to incorporate new cryptographic schemes +- Reference-based implementation, ensuring that any scientific work derived from this repository maintains appropriate citations. --- @@ -50,7 +47,7 @@ pip install -r requirements.txt ``` ### Usage -You can interact with the framework in two ways: +You can interact with the toolkit in two ways: 1. **Running Python scripts** 2. **Using the Web Interface** @@ -100,7 +97,7 @@ If you find this project useful for your research, please consider citing: ```bibtex @misc{Coduri2025VisualCrypto, author = {Christian Coduri}, - title = {VisualCrypto: A Python-based framework for image-based secret sharing}, + title = {VisualCrypto: A Python-based toolkit for image-based secret sharing}, year = {2025}, publisher = {GitHub}, url = {https://github.com/coduri/VisualCrypto}, diff --git a/docs/index.md b/docs/index.md index ec58982..ceae0e8 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,126 +1,66 @@ -# Introduction to Visual Secret Sharing -Visual Secret Sharing (VSS) is a cryptographic technique and a specific application of the general secret sharing method, in which an image or secret is divided into multiple shares. Individually, these shares reveal no information, and the secret can only be reconstructed when a sufficient number of shares are combined. +# Welcome to VisualCrypto -This repository implements two primary approaches to VSS: **Visual Cryptography (VC)** and **Random Grid (RG)**. Each method has distinct properties, advantages, and limitations, which are outlined in this section. +## Abstract +**VisualCrypto** is an open-source Python-based toolkit with a web interface designed for **Visual Secret Sharing (VSS)**, a cryptographic technique that splits a secret image into multiple shares. Each share appears as random noise and reveals no information on its own, but when combined, they reconstruct the original image. -## Visual Cryptography (VC) -Introduced by Naor and Shamir in 1995, this technique enables the human visual system to reconstruct a secret without any computation. By printing the shares on transparent sheets and overlaying them, the secret image is revealed. - -
- -
- -- **Advantages**: - - Simple, computation-free reconstruction. - -- **Drawbacks**: - - Pixel expansion: The reconstructed image and the shares are larger than the original. - - Decreased quality: The reconstructed image will have higher contrast. - - - -??? question "What is an 'Halftoned' image?" - **Visual Cryptography operates exclusively on binary images.** While the original input can be grayscale or even color, it must first be converted into a binary format to be compatible with VC schemes. A **binary image** consists of only two colors, typically black and white, though other color pairs can be used. - - This conversion is often achieved through **halftoning**, a technique that simulates continuous tones using only two distinct colors. One widely used halftoning method is **Floyd-Steinberg dithering**, which distributes quantization errors to neighboring pixels, creating a visually smoother representation of grayscale images. By transforming images into a binary format, halftoning ensures that VC can effectively encode and reconstruct secret images. - -
- -
+This repository primarily focuses on **(2,2)-VSS schemes**, where a secret image is split into two shares, both of which are required to reveal the hidden content. +## Motivation +VisualCrypto was initially developed as part of a bachelor thesis that made use of **Visual Cryptography (VC)** and **Random Grid (RG) schemes**. During the research, several cryptographic schemes were implemented based on official academic papers, primarily to generate images for the thesis. Rather than letting all the code go unused, it was refined and expanded into a publicly available toolkit, making these techniques more accessible to a broader audience. -??? question "Why Visual Cryptography introduce Pixel Expansion and Higher Contrast?" - Visual Cryptography relies on pixel expansion to enable a purely visual decryption process. Since VC does not require computational decryption, each pixel of the secret image is expanded into multiple subpixels in the generated shares. This ensures that when the shares are stacked together, a human observer can visually perceive the reconstructed image without additional processing. - - In a (2,2)-VC scheme, each pixel of the original image is expanded into four subpixels in each share. This expansion allows the encoding of visual information in a way that maintains perfect secrecy, as the shares appear completely random when viewed independently. However, when the shares are overlaid, the expanded subpixels align in a way that reveals the hidden image. +One of the key motivations behind VisualCrypto is the lack of a widely recognized and comprehensive library for Visual Secret Sharing schemes. While individual implementations exist, there is no unified software that allows users to easily apply, compare, and experiment with different VSS techniques. By making VisualCrypto open-source, the goal is to provide **researchers, developers, and cryptography enthusiasts** with a well-documented, reliable, and extensible platform for working with various schemes from scientific literature. -
- - -
+## Features +- Support for Visual Cryptography (VC) & Random Grid (RG) techniques +- Web-based & script-based execution for ease of use +- Easily extendable to incorporate new cryptographic schemes +- Reference-based implementation, ensuring that any scientific work derived from this repository maintains appropriate citations. - One consequence of this pixel expansion is an increase in contrast. When an original pixel is white, both shares use identical subpixel patterns, resulting in areas that appear partially white when stacked. In contrast, if the original pixel is black, the two shares contain complementary subpixel patterns, making the reconstructed area appear fully black. This difference causes a 50% increase in contrast for white pixels, making the reconstructed image darker and more visually distinct compared to the original. - - The following illustration demonstrates how pixel expansion works and how it impacts the reconstructed image's contrast: - -
- -
- - By expanding each pixel and carefully structuring the subpixels, Visual Cryptography ensures that human vision alone can decrypt the secret image while inherently increasing its contrast. - - +--- -## Random Grid (RG) -Proposed by Kafri and Keren in 1987, Random Grid employs computational reconstruction rather than direct visual overlay. This approach mitigates the limitations of pixel expansion and contrast increase found in Visual Cryptography. +## Design +Below is an overview of the project's architecture:
- + Project Structure
-- **Advantages**: - - Maintains the original image size (no pixel expansion). - - Preserves image contrast and quality. - -- **Drawback**: - - Requires computational reconstruction. - - - -??? note - In the **Random Grid approach**, computation is possible, allowing for the application of **general secret sharing techniques** beyond traditional visual decryption. Unlike Visual Cryptography, which relies solely on the human visual system for decoding, RG-based schemes can leverage mathematical and computational methods to enhance security and improve reconstruction accuracy. This flexibility makes Random Grid a suitable approach for scenarios where digital processing is available and additional cryptographic techniques can be applied. - ---- - -## Comparison of VC and RG Approaches -The table below compares the outputs of **Visual Cryptography** and **Random Grid** using as input the same grayscale halftone images. The scripts used in these examples are `vc_grayscale_halftone.py` and `rg_grayscale_halftone.py`. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
StepVisual Cryptography (VC)Random Grid (RG)
Input (Binary Image)
Share 1
Share 2
OR Reconstruction
XOR ReconstructionNot proposed in the official paper (requires computational processing)
- - -For both executions, the input halftone image has a resolution of `400×400 px`. - -- In **Random Grid**, all output images, including the generated shares and the reconstructed image, **mantain the original size** of `400×400 px`. -- In **Visual Cryptography**, the pixel expansion process results in the shares and reconstructed image **doubling in size** to `800×800 px`. +### Key Components +- **`index.html`**: The main frontend interface where users select algorithms, perform operations, and upload images. +- **`app.py`**: A Flask-based web server providing API endpoints for frontend interactions (see [API Reference](api_reference.md) for details). +- **`algo_interface.py`**: An interface to access various visual secret sharing schemes. It maintains a dictionary that maps scheme names to their respective functions. +- **`scripts/`**: Contains the core implementations of visual cryptography and random grid schemes. + - `visual_cryptography/`: Contains different Visual Cryptography implementations. + - `random_grid/`: Contains Random Grid based implementations. + +### Folder Structure +``` +visual-secret-sharing/ +├── .github/ +├── docs/ # Documentation files +│ +├── scripts/ # Core scripts for encryption and decryption +│ ├── images/ # Image assets for testing and output +│ │ ├── output/ # Stores generated shares and reconstructed images (when using CLI) +│ │ └── test.png # Example input image used for testing +│ ├── random_grid/ # Scripts for encrypting and decrypting using Random Grid schemes +│ └── visual_cryptography/ # Scripts for encrypting and decrypting using Visual Cryptography schemes +│ +├── web_app/ # Flask-based web application +│ ├── static/ # Static files used by the web app +│ │ ├── css/ # Stylesheets for the web interface +│ │ ├── output/ # Stores generated shares and reconstructed images (when using GUI) +│ │ └── uploads/ # Folder for storing user-uploaded images +│ ├── templates/ # HTML templates for the web application +│ ├── algo_interface.py # Interface for accessing VSS schemes and their corresponding functions +│ └── app.py # Main Flask application file +│ +├── .gitignore +├── LICENSE.txt +├── mkdocs.yml # Configuration file for MkDocs, defining the documentation structure +├── README.md +└── requirements.txt # Python dependencies required to run the project + +``` + +--- \ No newline at end of file diff --git a/docs/pages/introductionVSS.md b/docs/pages/introductionVSS.md new file mode 100644 index 0000000..1ae50e8 --- /dev/null +++ b/docs/pages/introductionVSS.md @@ -0,0 +1,126 @@ +# Introduction to Visual Secret Sharing +Visual Secret Sharing (VSS) is a cryptographic technique and a specific application of the general secret sharing method, in which an image or secret is divided into multiple shares. Individually, these shares reveal no information, and the secret can only be reconstructed when a sufficient number of shares are combined. + +This repository implements two primary approaches to VSS: **Visual Cryptography (VC)** and **Random Grid (RG)**. Each method has distinct properties, advantages, and limitations, which are outlined in this section. + +## Visual Cryptography (VC) +Introduced by Naor and Shamir in 1995, this technique enables the human visual system to reconstruct a secret without any computation. By printing the shares on transparent sheets and overlaying them, the secret image is revealed. + +
+ +
+ +- **Advantages**: + - Simple, computation-free reconstruction. + +- **Drawbacks**: + - Pixel expansion: The reconstructed image and the shares are larger than the original. + - Decreased quality: The reconstructed image will have higher contrast. + + + +??? question "What is an 'Halftoned' image?" + **Visual Cryptography operates exclusively on binary images.** While the original input can be grayscale or even color, it must first be converted into a binary format to be compatible with VC schemes. A **binary image** consists of only two colors, typically black and white, though other color pairs can be used. + + This conversion is often achieved through **halftoning**, a technique that simulates continuous tones using only two distinct colors. One widely used halftoning method is **Floyd-Steinberg dithering**, which distributes quantization errors to neighboring pixels, creating a visually smoother representation of grayscale images. By transforming images into a binary format, halftoning ensures that VC can effectively encode and reconstruct secret images. + +
+ +
+ + +??? question "Why Visual Cryptography introduce Pixel Expansion and Higher Contrast?" + Visual Cryptography relies on pixel expansion to enable a purely visual decryption process. Since VC does not require computational decryption, each pixel of the secret image is expanded into multiple subpixels in the generated shares. This ensures that when the shares are stacked together, a human observer can visually perceive the reconstructed image without additional processing. + + In a (2,2)-VC scheme, each pixel of the original image is expanded into four subpixels in each share. This expansion allows the encoding of visual information in a way that maintains perfect secrecy, as the shares appear completely random when viewed independently. However, when the shares are overlaid, the expanded subpixels align in a way that reveals the hidden image. + +
+ + +
+ + One consequence of this pixel expansion is an increase in contrast. When an original pixel is white, both shares use identical subpixel patterns, resulting in areas that appear partially white when stacked. In contrast, if the original pixel is black, the two shares contain complementary subpixel patterns, making the reconstructed area appear fully black. This difference causes a 50% increase in contrast for white pixels, making the reconstructed image darker and more visually distinct compared to the original. + + The following illustration demonstrates how pixel expansion works and how it impacts the reconstructed image's contrast: + +
+ +
+ + By expanding each pixel and carefully structuring the subpixels, Visual Cryptography ensures that human vision alone can decrypt the secret image while inherently increasing its contrast. + + + +## Random Grid (RG) +Proposed by Kafri and Keren in 1987, Random Grid employs computational reconstruction rather than direct visual overlay. This approach mitigates the limitations of pixel expansion and contrast increase found in Visual Cryptography. + +
+ +
+ +- **Advantages**: + - Maintains the original image size (no pixel expansion). + - Preserves image contrast and quality. + +- **Drawback**: + - Requires computational reconstruction. + + + +??? note + In the **Random Grid approach**, computation is possible, allowing for the application of **general secret sharing techniques** beyond traditional visual decryption. Unlike Visual Cryptography, which relies solely on the human visual system for decoding, RG-based schemes can leverage mathematical and computational methods to enhance security and improve reconstruction accuracy. This flexibility makes Random Grid a suitable approach for scenarios where digital processing is available and additional cryptographic techniques can be applied. + +--- + +## Comparison of VC and RG Approaches +The table below compares the outputs of **Visual Cryptography** and **Random Grid** using as input the same grayscale halftone images. The scripts used in these examples are `vc_grayscale_halftone.py` and `rg_grayscale_halftone.py`. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StepVisual Cryptography (VC)Random Grid (RG)
Input (Binary Image)
Share 1
Share 2
OR Reconstruction
XOR ReconstructionNot proposed in the official paper (requires computational processing)
+ + +For both executions, the input halftone image has a resolution of `400×400 px`. + +- In **Random Grid**, all output images, including the generated shares and the reconstructed image, **mantain the original size** of `400×400 px`. +- In **Visual Cryptography**, the pixel expansion process results in the shares and reconstructed image **doubling in size** to `800×800 px`. diff --git a/docs/pages/overview.md b/docs/pages/overview.md deleted file mode 100644 index 7831011..0000000 --- a/docs/pages/overview.md +++ /dev/null @@ -1,50 +0,0 @@ -# Project Overview -## Design -Below is an overview of the project's architecture: - -
- Project Structure -
- -### Key Components -- **`index.html`**: The main frontend interface where users select algorithms, perform operations, and upload images. -- **`app.py`**: A Flask-based web server providing API endpoints for frontend interactions (see [API Reference](api_reference.md) for details). -- **`app.py`**: A Flask-based web server that renders `index.html` and provides API endpoints for frontend interactions. API documentation for details. -- **`algo_interface.py`**: An interface to access various visual secret sharing schemes. It maintains a dictionary that maps scheme names to their respective functions. -- **`scripts/`**: Contains the core implementations of visual cryptography and random grid schemes. - - `visual_cryptography/`: Contains different Visual Cryptography (VC) implementations. - - `random_grid/`: Contains Random Grid (RG) based implementations. - ---- - -## Folder Structure -``` -visual-secret-sharing/ -├── .github/ -├── docs/ # Documentation files -│ -├── scripts/ # Core scripts for encryption and decryption -│ ├── images/ # Image assets for testing and output -│ │ ├── output/ # Stores generated shares and reconstructed images (when using CLI) -│ │ └── test.png # Example input image used for testing -│ ├── random_grid/ # Scripts for encrypting and decrypting using Random Grid schemes -│ └── visual_cryptography/ # Scripts for encrypting and decrypting using Visual Cryptography schemes -│ -├── web_app/ # Flask-based web application -│ ├── static/ # Static files used by the web app -│ │ ├── css/ # Stylesheets for the web interface -│ │ ├── output/ # Stores generated shares and reconstructed images (when using GUI) -│ │ └── uploads/ # Folder for storing user-uploaded images -│ ├── templates/ # HTML templates for the web application -│ ├── algo_interface.py # Interface for accessing VSS schemes and their corresponding functions -│ └── app.py # Main Flask application file -│ -├── .gitignore -├── LICENSE.txt -├── mkdocs.yml # Configuration file for MkDocs, defining the documentation structure -├── README.md -└── requirements.txt # Python dependencies required to run the project - -``` - ---- \ No newline at end of file diff --git a/docs/pages/web_interface_integration.md b/docs/pages/web_interface_integration.md index 8a8def0..aee0048 100644 --- a/docs/pages/web_interface_integration.md +++ b/docs/pages/web_interface_integration.md @@ -126,7 +126,7 @@ Defines how the Flask app interacts with your algorithm. "image_type": "L" # Image mode (e.g., 'L' for grayscale, '1' for binary) } ``` -The `get_config()` function acts as a bridge between individual algorithms and the framework. It encapsulates all required metadata, descriptions, functions, and parameters within a single dictionary, allowing the Flask app to interact with the scheme simply by accessing `get_config()`. +The `get_config()` function acts as a bridge between individual algorithms and the toolkit. It encapsulates all required metadata, descriptions, functions, and parameters within a single dictionary, allowing the Flask app to interact with the scheme simply by accessing `get_config()`. --- diff --git a/mkdocs.yml b/mkdocs.yml index fd10674..5473b75 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -33,11 +33,10 @@ theme: primary: blue nav: - - 'User Guide': - - 'Introduction to VSS Schemes': index.md - - 'Getting Started': pages/getting_started.md + - 'Index': index.md + - 'Introduction to VSS Schemes': pages/introductionVSS.md + - 'Getting Started': pages/getting_started.md - 'Developer Guide': - - 'Project Overview': pages/overview.md - 'Contributing': pages/contributing.md - 'Web Interface Integration': pages/web_interface_integration.md - 'API Reference': pages/api_reference.md