Overview
Face Liveness is a library that checks whether the person in front of a camera is a live human. A shared Rust core does face detection, landmarks, blink, mouth and head-turn challenges, and passive anti-spoofing, and thin bindings expose it to Python, Node.js and the browser through WebAssembly.
I designed and built it in phases over a few days: core detectors, an ONNX vision pipeline in pure Rust, language packages, signed receipts for server-side verification, and a browser demo. It is in early development and the README says so.
The challenge
Identity checks that rely on a selfie are easy to fool with a printed photo or a screen. Liveness libraries exist, but they tend to be tied to one language or one cloud service, so a team using Python on the server and JavaScript in the browser ends up with two different implementations.
The detectors also need tuning on real recordings, because blink and head-turn thresholds differ between faces and cameras.
The goal
Write the logic once in Rust and make it identical everywhere it runs.
- 01Detect blinks, mouth opening and head turns with thresholds that adapt to each face.
- 02Find faces and 478 landmarks from raw frames in pure Rust, without calling Python.
- 03Ship Python, Node.js and browser packages that give the same results as the core.
- 04Let a server verify the outcome with signed tickets and receipts instead of trusting the client.
One core, several bindings
The repository is a Rust workspace. liveness-core holds the detectors, challenge flow and vision code. liveness-py (PyO3 and maturin), liveness-node (napi-rs) and liveness-wasm (wasm-bindgen) are thin wrappers. Shared conformance cases in tests/conformance/cases.json check that Rust, Python and Node return identical results.
Detectors tuned on recordings
Per-frame face measurements from recorded sessions are stored as CSV fixtures, so the detectors can be replayed and tuned without keeping any images. A replay example prints every detected blink, mouth-open and head turn, the totals and the cost per frame, and can sweep blink counts across thresholds. Face detection and landmarks run as MediaPipe models converted to ONNX and executed in pure Rust, and I compared the output with MediaPipe itself.
Anti-spoofing and signed receipts
A random challenge sequence with time limits stops printed photos, since a photo cannot blink and tilting it does not register as a head turn. A passive MiniFASNet model scores print and screen texture, currently report-only until a threshold is calibrated. For servers, signed tickets fix the challenges and Ed25519 JWT receipts carry the outcome and a SHA-256 chain over every frame.
- 01The best frame is aligned for face recognition and bound to the signed receipt.
- 02The threat model lists what is not defended: live deepfakes, injected virtual cameras and 3D masks.
Browser demo
The same engine compiles to WebAssembly and runs in a demo page, either fully on the device or with a small Node server that verifies the result and issues signed receipts. A GitHub Actions workflow is set up to publish the on-device version to GitHub Pages.
The outcome
Face Liveness has a working Rust core, Python and Node packages, a WebAssembly build and a signed-receipt flow, with CI and a documented threat model. It is early-stage and not claimed to be production-ready, but it shows a multi-language Rust library built and tested across bindings.


