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
≈10354\approx 10^{354}
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.

1,176

Possible sets of plaintext coordinates, if the plaintext dimension is unknown

21,176−2≈1.03×103542^{1{,}176} - 2 \approx 1.03 \times 10^{354}

The same, even if the plaintext dimension were known (padding adds 50%)

(1,176784)≈3.01×10323\binom{1{,}176}{784} \approx 3.01 \times 10^{323}

Degrees of freedom of the secret orthogonal matrix

1,176×1,1752=690,900\dfrac{1{,}176 \times 1{,}175}{2} = 690{,}900

The marker shows the manuscript's example: a 784-value MNIST image with 50% padding, encrypted to 1,176 values. Counts are exact, shown to three significant figures.

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) Trainer (B) Attacker (C) Data and labels Encryption Key stays here Inference oracle Encrypts, runs the model, deletes the encrypted copy Encrypted, with labels Training Model Used by A's inference oracle Its own example A label only Intercepted copy: encrypted data and labels
Top: training, where the attacker may take a copy of the encrypted data and labels. Bottom: the attacker queries the trained model. The plaintext data, the key and the encrypted version of the attacker's own example never leave the data owner.
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:

zi=ui P Q=uiA,z_i = u_i\,P\,Q = u_i A,
A⊤A=I.A^\top A = I.

Because the matrix is orthogonal, the inner products between examples are unchanged:

ZZ⊤=UAA⊤U⊤=UU⊤Z Z^\top = U A A^\top U^\top = U U^\top

so the lengths of the examples, the angles between them and the distances between them are all unchanged:

⟨zi,zj⟩=⟨ui,uj⟩,\langle z_i, z_j \rangle = \langle u_i, u_j \rangle,
∥zi−zj∥2=∥ui−uj∥2.\lVert z_i - z_j \rVert_2 = \lVert u_i - u_j \rVert_2.

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
An illustration: two groups of points, rotated together. Every coordinate changes, but the distances between points and the line separating the groups are unchanged.

Measured across 1,000 random pairs of encrypted MNIST examples, the largest change the shuffle and rotation made was 4.3×10−144.3 \times 10^{-14} degrees in angle and 5.3×10−155.3 \times 10^{-15} 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: the coordinate system

The orthogonal matrix is drawn at random from all rotations and reflections, uniformly (the Haar distribution). Any two padded datasets with the same inner products differ only by a rotation or reflection, and rotating a uniformly random matrix leaves it uniformly random. So the encrypted data says nothing about which orientation it came from.

In practice, for every orthogonal matrix RR, the candidate decryption

UR=ZR,U_R = Z R,
URUR⊤=ZRR⊤Z⊤=ZZ⊤,U_R U_R^\top = Z R R^\top Z^\top = Z Z^\top,

fits the encrypted data exactly as well as the true one. There are infinitely many of them, and nothing in the encrypted data distinguishes the right one.

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 dd, the number of possible choices among DD coordinates would be

(Dd)=D!d! (D−d)!.\binom{D}{d} = \frac{D!}{d!\,(D-d)!}.

They do not know dd, only that it is smaller than DD. Every possible dimension has to be considered, which gives

∑d^=1D−1(Dd^)=2D−2\sum_{\hat{d}=1}^{D-1} \binom{D}{\hat{d}} = 2^D - 2

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.

First plaintext dimension: first letters of 5-letter words
a b c d e f g h i j k l m n o p q r s t u v w x y z First letter 1024 0
Same coordinate after encryption, with Gaussian fit
-0.3 0.7 1.6 Encrypted value 568 0

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:

xj′  ↦  yj′.x'_j \;\mapsto\; y'_j.

The encrypted version of the example is deleted and never returned. The attacker therefore gets no equations of the form

zj′=Pad⁡(xj′) Az'_j = \operatorname{Pad}(x'_j)\,A

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 D(D−1)/2D(D-1)/2 690,900690{,}900
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 ≈236.6 million\approx 2^{36.6\,\text{million}}
Possible signal-coordinate subsets, plaintext dimension unknown 2D−22^D - 2 ≈1.03×10354\approx 1.03 \times 10^{354}
Possible signal-coordinate subsets, even if the plaintext dimension were known (Dd)\dbinom{D}{d} ≈3.01×10323\approx 3.01 \times 10^{323}
Possible index shuffles D!D! ≈1.01×103,102\approx 1.01 \times 10^{3{,}102}

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:

ΣZ=A⊤ΣUA,\Sigma_Z = A^\top \Sigma_U A,
eig⁡(ΣZ)=eig⁡(ΣU).\operatorname{eig}(\Sigma_Z) = \operatorname{eig}(\Sigma_U).

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 112\tfrac{1}{12}, 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.

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

  • Reconstruction, against its own passage 0.81%
  • The same reconstruction, against a different passage in the same language 0.80%
  • Guessing a space for every character 16.1%
  • Random characters 0.39%
10,000 test passages of 784 characters, ten languages, Windows-1252 bytes. Encryption: 392 padding values generated from the data's principal components, interlaced; Gaussian perturbation with standard deviation 0.05 on a 0 to 1 scale; a secret 1,176 × 1,176 orthogonal transformation. Attack: spectral recovery with an identical, row-shuffled copy of the dataset and the plaintext dimension known. Average error 41.2 of 255 byte levels (41.5 against a different passage). Byte levels: each character is a value from 0 to 255, so “b” for “a” is 1 level off and “A” for “a” is 32. In the step-through, the passage shown for each language is a typical one: its exact share is the median for that language. The point cloud in the attack step is an illustration; the eigenvalues beside it are the attack's own. · marks a character with no visible form. Text from Wikipedia, CC BY-SA 4.0.

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 XX and ZZ, then

Z=X T⟹T=X−1Z.Z = X\,T \quad\Longrightarrow\quad T = X^{-1} Z.

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.