Official implementation for CryptoFace: End-to-End Encrypted Face Recognition. The paper is presented at CVPR 2025.
We encrypt face images to provide biometric and database security.
Face recognition is central to many authentication, security, and personalized applications. Yet, it suffers from significant privacy risks, particularly arising from unauthorized access to sensitive biometric data. This paper introduces CryptoFace, the first end-to-end encrypted face recognition system with fully homomorphic encryption (FHE). It enables secure processing of facial data across all stages of a face-recognition process—feature extraction, storage, and matching—without exposing raw images or features. We introduce a mixture of shallow patch convolutional networks to support higher-dimensional tensors via patch-based processing while reducing the multiplicative depth and, thus, inference latency. Parallel FHE evaluation of these networks ensures near-resolution-independent latency. On standard face recognition benchmarks, CryptoFace significantly accelerates inference and increases verification accuracy compared to the state-of-the-art FHE neural networks adapted for face recognition. CryptoFace will facilitate secure face recognition systems requiring robust and provable security.@inproceedings{ao2025cryptoface,
title={{CryptoFace}: End-to-End Encrypted Face Recognition},
author={Ao, Wei and Boddeti, Vishnu Naresh},
booktitle = {CVPR},
year = {2025},
pages = {19197-19206},
month = {June}
}
conda create -n cryptoface python=3.9
conda activate cryptoface
pip install -U scikit-learn
pip install mxnet wandb tqdm
conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia
pip uninstall numpy
pip install numpy==1.23.1
pip install einops
pip3 install multipledispatchPlease download training dataset and evaluation datasets from InsightFace.
You can download checkpoints from Google Drive.
| Architecture | Input Resolution | Parameters | Link |
|---|---|---|---|
| CryptoFaceNet4 | 0.94M | Google Drive | |
| CryptoFaceNet9 | 2.12M | Google Drive | |
| CryptoFaceNet16 | 3.78M | Google Drive |
You can train models from scratch.
python train.py config.yamlInstall GMP
wget https://gmplib.org/download/gmp/gmp-6.3.0.tar.xz
tar -xf gmp-6.3.0.tar.xz
cd gmp-6.3.0
./configure
make
make check
sudo make installInstall NTL
wget https://www.shoup.net/ntl/ntl-11.5.1.tar.gz
tar -xf ntl-11.5.1.tar.gz
cd ntl-11.5.1/src
./configure NTL_GMP_LIP=on
make
make check
sudo make installInstall OpenMP
sudo apt-get update
sudo apt-get install libomp-devCompile and Install SEAL
cd cnn_ckks/cpu-ckks/single-key/seal-modified-3.6.6
cmake -S . -B build
cmake --build build
sudo cmake --install buildCompile CNNs
cd cnn_ckks
cmake -S . -B build
cd build
makeYou can download off-the-shelf model weights for FHE Inference from Google Drive. We provide all CKKS weights for CryptoFaceNets, AutoFHE and MPCNN.
You can use our script to transfer PyTorch weights to txt files.
python ckks.py config.yaml --output-dir <PATH>/ckks_model --ckpt-path <PATH>/model.ckptYou can use our script to transfer evaluation dataset bin files to txt files. (input-size: 64, 96 or 128)
# Not patched images
python datasets.py <PATH>/faces_emore -o <PATH>/faces_emore_patch --not-use-patch --input-size 64# Patched images
python datasets.py <PATH>/faces_emore -o <PATH>/faces_emore_patch --use-patch --input-size 64Benchmark baselines ./cnn [algorithm] [model] [dataset] [path_to_weight] [path_to_dataset] [path_to_output] [img_start_id] [img_end_id]
# MPCNN ResNet32
mkdir <PATH>/ckks_result/mpcnn/resnet32
./cnn mpcnn resnet32 lfw 0 <PATH>/ckks_model <PATH>/faces_emore <PATH>/ckks_result 0 1
# MPCNN ResNet44
mkdir <PATH>/ckks_result/mpcnn/resnet44
./cnn mpcnn resnet44 lfw 0 <PATH>/ckks_model <PATH>/faces_emore <PATH>/ckks_result 0 1
# AutoFHE ResNet32
mkdir <PATH>/ckks_result/autofhe/resnet32
./cnn autofhe resnet32 lfw 0 <PATH>/ckks_model <PATH>/faces_emore <PATH>/ckks_result 0 1Benchmark CryptoFace ./cnn [algorithm] [input_size] [dataset] [path_to_weight] [path_to_dataset] [path_to_output] [img_start_id] [img_end_id]
# CryptoFace 64x64
mkdir <PATH>/ckks_result/cryptoface/64
./cnn cryptoface 64 lfw 0 <PATH>/ckks_model <PATH>/faces_emore_patch <PATH>/ckks_result 0 1
# CryptoFace 96x96
mkdir <PATH>/ckks_result/cryptoface/96
./cnn cryptoface 96 lfw 0 <PATH>/ckks_model <PATH>/faces_emore_patch <PATH>/ckks_result 0 1
# CryptoFace 128x128
mkdir <PATH>/ckks_result/cryptoface/128
./cnn cryptoface 128 lfw 0 <PATH>/ckks_model <PATH>/faces_emore_patch <PATH>/ckks_result 0 1The C++ implementation is built on top of
[1] https://github.com/human-analysis/AutoFHE
[2] https://github.com/snu-ccl/FHE-MP-CNN.
The Python implementation of ArcFace Head and Evaluation Utils is from