Free-text keystroke authentication using transformers: a comparative study of architectures and loss functions

Saleh Momeni, Bagher BabaAli · DOI

Abstract

Researchers have established a new benchmark in keystroke biometrics by replacing traditional Recurrent Neural Networks (RNNs) with Transformer architectures. By framing free-text typing patterns as a contrastive learning problem and utilizing anomaly detection for scoring, the proposed system achieves a record-breaking Equal Error Rate (EER) of 0.0163% on the Aalto dataset. This study compares Bi-encoder and Cross-encoder architectures, various contrastive loss functions, and distance metrics to identify the optimal configuration for behavioral authentication.

Introduction

Keystroke dynamics—the unique rhythm and timing of a user's typing—provide a non-intrusive method for identity verification. While "fixed-text" authentication (e.g., passwords) is relatively straightforward, "free-text" authentication presents significant challenges due to variations in typing rhythm caused by factors such as stress, fatigue, or linguistic context.

Previous state-of-the-art models primarily relied on Recurrent Neural Networks (RNNs) or Long Short-Term Memory (LSTM) networks. However, these architectures often struggle with long-range dependencies and lack the scalability required for massive biometric datasets. This paper explores whether Transformer architectures, which have revolutionized Natural Language Processing, can provide a significant leap in accuracy and efficiency for behavioral biometrics.

Methodology

The researchers developed a Transformer-based pipeline and evaluated it across three primary dimensions: architecture, loss functions, and feature engineering.

Model Architectures

The study compared two primary Transformer configurations:

  1. Bi-encoders: These process two typing samples independently to generate vector representations, which are then compared using a distance metric.
  2. Cross-encoders: These process two samples simultaneously, allowing the model to capture direct interactions between the sequences.
Comparison of Bi-Encoder and Cross-Encoder architectures for keystroke authentication.

Loss Functions and Features

To optimize the model for identity verification, several contrastive learning objectives were tested, including standard Triplet loss, Batch-all Triplet loss, and Weighted Decoupled Contrastive Learning (WDCL).

The input features consist of 10 channels: five temporal features (such as hold latency and press latency) and five spatial features derived from learnable keyboard position embeddings. The model was trained and evaluated on the Aalto desktop keystroke dataset, which contains data from over 168,000 participants.

Results and Discussion

The experimental results demonstrate that Transformers significantly outperform previous gold-standard models like TypeNet (an LSTM-based approach).

Architecture and Metric Performance

A key finding was that the Bi-encoder architecture, when paired with appropriate loss functions, actually outperformed the Cross-encoder while remaining computationally more efficient. Additionally, Cosine distance was found to be the most effective metric for triplet-based losses, consistently surpassing Euclidean and Manhattan distances.

Equal Error Rate (EER) performance across different architectures, loss functions, and enrollment sizes (E).

State-of-the-Art Accuracy

The optimal configuration—a Bi-encoder trained with Batch-all Triplet loss using Cosine distance—achieved an EER of 0.0186% with 10 enrollment samples ($E=10$). The researchers further improved this by treating the verification phase as an anomaly detection problem. By employing a One-class Support Vector Machine (SVM) to define the boundary of a user's typing behavior, the EER was reduced to a record 0.0163%. For comparison, the previous state-of-the-art TypeNet model reported EERs between 1.2% and 1.6% on the same dataset.

Conclusion

This study confirms that Transformers are exceptionally well-suited for capturing the complex temporal and spatial signatures of human typing. While the results are highly promising, future work should address the model's generalization across different languages and its robustness against adversarial mimicry attacks. Integrating keystroke dynamics with other behavioral markers remains a compelling path toward even more secure multi-modal biometric systems.

Summary updated

BibTeX
@misc{momeni2023free,
  author = {Saleh Momeni and Bagher BabaAli},
  title = {{Free-text keystroke authentication using transformers: a comparative study of architectures and loss functions}},
  year = {2023},
  eprint = {2310.11640},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2310.11640},
}
Figure