A secure social media application which uses Distributed Computing to verify if a image a user wants to post is similar to the images given in the reference database. This is achieved using hashing methods like Perceptual Hashing, Average hashing, Difference hashing and Median hashing where the hash values are precomputed for reference images in a Database.
The uploaded image is then hashed with it's respective hash and later verified with the precomputed hashes with Hamming Distance and a threshold for the System to decide whether to vote or not for the given image.
If a Quorum exists the image isn't uploaded to the social media and the user is flagged and banned from the application after 2 warnings (Since this a proof of concept we used Cat Images as the reference image, so you can't post cat images in this server).
</img>
Image Hashing is a fingerprint of a multimedia file derived from various features from its content. Unlike cryptographic hash functions which rely on the avalanche effect of small changes in input leading to drastic changes in the output here we use Similarity of Images.
Image | Image Hash |
---|---|
</img> | </img> |
Query Image (Cat) | 0xa4ad99b3629076ae |
The above is an Example of Image Hashing Where We Query Using an Image and It’s Hash is computed on Each Server depending on the algorithm
Uses Discrete Cosine Transform to capture frequencies in the image and Perform hash based on the 8x8 upper-left part of image and set bit to 1 if > mean
Scale Down grayscale Image to 8x8 and compute Median of the values of pixels and set bit to 1 if > median
Compute the average of the pixel values in the image (8x8) without DCT and compute the hash
After Image Scaling and Gray scaling compute dhash by computing the difference between adjacent pixels and compute hash
Certain Algorithm are not resistant to image augmentation such as Skewing , Cropping , Contrast changes
Each Algorithm will have a threshold beyond which the algorithm identifies the image as illegal so we provide a distributed environment using raft consensus protocol where each hash is computed and voted based on its threshold ensuring:
1.Fault Tolerance (Regular Raft Leader Election at select time-intervals)
2.Reliablity (Multiple Servers' Vote Ensure Reliablity)
3.Safety
</img>
The following is the type initilization for the HashServer Class in Backend:
backend
directory. > python3 -m venv venv
> venv\Scripts\activate
> source venv/bin/activate
> pip install -r requirements.txt
config.py
file to specify your database configuration. > flask run
d_flag
directory. > npm install
> npm start
http://localhost:3000
.http://localhost:5000
.http://127.0.0.1:5000/initdb
to initialise the DB with reference cat images. This will be required for the algorithms to compare hashes and vote.backend
: Contains the Flask backend code.d_flag
: Contains the React frontend code.