Professional Documents
Culture Documents
B.Tech.
in
DEPARTMENT OF
DEPARTMENT NAME
NATIONAL INSTITUTE OF TECHNOLOGY
TIRUCHIRAPPALLI-620015
MAY 2023
Figure 2.1: Structure of a Blockchain
altering all subsequent blocks. Additionally, transactions are verified and approved
by a network of nodes using complex algorithms and consensus mechanisms, further
ensuring the validity of the data. The most well-known implementation of blockchain
2.2 IPFS
IPFS, an acronym for InterPlanetary File System, is a revolutionary protocol and net-
work that facilitates a distributed method for storing and accessing files in a decentral-
5
4.1 Proposed Architecture
We used image processing techniques to convert the fingerprint image to a binary for-
mat, such as black and white pixels, where black represents the fingerprint ridges and
white represents the valleys. Once we have the binary data, we will apply the AES
encryption algorithm to encrypt the data. This can be done using a software library or
a programming language that supports AES encryption. After encryption, we saved the
encrypted data to our IPFS system. The encrypted data will look like random bytes of
data and will not be readable in its encrypted form without the secret key. To decrypt
11
can be used for various purposes, such as verifying the identity of the user and detecting
Data Encryption
After obtaining the data hash for the fingerprint image, we apply encryption using the
AES algorithm to ensure data security before uploading it to the IPFS. This process
ensures the immutability feature of the entire system. By encrypting the template, we
render it useless to malicious attackers, since decryption without the appropriate key is
virtually impossible, even through brute-force attacks. This step serves to augment the
The encrypted data is stored on the IPFS, which functions as a decentralized file system.
By leveraging IPFS, we reduce the gas price required to deploy smart contracts and
execute commands on the ethereum test network. After successfully storing the data on
21
6.1.4 Upload the CID on Ethereum Test Network
After obtaining the CID, we proceed to upload it onto the Ethereum test network using
Hardhat, which is an inbuilt JavaScript library. For our simulation, we utilized Georli
as our test network, as it does not entail any real monetary expenses. We created and
deployed smart contracts for data uploading and retrieval using remix IDE. Metamask
Figure 6.3: smart contracts to upload and retrive data from Ethereum Test Net
22
6.2 User Verification
In this section, we will delve into user verification, which entails collecting user input
and comparing it against the encrypted user data that we possess. Since the data we
For User Verification also we need to get inputs from user like user email and user
fingerprint. The image below shows the same.
In order to authenticate user input against the data stored in our system, it is necessary
for both sets of information to be in the same format. However, since our stored data is
encrypted, it must be decrypted prior to comparison. To encrypt the data, we utilized
23
based on the distance between their descriptors.
fingerprint image, allowing it to match fingerprints that have been rotated with respect
to each other. Overall, SIFT is a powerful fingerprint matching algorithm that can
effectively match fingerprints under a wide range of variations, making it a popular
Upon receiving the user input, we retrieved all the stored data within our system. In our
proposed system, the user’s data is compared with all other available user data to verify
its authenticity. This verification process is used to determine whether the user’s data
is already present within the system, and if not, it is subsequently added. Furthermore,
this verification procedure can be utilized to detect the manipulation or presence of
counterfeit data. If the user is verified successfully, success verdict will be shown on
user’s screen as shown below.
25
blockchain networks may prioritize smaller transactions, leading to longer confirmation
amount of gas consumed in our case is constant, regardless of the size of the input. This
makes our system more efficient and scalable.
File Size(B) Gas Consumed(in gas units) Gas consumed using our System(in gas units)
107 223559 5057
938 465001 5103
4610 665595 4080
10111 1064139 5009
12379 1383016 4912
Table 7.2: Cost analysis of Traditional system vs cost analysis of our system
Figure 7.1: Cost analysis of our system against the Traditional system
As the size of the uploaded file increases, the processing time required for the trans-
action to be included in a block on the Ethereum blockchain also increases. This is
27
because larger files consume more gas, which in turn demands more computational re-
sources and processing time. For instance, a transaction involving the upload of a small
file of a few bytes may be processed and added to a block relatively quickly. In contrast,
a transaction involving a larger file of several megabytes could take several minutes or
even hours to be processed and included in a block, depending on the congestion of the
network and the gas price set by the user. The figure below represents time analysis of
our improved system against Traditional system.
Figure 7.2: Time analysis of our system against the Traditional system
have incorporated AES encryption, which makes our system almost impervious to se-
curity breaches. AES-128 encryption offers a key space of 2128 , indicating that there
are 2128 potential keys that can be utilized for data decryption. Assuming that a hacker
gains access to a supercomputer capable of testing 1016 keys per second, it would still
take them around 1017 seconds, equivalent to 3.17 × 109 years, to perform a brute force
attack and test all possible keys.
28
Appendix A
Code Attachments
This part of code handles taking user input. When user enters his details in front end part
and clicks on enter button, events are fired in the back end. Those events are handled
by following functions.
1
2 % import e x p r e s s from "express" ;
3 % import m u l t e r from "multer" ;
4 % import F i n g e r p r i n t 2 from "fingerprintjs2" ;
5 % import * a s IPFS from "ipfs-core" ;
6
7 const upload = multer ( ) ;
8 c o n s t app = e x p r e s s ( ) ;
9 c o n s t node = a w a i t IPFS . c r e a t e ( ) ;
10
11 // use body-parser middleware to parse request bodies
12 app . u s e ( e x p r e s s . u r l e n c o d e d ( { e x t e n d e d : t r u e } ) ) ;
13
14 // set the view engine to ejs
15 app . s e t ( "view engine" , "ejs" ) ;
16
17 // render the form template
18 app . g e t ( "/" , ( r e q , r e s ) => {
19 r e s . r e n d e r ( "form" ) ;
20 }) ;
21
27 c o n s t f i n g e r p r i n t T e m p l a t e = F i n g e r p r i n t 2 . x64hash128 ( b y t e S t r i n g ) ;
28
29 c o n s t r e s u l t = a w a i t node . add ( {
30 p a t h : $ { r e q . body . e m a i l } . t x t ,
31 c o n t e n t : JSON . s t r i n g i f y ( {
32 name : r e q . body . name ,
33
33 e m a i l : r e q . body . e m a i l ,
34 hashedTemplate : f ing erp rin tTe mp lat e ,
35
36 }) ,
37 }) ;
38
39 console . log ( r e s u l t . cid . t o S t r i n g ( ) ) ;
40
41 c o n s t chunks = [ ] ;
42 f o r a w a i t ( c o n s t chunk o f node . c a t ( r e s u l t . c i d ) ) {
43 c h u n k s . p u s h ( chunk ) ;
44 }
45
46 c o n s t r e t r i e v e d M e t a d a t a = JSON . p a r s e ( c h u n k s . t o S t r i n g ( ) ) ;
47
48 console . log ( retrievedMetadata ) ;
49 }) ;
50
51 // start the server
52 c o n s t PORT = p r o c e s s . env . PORT | | 3 0 0 0 ;
53 app . l i s t e n ( PORT , ( ) => {
54 c o n s o l e . l o g ( S e r v e r l i s t e n i n g on p o r t $ {PORT} ) ;
55 }) ;
In this section we have mentioned all the steps involved in data preprocessing including
data hashing and encryption. Function to decrypt the data is also incuded here.
1
2
3
4 // using canvas to encrypt the image to binary data
5 c o n s t c a n v a s = document . c r e a t e E l e m e n t ( ’canvas’ ) ;
6
34
24
16
17
18 e x p o r t a s y n c f u n c t i o n addImageToIPFS ( i m a g e D a t a ) {
19 c o n s t a d d e d = a w a i t c l i e n t . add ( i m a g e D a t a ) ;
20 c o n s o l e . log ( added . c i d . t o S t r i n g ( ) ) ;
21 return added . c i d . t o S t r i n g ( ) ;
22 }
23
24 // function to add data on ipfs
25
26 a s y n c f u n c t i o n add ( ) {
27 c o n s t i m a g e U r l = ’https://imageurl.jpg’ ;
28 c o n s t response = await f e t c h ( imageUrl ) ;
29 c o n s t imageData = a w a i t r e s p o n s e . blob ( ) ;
30 c o n s t c i d = a w a i t addImageToIPFS ( i m a g e D a t a ) ;
31 c o n s o l e . l o g ( Image a d d e d t o IPFS w i t h CID $ { c i d } ) ;
32 }
33
34 add ( ) ;
35
A.4 FingerPrint Matching
1 // Define the fingerprints to compare
2 c o n s t f i n g e r p r i n t 1 = document . g e t E l e m e n t B y I d ( ’fingerprint1’ ) ;
3 c o n s t f i n g e r p r i n t 2 = document . g e t E l e m e n t B y I d ( ’fingerprint2’ ) ;
4
5 // Load the jsfeat library
6 j s f e a t = r e q u i r e ( ’jsfeat’ ) ;
7
36
50 f i l t e r e d M a t c h e s . push ( matches [ i ] ) ;
51 }
52 }
53 return f i l t e r e d M a t c h e s ;
54 }
55
56 // Call the SIFT functions to compare the fingerprints
57 const keypoints1 = detectFeatures ( fingerprint1 ) ;
58 const keypoints2 = detectFeatures ( fingerprint2 ) ;
59 const descriptors1 = computeDescriptors ( fingerprint1 , keypoints1 ) ;
60 const descriptors2 = computeDescriptors ( fingerprint2 , keypoints2 ) ;
61 const matches = m at c h De s c ri p t o rs ( d e s c r i p t o r s 1 , d e s c r i p t o r s 2 ) ;
62
This sections provides the smart contracts written in solidity language. The smart con-
26 % C o n t r a c t t o u p l o a d and r e t r i v e d a t a
27
28 pragma s o l i d i t y >=0.7.0 < 0 . 9 . 0 ;
29
30 c o n t r a c t ImageUpload {
31
32 / / D e c l a r e a b y t e s v a r i a b l e t o s t o r e t h e image
33 b y t e s p u b l i c image ;
34
37
35 / / D e c l a r e an e v e n t t o e m i t when a new image i s u p l o a d e d
36 e v e n t NewImage ( b y t e s i m a g e ) ;
37
38 / / F u n c t i o n t o u p l o a d t h e image t o t h e b l o c k c h a i n
39 f u n c t i o n u p l o a d I m a g e ( s t r i n g memory i m a g e ) p u b l i c {
40 image = b y t e s ( i m a g e ) ;
41 e m i t NewImage ( image ) ;
42 }
43
44 / / F u n c t i o n t o g e t t h e u p l o a d e d image
45 f u n c t i o n g e t I m a g e ( ) p u b l i c view r e t u r n s ( b y t e s memory ) {
46 r e t u r n image ;
47 }
48
49 }
38