Skip to main content

bauta-rs

The optional native masker for Bauta.

Bauta masks data on its way from production to a copy. Masking key and fpe columns costs tens of microseconds a value in Python, most of it spent in the interpreter rather than in cryptography. This computes the same masks in Rust, about ten times faster on a whole job on one core, and can use several.

It is optional. Bauta works without it, and produces identical output either way.

Installing

pip install "bauta[native]"

The extra installs the bauta-rs released with your version of bauta, which is the only one Bauta uses; any other is ignored with a warning. Wheels cover Linux (x86-64 and ARM) and macOS (Apple silicon and Intel) on every supported Python. Elsewhere pip compiles it, which needs Rust 1.83 or newer.

Layout

Path What it is
core/ The constructions. No Python dependency, so they are testable without an interpreter.
py/ The PyO3 layer: conversions in, results out, and every unsafe boundary.
vectors/reference.json What the Python implementation produces, recorded. The contract between the two. Its pythonOnly section records the strategies with no port, so Python can't change those masks unnoticed either; nothing here reads it.
generate_vectors.py Regenerates that file from the Python implementation.

Building

From a clone, with Rust 1.83 or newer.

cargo test --release
cd py && maturin build --release
pip install ../target/wheels/bauta_rs-*.whl

--release matters: two tests measure SHA-256 and AES throughput to catch a backend fallen back to software, which a debug build looks like. py/ needs Python to link, so tests/masking/test_nativeMasking.py tests it. See development for the rest.

Threads, and remembering masks

A chunk's distinct values are masked across a thread pool, whose size the Python layer sets per process (setThreads) from jobs.yaml's maskingThreads; each mask depends on its value alone, so the count changes no result. availableCores() reads a container's CPU quota, which Python's os.cpu_count() doesn't. key, fpe and the fake* strategies also remember masks across chunks. The extension allocates through mimalloc: the system allocators serialise masking's many small allocations across threads. It is mimalloc 2, not the crate's default 3, which crashed the process once a thread other than Python's main one had loaded the extension.

Machine integers where they fit

key's Feistel network and fpe's FF1 rounds each have two paths: one in u64 halves, taken wherever the values fit -- any key domain up to 2**128, and FF1 halves of up to 19 decimal digits, which is every identifier in practice -- and the original in BigUint for anything wider. Both hash and encrypt exactly the same bytes; the first only skips allocating a big integer every round, which was 40% of a key mask and three quarters of an fpe one. Unit tests run both paths over every width the fast one takes and require the same result, and the vectors cover each side of both boundaries.

Integers cross the Python boundary the same way: as an i64 through the C API where they fit, and as a BigInt otherwise. The extension is built against the stable ABI (abi3), where PyO3 converts a BigInt by calling int.to_bytes and int.from_bytes -- a Python call per value, made while every masking thread waits for the results.

The rule

Python is the reference. This crate exists to be faster, not to be different. Where the two disagree, Python is right.

A difference between the two would surface not as a wrong answer but as what looks like a changed key: joins between an old copy and a new one quietly stopping matching, with the key fingerprint unchanged. So every covered strategy is checked against vectors/reference.json, values depending on Python's Unicode rules are handed back to Python rather than reimplemented, and FF1 and the keyed hash are checked against NIST's and RFC 4231's vectors. See two implementations.

What it covers

key, fpe, hash, email, digits, number, redact, and the fake* strategies, which pick from the lists Python passes in when a masker is built -- so the lists are defined once, in Python, and the vectors record them. number (core/src/number.rs) reproduces Python's decimal arithmetic at 60 digits for the operations it uses, and hands back zeros, non-finite values and anything that would take Python's rounding past what it reproduces.

redact (core/src/redact.rs) finds what Python's six regular expressions find, on the regex crate, which has no lookaround. Each lookbehind is checked by hand against the character before a match, and each lookahead is one more character the pattern consumes and trims off again, which leftmost-first matching settles on where Python's backtracking does. fancy-regex, which has lookaround, was slower than Python. Text outside ASCII goes back to Python, and so does a policy with patterns of its own, whose regular expressions only Python's re is sure to read as Python does.

Everything else stays in Python: shuffle, dateShift, keep, null and constant are already cheap -- dateShift derives one shift per day, and a column holds a few thousand days -- and custom strategies are Python by definition.

Metadata

Release files for bauta-rs 0.2.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bauta-rs 0.2.12
File Size Uploaded Provenance Actions
bauta_rs-0.2.12.tar.gz 53.8 kB With provenance Details for bauta_rs-0.2.12.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for bauta-rs 0.2.12
File Actions
bauta_rs-0.2.12-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for bauta_rs-0.2.12-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
bauta_rs-0.2.12-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for bauta_rs-0.2.12-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
bauta_rs-0.2.12-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for bauta_rs-0.2.12-cp310-abi3-macosx_11_0_arm64.whl
bauta_rs-0.2.12-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for bauta_rs-0.2.12-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 3.4 MB

Release files / bauta_rs-0.2.12.tar.gz

Download URL bauta_rs-0.2.12.tar.gz
Size 53.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b94d67621c78e71fa79dd0c00a0be6b75dae79a532e33796c602772ef11c4f88
BLAKE2b-256 checksum
How to use checksums
2b1282ce08fba49b732421344d0394038ad75933ac6aa5a7d090c17d929e5ead
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

Release files / bauta_rs-0.2.12-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL bauta_rs-0.2.12-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 895.5 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
efafb1b478d68c5626b3fa1a4b5f5835f8987aeb8b6d089392cc74d14209fc07
BLAKE2b-256 checksum
How to use checksums
edb2a854318dca3060ebcc3e936a008fa0b001bd60ddb5b2e3623f0aa285dd7a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

Release files / bauta_rs-0.2.12-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL bauta_rs-0.2.12-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 852.8 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
7bd0eae40576f9a0de9f8d8067b48d8343e51844aa8c8f123bbca7731c1f8d67
BLAKE2b-256 checksum
How to use checksums
530a955b12171d0ea943c3365399940b368a51865ef63552b8389cfc796ed801
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

Release files / bauta_rs-0.2.12-cp310-abi3-macosx_11_0_arm64.whl

Download URL bauta_rs-0.2.12-cp310-abi3-macosx_11_0_arm64.whl
Size 766.5 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
33c130e5e0b0b469f1f57bc0af7956601a4635a59ea5bd987fd36ca7fa29af72
BLAKE2b-256 checksum
How to use checksums
17eb6c4f145c955f13efa116c1da74ab5e03f4ffa8a81d0ec81aeb4178a89bfa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

Release files / bauta_rs-0.2.12-cp310-abi3-macosx_10_12_x86_64.whl

Download URL bauta_rs-0.2.12-cp310-abi3-macosx_10_12_x86_64.whl
Size 847.7 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
b7a8161521900e208f4d80e0b1c5c0cf01675a25bd835d4b843c8ead5df2aa93
BLAKE2b-256 checksum
How to use checksums
7764ddebce825702471018cceb5832659d83073142bfac03e6923dede7a3fc10
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

Security for bauta-rs 0.2.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for bauta_rs-0.2.12.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page