Biometric Template Protection (BTP) is an important component in biometric systems, aimed at protecting sensitive biometric data from being compromised. However, BTP can often be a complex topic difficult to understand for beginners. This repository provides a basic and simplified implementation of a BTP scheme for educational purposes.
My goal is to demonstrate the fundamental concepts of template protection using a simple cryptographic technique, rather than creating a production ready system designed for secure deployment.
This simplified scheme consists of two main phases: Enrollment and Authentication.
- The biometric data (represented as an embedding
embedding1
) is first quantized into a binary vector (bit_vector1
). - A
secret_key
is generated, which is a random binary vector of the same length asbit_vector1
. - The client then encrypts the binarized template by XORing
bit_vector1
with thesecret_key
to createcipher1
. - The client stores the
secret_key
and sendscipher1
to the server for later authentication.
- During authentication, a new biometric sample (
embedding2
) is captured and quantized tobit_vector2
. - The client XORs
bit_vector2
with the storedsecret_key
to createcipher2
. - The server calculates the Hamming distance between
cipher1
(from enrollment) andcipher2
(from authentication). - If the Hamming distance is below a certain threshold, the user is authenticated.
-
Data Leakage: While the exact bits of the cipher cannot be directly determined without the secret key, the server is able to see which authentication bits differ from the enrollment, which may in time reveal details about the vector's entropy. Particularly, the server can use the differences across several users to determine which bits are reliable, similar to an Attack via Record Multiplicity. Cross-user weaknesses like this can be mitigated by performing a client-side random permutation on the enrollment vector for each user, and storing the permute order for future authentications.
-
Full Access Adversary: If the adversary has access to both the client and server, they will be able to decrypt the original enrollment
bit_vector
by performing XOR on the client'ssecret_key
and the server'scipher
.
-
Clone the repository:
git clone https://github.com/templateprotection/basic-btp.git cd btp-scheme
-
Install the required dependencies:
pip install -r requirements.txt
-
Run the code:
python btp.py