blindLM

An open model that cannot read your prompt

Python · Go · BGV encryption

39 s

When you send a prompt to a hosted model, the company that runs the GPUs can read it. blindLM lets you use those GPUs anyway. The servers hold the weights and do the heavy arithmetic, but every vector they receive looks random to them, and the prompt, the model's intermediate values and the answer stay on your side. It is a working prototype on Qwen2.5-0.5B-Instruct, and it produces exactly the same tokens as the unmodified model.

It rests on the fact that an LLM does two kinds of work for every token. The large matrix multiplications are almost all of the arithmetic, and they are why you need big hardware and the full set of weights. The rest is a handful of small nonlinear steps: normalisation, attention's softmax, the activation function and the choice of the next token. Those are cheap in plaintext and expensive under encryption. blindLM splits the model along that line. A server holds the weights and does only the matrix multiplications, on data it cannot read. A gateway on the user's side does the small steps in plaintext and never needs the large matrices.

The numbers below come from an Apple M3 Pro, CPU only, with the server, the preparation service and the gateway running as three processes over local HTTP.

24 of 24
Tokens identical to the unmodified model
8.4 s
Online time for a 41-token prompt plus 24 generated tokens
208 MB
Online traffic for that request, over 2,328 round trips
3.83 MB
Online traffic per generated token, over 97 round trips
3 minutes
Preparation for that request, 72 token positions on 10 cores
about 30 MB
Preparation traffic per token position
99 MB
Evaluation keys, sent once per user

How it works

  1. 01

    Masks are prepared before the prompt exists

    Every vector the gateway sends will be hidden under a one-time random mask r, and the gateway will need W·r to remove it. To get W·r, it encrypts r with BGV and sends the ciphertext to the server, which multiplies it by the weight matrix without being able to read it. The gateway decrypts the result and stores the pair. None of this depends on the prompt, so the gateway's --batch option keeps a pool of masks ready before anyone types. This is the expensive part of the system, and the only place where cryptography is used.

  2. 02

    A layer takes four round trips

    Online, the gateway sends x + r in place of a private vector x. Because r is uniformly random and used once, the server receives a uniformly random vector that carries no information about x. It multiplies by the weights with ordinary integer arithmetic, and the gateway subtracts W·r to get W·x. Each layer does this four times: for the query, key and value matrices, for the attention output, for the gate and up matrices, and for the down projection. Between trips the gateway works in plaintext. It adds biases, runs attention over its own history, normalises, and computes SiLU of the gate times the up value.

  3. 03

    The gateway picks the token

    After the last layer, one more round trip applies the output matrix, and the gateway chooses the next token itself. Decoding is greedy. All of the arithmetic is exact modulo a 46-bit prime. Activations are rounded to 17 bits and weights to between 19 and 24 fractional bits once, before use, and nothing after that is approximated.

  4. 04

    Every reply is checked

    The gateway does not take the server's results on trust. For each matrix W it keeps a secret random vector u and the product v = u·W, computed once from the public weights. A correct reply y to the input x satisfies u·y = v·x, which costs the gateway two short sums, and a wrong reply passes with probability about 2^-92 whatever the server does. A 24-token request checked 4,056 replies. In testing, a single altered value was caught at the first, 50th, 97th and 1,000th reply. When a check fails, the gateway stops for good and needs a new check file.

Decisions

Preparation uses standard BGV encryption from Lattigo, with ring degree 2^13 and a 192-bit modulus, which is under the 218-bit cap for 128-bit security. The lattice estimator has not been run on these parameters yet. They follow the standard table.

It works only with open-weight, dense models. The gateway sees intermediate values, so a user could reconstruct the weights, and in a mixture-of-experts model, hiding which experts run would mean evaluating all of them.

The gateway is in the loop for every layer, so it has to be online with a fast link to the server. Today it runs on the customer's own machine and speaks the OpenAI chat-completions format. Hosting it in a secure enclave next to the servers, so the user installs nothing, is designed but not built. TLS, login, a GPU path and serving more than one request at a time are not built either.

All projects