Security
What an attacker holding the encrypted data can and cannot learn from it. The analysis assumes a specific threat model, set out below, and tests it against attacks that are given more information than a real attacker would have.
- Possible sets of plaintext coordinates for one MNIST-sized example encrypted to 1,176 values
- What the inference oracle returns to anyone who queries it
- Labels only
- Attacker's reconstruction error (MAE) vs guessing a blank image
- 0.241 vs 0.173
How many ways the data could be hidden
Padding adds values that carry no information. After the shuffle and the orthogonal transformation, an attacker has to work out which coordinates held the original data, without knowing how many there were. The number of possibilities grows with every coordinate added. Move the slider to see how quickly.
Possible sets of plaintext coordinates, if the plaintext dimension is unknown
The same, even if the plaintext dimension were known (padding adds 50%)
Degrees of freedom of the secret orthogonal matrix
The threat model
A data owner encrypts its data and sends the encrypted data and the labels to another party to train a network. An attacker may intercept both, or be part of the training party. Later, anyone, including the attacker, can send an example of their own to the owner's inference oracle and receive a predicted label.
- Data owner (A)
- Holds the plaintext data, the labels and the secret key. Encrypts the data and sends it, with the labels, for training.
- Trainer (B)
- Trains a network on the encrypted data and labels.
- Attacker (C)
- May intercept the encrypted data and labels, or be part of the training party. Can also query the inference oracle with its own examples, which are not from the training data.
- Inference oracle
- Run by the data owner. Encrypts each submitted example privately, runs the trained network, deletes the encrypted example and returns only the predicted label.
The attacker holds
- The encrypted training data and its labels
- Its own examples, which it can submit to the inference oracle
- The label the oracle returns for each of them
The attacker never sees
- The original training data
- The secret key: the padding positions, the shuffle and the orthogonal matrix
- The encrypted version of its own examples
- How many dimensions the original data had
What is deliberately preserved
Each padded example is multiplied by the same secret shuffle and orthogonal matrix, which together form one orthogonal matrix:
Because the matrix is orthogonal, the inner products between examples are unchanged:
so the lengths of the examples, the angles between them and the distances between them are all unchanged:
This is intentional: it is the information a neural network learns from, and it is why training on encrypted data works. It is also information available to an attacker, which is why the rest of this page tests what can be done with it.
- Coordinates of the circled point
- (−0.69, 0.83)
- Distance between the two groups
- 2.61
Measured across 1,000 random pairs of encrypted MNIST examples, the largest change the shuffle and rotation made was degrees in angle and in distance: floating-point rounding. Padding and perturbation are the only steps that change the geometry, by amounts set in configuration.
Lengths, angles and distances for three example pairs
| Example pair | Stage | Length | Angle | Distance |
|---|---|---|---|---|
| 1 and 2 | Plaintext | 7.692 | 78.839° | 11.269 |
| Padded + perturbed | 8.869 | 70.374° | 11.439 | |
| Encrypted | 8.869 | 70.374° | 11.439 | |
| 3 and 4 | Plaintext | 5.541 | 75.799° | 11.382 |
| Padded + perturbed | 6.919 | 69.071° | 11.642 | |
| Encrypted | 6.919 | 69.071° | 11.642 | |
| 5 and 6 | Plaintext | 7.825 | 84.950° | 9.915 |
| Padded + perturbed | 8.730 | 74.475° | 10.135 | |
| Encrypted | 8.730 | 74.475° | 10.135 |
Computed on MNIST test examples. The encrypted rows match the padded and perturbed rows to every decimal shown.
What stays hidden: which coordinates are real
Before the rotation, some coordinates held the original data and the rest held padding. To recover the data, an attacker has to identify which. If they knew the original dimension , the number of possible choices among coordinates would be
They do not know , only that it is smaller than . Every possible dimension has to be considered, which gives
possible sets of plaintext coordinates: the numbers in the counter at the top of this page. Knowledge of the data's statistics can make some choices more plausible than others; the attacks below test how far that helps.
Coordinate mixing
Each encrypted coordinate is a weighted mix of every padded coordinate, so structure in the plaintext disappears from the value distributions. Starting from the 8,258 five-letter words in an English dictionary, the first letter's distribution shows the structure of English; after encryption the same coordinate fits a Gaussian distribution.
A single plaintext coordinate reaches all of the ciphertext coordinates
Move over the plaintext image, or drag on a touch screen. The selected pixel's value is spread as small positive and negative weights across all of the coordinates of the ciphertext.
Before encryption
One pixel = one value
After encryption
Its weight in all coordinates
The plaintext is one Fashion-MNIST example, an ankle boot. Illustration only. Each pixel’s weights here are seeded random noise scaled so the squared weights sum to 1, which is how a row of a random orthogonal matrix behaves. A real Tensorlock key gives every pixel its own fixed pattern of the same kind; the pixel is spread out, not lost.
The inference oracle
The attacker can send its own examples to the data owner's inference oracle. The oracle encrypts each one privately, runs the trained network and returns only the predicted label:
The encrypted version of the example is deleted and never returned. The attacker therefore gets no equations of the form
linking its own plaintext to ciphertext. Labels tell it about the trained network's decisions, not about the secret key, and are not enough to solve for the orthogonal matrix.
The search space
Without knowledge of the plaintext's structure, reversing the encryption means searching for the orthogonal matrix and for which coordinates held the plaintext, then accounting for the perturbation. The manuscript sizes these searches for a 784-value plaintext, such as an MNIST image, encrypted to 1,176 values.
| Quantity | Size |
|---|---|
| Degrees of freedom of the orthogonal matrix | |
| Distinguishable orthogonal matrices at double precision About 53 bits per degree of freedom: an illustration of scale, as the manuscript notes, not a cryptographic key count | |
| Possible signal-coordinate subsets, plaintext dimension unknown | |
| Possible signal-coordinate subsets, even if the plaintext dimension were known | |
| Possible index shuffles |
The attacker also does not know which steps were applied, in what order, how many times, or with which parameters.
Modeled attacks with reference data
The strongest modeled attacker exploits what the encryption deliberately preserves. Because the same orthogonal matrix is applied to every example, the covariance of the encrypted data is a rotation of the covariance of the padded data, with the same eigenvalues:
An attacker holding reference data with the same covariance structure can try to match eigenvalues, pair eigenvectors and resolve their signs. The experiments give the attacker the plaintext dimension and an exact or near-exact reference dataset, then weaken the reference slightly.
- Encryption attacked
- Interlaced padding adding 50% to the dimensions, ±5% perturbation with clipping, shuffle, orthogonal transformation.
- Paired error
- Mean absolute error between each recovered example and its true original, per value on a 0–1 scale. Two random vectors score about 0.333.
- Same-class error
- The same measure against other examples of the same class. A paired error no lower than this means nothing specific to the example was recovered.
Exact and near-exact reference
| Reference | Encrypted data | Paired error | Same-class error |
|---|---|---|---|
| Fashion-MNIST | Fashion-MNIST, row-shuffled | 0.109 | 0.223 |
| MNIST | MNIST, row-shuffled | 0.082 | 0.179 |
| MNIST | EMNIST Digits | 0.241 | 0.236 |
With an exact copy of the dataset in shuffled order, some recovery is possible. With MNIST as the reference for EMNIST Digits (the same subject, with slightly different covariance), the paired error rises to 0.241: worse than guessing a blank image, which scores 0.173 on the same examples. It is also no lower than the same-class error of 0.236, so nothing specific to each example is recovered. Sharpening the encrypted images slightly relative to the reference has the same effect, raising the paired error from 0.110 to 0.208.


















The near-exact case: one typical example per digit, each original above the attacker's reconstruction. Ten re-runs gave paired errors of 0.2384–0.2426, consistent with the reported 0.241. On average each reconstruction was no closer to its true original than to a random image of the same class (−1.2%). The blank-image baseline uses the same metric on the same examples.
Advanced padding and perturbation
Uniform random padding leaves a trace: its covariance eigenvalues cluster near , the variance of a uniform value on [0, 1], a plateau that can help an attacker identify padding coordinates. Padding generated from the data's own principal components, with a structured nonlinear perturbation, removes the plateau. On MNIST the attacker then found 195 of 392 padding coordinates instead of all 392, and the paired error rose from 0.082 to 0.140, even with an exact reference and the plaintext dimension known.
| Data | Padding and perturbation | Paired error | Same-class error | Padding coordinates found |
|---|---|---|---|---|
| MNIST | Uniform random | 0.082 | 0.179 | 392 / 392 |
| MNIST | PCA bootstrap padding, structured nonlinear perturbation | 0.140 | 0.190 | 195 / 392 |
| Fashion-MNIST | Uniform random | 0.109 | 0.223 | 392 / 392 |
| Fashion-MNIST | PCA bootstrap padding, structured nonlinear perturbation | 0.171 | 0.240 | 355 / 392 |
Plaintext dimension unknown
Without the plaintext dimension, the attacker must also search for it. Even against uniform padding, with the search tuned to it, the tested strategies almost never found the right dimension; when they came close, fewer than 70% of the coordinates chosen as plaintext were correct. Against advanced padding and perturbation they obtained no meaningful recovery, padding identification or estimate of the dimension.
Manuscript, Tables 2 and 3, Figures 7 to 9, and §'Unknown d' attack modeling.
The attack on encrypted text
An image that is recovered approximately can still be recognizable. Records, tables, time series and text cannot be: a number that is slightly off is a different number, and a character that is slightly off is a different character. For this kind of data, anything short of exact recovery is wrong data.
Below, one Wikipedia passage in each of ten languages goes through each step of the encryption, then through the strongest attack modeled: the attacker holds an identical copy of the dataset and knows the plaintext dimension. Each passage is 784 characters, stored as one byte per value.
The first 160 of the passage’s 784 characters. Each character is one value, its byte code.
392 padding values, generated from the statistics of the data, are inserted at secret positions, making 1,176 values. The original characters move to make room.
Random noise nudges every value up or down (standard deviation 5% of the byte range), so each character shifts to a nearby one.
A secret orthogonal transformation mixes all 1,176 values: every encrypted value depends on every value before it. The encrypted values are real numbers, shown here as characters for display only.
The attacker holds an identical copy of the dataset and knows the plaintext dimension. It compares the shape of its copy with the shape of the encrypted data: their principal directions, and how far the data spreads along each (the eigenvalues). It pairs each of its 784 directions with one of the 1,176 encrypted ones, then chooses which way each points.
The attacker’s reconstruction, from those pairings. Each wrong character is colored by how far its value is from the original. Exact Wrong by byte levels 13296+
Point at or tap a character to compare it with the original.
Across 10,000 test passages, 0.81% of reconstructed characters were exactly right. Compared with a different passage in the same language, the same reconstructions match 0.80%: nothing specific to the passage was recovered. Guessing a space for every character would get 16.1% right.
Characters exactly right
Why one orthogonal matrix is not enough
A single orthogonal matrix has been proposed on its own for machine learning on protected data. Its weakness is that it can be solved for directly. If an attacker has enough plaintext examples and their encrypted versions, arranged as the rows of square matrices and , then
This does not carry over to Tensorlock. Padding changes the dimension, and each example gets its own padding and perturbation, so no single fixed matrix maps the original values to the encrypted ones. An attacker would first have to recover the hidden padded representation and account for the perturbation before the orthogonal matrix could be reversed.
Security parameters
Like the key size in a conventional cipher, these settings can be turned up to strengthen the encryption for a given project, at some cost in accuracy (see the Results page):
- Padding extent
- How many values are added to each example.
- Padding location
- External, after the original values, or interlaced among them, in one block or scattered.
- Padding values
- Uniform or Gaussian random values, values sampled from the data, or values generated from the data’s structure.
- Perturbation function
- Random shifts within a bound, or other functions, including nonlinear and structured perturbations.
- Perturbation range
- The bounds on each change.
- Edge handling
- Clipping or reflection when a perturbation would take a value out of range.
- Rounds
- Repeating the sequence, changing its order, varying the settings in each round, or leaving steps out.
- Block matrices
- For very large vectors, splitting them into blocks, each with its own orthogonal matrix or shuffle. The result is still one orthogonal transformation.
Compared with other approaches
- Federated learning
- Training software runs inside the data owner’s systems, with direct access to the data, and the updated model is sent back to the developer. The owner has to trust both the software and what leaves with the model. Combining many contributors’ updates also obscures the value of any one organization’s data.
- Fully homomorphic encryption
- Computation on encrypted data with strong cryptographic guarantees, but many orders of magnitude slower than ordinary computation, and it needs substantial changes to how networks are built. In one early study, training a network on MNIST downsampled to 8 × 8 pixels took between 40 minutes and 1.5 days.
- Instance encoding (InstaHide, NeuraCrypt)
- Earlier methods that transform each example before training. Both were shown to be vulnerable to attacks that exploit their specific structure: InstaHide’s mixing and sign flips, and NeuraCrypt’s position encoding.
- Trusted execution environments (DarKnight, AsymML)
- Data is decrypted inside secure hardware. Side-channel attacks on that hardware are outside these schemes’ scope, and splitting training between secure hardware and GPUs costs time: AsymML still runs about 15 times slower than plaintext GPU training.
- Differential privacy
- Limits what a trained model reveals about any individual example, by adding calibrated noise during training. The model is still trained on the original data: it is not an encryption method.
- A single orthogonal matrix
- Proposed for machine learning on its own, and recoverable from paired examples, as described above.
Scope
This analysis covers the threat model above and the attacks tested; it is not a proof that no stronger attack exists. Tensorlock does not claim information-theoretic privacy. It deliberately preserves the geometry of the padded data, and the conclusions hold for attackers without the additional knowledge, such as exact or near-exact reference data, that can help partially resolve the hidden coordinate system.
Challenge dataset
A synthetic unknown dataset encrypted with the method. Its content, shape, plaintext dimension and data type are not disclosed, and neither are the transformation steps applied, their order, or their parameters.
PyTorch .pt and safetensors files with identical contents: 58,862 training and 9,786 test examples, each 49 × 48 float32 values, with labels in 10 categories.