Skip to content

Commit

Permalink
docs: improve clarity and structure
Browse files Browse the repository at this point in the history
  • Loading branch information
coduri committed Feb 25, 2025
1 parent c8ec5d8 commit 627154e
Show file tree
Hide file tree
Showing 6 changed files with 193 additions and 181 deletions.
19 changes: 8 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@

<h1 align="center">VisualCrypto</h1>

<p align="center">A framework for image-based secret sharing</p>
<p align="center">A toolkit for image-based secret sharing</p>

<div align="center">

[![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)
Expand All @@ -20,22 +19,20 @@
</div>




## 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.

---

Expand All @@ -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**

Expand Down Expand Up @@ -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},
Expand Down
170 changes: 55 additions & 115 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -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 <a href="https://doi.org/10.1007/BFb0053419" target="_blank">Naor and Shamir in 1995</a>, 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.

<div align="center">
<img src="assets/vc/process.png"/>
</div>

- **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.

<div align="center">
<img src="assets/vc/halftoning.png" width="50%"/>
</div>
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.

<div align="center">
<img src="assets/vc/black.png" width="48%"/>
<img src="assets/vc/white.png" width="48%"/>
</div>
## 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:

<div align="center">
<img src="assets/vc/pattern.png" width="80%"/>
</div>

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 <a href="https://doi.org/10.1364/ol.12.000377" target="_blank" rel="noopener noreferrer">Kafri and Keren in 1987</a>, 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:

<div align="center">
<img src="assets/rg/process.png"/>
<img src="assets/design.png" alt="Project Structure" width="90%">
</div>

- **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`.



<table style="border-collapse: collapse; width: 100%; text-align: center;">
<colgroup>
<col style="width: 20%;" />
<col style="width: 35%;" />
<col style="width: 35%;" />
</colgroup>
<thead>
<tr>
<th style="vertical-align: middle; text-align: center;">Step</th>
<th style="vertical-align: middle; text-align: center;">Visual Cryptography (VC)</th>
<th style="vertical-align: middle; text-align: center;">Random Grid (RG)</th>
</tr>
</thead>
<tbody>
<tr>
<td style="vertical-align: middle; text-align: center;"><strong>Input (Binary Image)</strong></td>
<td><img src="assets/vc/halftoned.png"/></td>
<td><img src="assets/rg/halftoned.png"/></td>
</tr>
<tr>
<td style="vertical-align: middle; text-align: center;"><strong>Share 1</strong></td>
<td><img src="assets/vc/share1.png"/></td>
<td><img src="assets/rg/RG1.png"/></td>
</tr>
<tr>
<td style="vertical-align: middle; text-align: center;"><strong>Share 2</strong></td>
<td><img src="assets/vc/share2.png"/></td>
<td><img src="assets/rg/RG2.png"/></td>
</tr>
<tr>
<td style="vertical-align: middle; text-align: center;"><strong>OR Reconstruction</strong></td>
<td><img src="assets/vc/overlap.png"/></td>
<td><img src="assets/rg/overlap_OR.png"/></td>
</tr>
<tr>
<td style="vertical-align: middle; text-align: center;"><strong>XOR Reconstruction</strong></td>
<td style="vertical-align: middle; text-align: center;"><i>Not proposed in the official paper (requires computational processing)</i></td>
<td><img src="assets/rg/overlap_XOR.png"/></td>
</tr>
</tbody>
</table>


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
```

---
Loading

0 comments on commit 627154e

Please sign in to comment.