The Python code

Now that we have our fingerprint reader hooked up and the PyFingerprint library installed, we can start looking at the Python code used for this project.

Before looking at the code itself, we should take a moment to get a general idea on how it works.

The code used for this project is split into two separate Python scripts. One script is used for uploading new fingerprints to the IOTA tangle. The other is used for validating against existing fingerprints stored on the tangle.

First, let’s look at the process of uploading new fingerprints to the tangle.

The general idea here is that each user (or in our case, each hotel employee who needs access to the safe) is provided with a unique IOTA seed. This seed will then be used to generate an IOTA address that further will be used when uploading fingerprint data (belonging to that particular employee) to the IOTA tangle. The fingerprint data itself is created by the reader and sent to the tangle in the form of a bundle of transactions. Each transaction inside the bundle holds a part of the fingerprint data inside its message fragment. Notice that there will be one bundle for each individual fingerprint. You may upload as many fingerprint bundles as you want. You may even upload multiple fingerprint bundles of each finger. Just notice that the more bundles you upload, the longer it will take to download them later on when they are used for validation. Also notice that the ZhianTec ZMF reader has a limit of 1000 prints being stored in memory at the same time.

Next, let’s look at the process of validating a fingerprint taken on the reader with existing fingerprints stored on the tangle.

The process starts with an employee wanting to access the safe. The script will then ask for his/her seed so that we know what IOTA seed to use when searching for his/her fingerprint bundles on the tangle. Next, the script starts downloading all the employees fingerprint bundles, while at the same time uploading them to the internal memory of the reader. Finally, the employee will be asked to put a finger on the reader. If the reader finds a match between the fingerprint being taken, and a fingerprint stored in the reader memory, we have a match, and the employee have been authenticated.

Note!

As mentioned, the validation script require a valid IOTA seed as input. However, can it really be expected that every employee can remember, or even type, a 81 character seed whenever they need to access the safe? Probably not. This problem could however be solved using some other technology discussed in a previous tutorial, namely RFID. The seed could be stored on the employees ID card, adding an additional level of security. You would now have to have both a valid employee ID card and a valid fingerprint to access the safe.

Here is the script for uploading fingerprints to the tangle..

The source code for this python script can be downloaded from here

And here is the script for validating a new fingerprint against existing prints stored on the tangle..

The source code for this python script can be downloaded from here