This Project is a decentralized application demonstrating a system for detecting deepfakes in images/videos, verifying their authenticity using cryptographic hashes, storing them decentrally on IPFS, and managing sharing permissions securely via a blockchain smart contract.
- Introduction
- Features
- Technology Stack
- Requirements
- Installation
- Running the Application (Local Development)
- File Structure
- Contributors
- Contributing
- License
Our project aims to tackle the challenges posed by deepfake technology to media authenticity by leveraging the combined power of blockchain and machine learning.
- Deepfake Detection: Uploaded media is analyzed by three backend nodes running a deep learning model to assess if it's likely a deepfake. A consensus mechanism can be used for higher reliability.
- Integrity Verification: A cryptographic hash (SHA-256) of the original media file is calculated before upload.
- Decentralized Storage: Verified authentic media is uploaded to IPFS via Pinata, ensuring content-addressable, decentralized storage.
- Immutable Record: The IPFS CID (Content Identifier) and the calculated hash are stored immutably on an Ethereum-compatible blockchain using a Solidity smart contract.
- Secure Sharing & Traceability: The smart contract manages fine-grained, item-level sharing permissions. Sharing actions are logged via events, enabling traceability of who shared what with whom.
- Client-Side Verification: When viewing media, the application fetches the content from IPFS, recalculates its hash, and verifies it against the hash stored on the blockchain, ensuring tamper-evidence.
- Deepfake Detection: Analyzes uploads using a Keras/TensorFlow model.
- Supports a client-orchestrated consensus mechanism across multiple detection nodes.
- Cryptographic Hashing: Generates SHA-256 hash for integrity verification.
- IPFS Upload: Stores verified media on IPFS via Pinata pinning service.
- Blockchain Anchoring: Records media CID, hash, and ownership on the blockchain (via Solidity Smart Contract).
- Client-Side Verification: Verifies retrieved media integrity against the blockchain hash.
- Item-Level Sharing: Allows owners (or those granted access) to securely share specific media items with other Ethereum addresses.
- Sharing Traceability: Logs sharing events on the blockchain, allowing reconstruction of the sharing history.
- Frontend: React.js, Ethers.js
- Backend: Python, Flask, TensorFlow/Keras
- Blockchain: Solidity, Hardhat
- Decentralized Storage: Pinata
- Wallet: MetaMask
Ensure you have the following installed before proceeding:
General:
- Web Browser with MetaMask extension.
Frontend:
Backend:
- Python >= 3.12
- Additional dependencies listed in
requirement.txt
Install the required packages then only you will be able to start the DApp
# first activate your python virtual environment and install python dependencies mentioned in requirement.txt
pip install -r requirement.txt
Blockchain Development:
- Hardhat (installed via npm in the project)
Services:
- Pinata Account: Required for API Key and Secret Key to pin files to IPFS.
Clone this repository to your local machine:
git clone https://github.com/hackerpranavpandey/BlockChain-Course-Project.git
cd BlockChain-Course-Project[Link](https://youtu.be/aRHTKzFZOkw?si=3DcqbRniiuajmQTQ)
For the consensus mechanism, you need to run three instances of the Flask backend, each on a different port specified in client/src/components/FileUpload.jsx (e.g., 5001, 5002, 5003).
Commands common for three terminals
cd Backend
# Activate virtual environment if not already active
# source venv/bin/activate # (macOS/Linux) OR venv\Scripts\activate (Windows)Terminal 1:
python backend1.py --port 5001Terminal 2:
python backend2.py --port 5002Terminal 3:
python backend3.py --port 5003In a new terminal, start the Hardhat local node from the project root:
npm i # to install node modules
npx hardhat nodeIn another new terminal, deploy the Upload.sol contract to the local Hardhat node:
npx hardhat run --network localhost scripts/deploy.jsIMPORTANT: Note the contract address printed in the console after successful deployment.
Open the file in your frontend where the contract instance is initialized (client/src/App.js). Update the contractAddress variable with the address you noted in the previous step.
cd client
npm i # to install node modules
npm start.
├── Backend/ # Python Flask backend code
│ ├── backend1.py # Main Flask application logic
│ ├── backend2.py # Main Flask application logic
│ ├── backend3.py # Main Flask application logic
│ └── deepfake_model.keras # Trained deep learning model file for Image
│ └── deepfake-detection-model1.h5 # Trained deep learning model file for Video
├── client/ # React frontend application (DApp)
│ ├── public/ # Static assets
│ └── src/ # React source code
│ ├── artifacts/ # Contract artifacts generated by Hardhat (including ABI)
│ ├── components/ # React components (FileUpload, Display, TraceabilityModal, Modal, etc.)
│ ├── App.css # Main app styles
│ ├── App.js
│ ├── App.test.js
│ ├── index.css
│ ├── index.js
│ ├── reportWebVitals.js
│ └── setupTests.js
├── contracts/ # Solidity smart contract source code
│ └── Upload.sol # The main smart contract
├── cache/ # Hardhat cache
├── ignition/ # Hardhat Ignition deployment modules (if used)
├── scripts/ # Deployment scripts (e.g., deploy.js)
├── screenshots # It contain all the screenshots of the DApp
├── hardhat.config.js # Hardhat configuration file
├── package-lock.json # Exact dependency versions for npm
├── package.json # Project metadata and Node.js dependencies
└── README.md # documentation file
Pranav Kumar Pandey
Parikshit Gehlaut
We welcome contributions to the our project! To contribute, please follow these steps:
- Fork the repository
- create a new branch
- Make and commit your changes
- Push to the branch
- Open a pull request
This project is licensed under the MIT License. See the LICENSE file for details.