This project implements an image authentication scheme using Merkle tree mechanisms in Rust. The main goal is to achieve image integrity verification by leveraging blockchain technology and the Inter-Planetary File System (IPFS). The proposed method not only verifies the integrity of the image but also restores tampered areas if the image has been altered.
- Image Integrity Verification: Uses Merkle tree mechanisms to verify the integrity of images.
- Tampered Area Restoration: Restores the tampered areas of images.
- Decentralized Storage: Utilizes IPFS for decentralized storage of images.
- Blockchain Technology: Implements blockchain to store the Merkle root for secure verification.
image_into_chunks.rs
: Handles the slicing of images into chunks.image_verification.rs
: Implements the image verification process using the Merkle tree mechanism.image_to_msb.rs
: Converts images to their Most Significant Bits (MSB) for further processing.blockencryption.rs
: Contains functions for encrypting image blocks.blockchain.rs
: Manages blockchain-related operations.merkle_tree.rs
: Implements Merkle tree operations.ipfs_upload.rs
: Manages the upload of image blocks to IPFS.main.rs
: The main entry point of the application.
-
Clone the repository:
git clone https://github.com/whoisgautxm/Image-Authentication-Model-in-Rust.git cd Image-Authentication-Model-in-Rust
-
Install Rust: Follow the instructions on rust-lang.org to install Rust.
-
Build the project:
cargo build
-
Run the project:
cargo run
-
Image Slicing and Encryption:
- The image is sliced into non-overlapping blocks.
- Each block is encrypted and uploaded to the IPFS system.
-
Merkle Tree Generation:
- The unique hash (fingerprint) of each image block is used as a transaction in the blockchain.
- A Merkle tree is generated with these transactions, and the Merkle root is stored in the blockchain.
-
Image Verification:
- The Merkle tree for the unverified image is generated.
- This tree is compared with the original image's Merkle tree from the blockchain to verify integrity and identify tampered areas.
-
Image Processing:
- Extract the k Most Significant Bits (MSBs) of each pixel.
- Slice the image into blocks of size N x N pixels.
-
Encryption and IPFS Upload:
- Encrypt each block.
- Upload encrypted blocks to IPFS and get their unique hashes.
-
Blockchain Integration:
- Use the hashes as transactions to build a Merkle tree.
- Store the Merkle root in the blockchain.
-
Verification Process:
- Generate Merkle tree for the received image.
- Retrieve the original Merkle tree from the blockchain.
- Compare both trees to identify tampered blocks.
Contributions are welcome! Please fork this repository and submit pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.