Pharmaceutical and materials companies spend large compute budgets on density functional theory (DFT), the standard quantum-mechanical method for computing a molecule's electron density: the three-dimensional cloud that determines its charges, polarity and reactivity. They rarely share the results, because a density identifies the molecule behind it. This proposal asks whether a partner could be allowed to search a pool of proprietary densities while seeing nothing but the answers. The partner would learn how similar their query molecule is to each deposited molecule, and nothing else.
The tool is functional encryption (FE): encryption where the key holder issues "functional keys," each of which decrypts only a chosen function of the data rather than the data itself. The idea in two sentences is this. Each molecule's density is reduced to a short, rotation-independent fingerprint and encrypted once. A client holding a key for their query can then compute similarity scores against every encrypted entry without further interaction, and the number of keys issued acts as an explicit, measurable leakage budget. The work would test two things. The first is whether the practical, pairing-based end of compact FE can reach the numerical precision chemistry needs. The second, which is the more important scientific question, is how many released similarity scores it takes before the hidden molecules can be re-identified.
Core Claim
FE promises that a key holder learns $f(x)$ and nothing more (Decoupling Encryption Overhead from Circuit Complexity). That guarantee is only as meaningful as the chosen $f$. For electron densities, the safety of the outputs is a question about chemistry, not cryptography.
We claim that three pieces together make DFT-level similarity search practical and auditable:
- A linear similarity over rotation-invariant density descriptors.
- Function-private inner-product encryption (IPE), which computes a dot product between an encrypted vector and a key vector while hiding both.
- A decryption scheme matched to the precision the search actually needs.
We further claim that the safe number of keys can be measured empirically on a benchmark molecule set.
The closest prior system is the Secure Similar Compounds Counter of Privacy-preserving search for chemical compound databases. It uses additively homomorphic ElGamal to compute Tanimoto similarity on 166-bit MACCS fingerprints and returns only a threshold count. We differ from it in three ways:
- Representation. We use continuous quantum densities instead of discrete substructure bits. The choice is motivated by Beyond Atoms, which finds that density-based representations beat atom-type ones on quantum property prediction and in low-data regimes.
- Trust topology. Encrypted deposits sit on an untrusted repository, and owners can go offline. In the counter protocol, the database owner holds the plaintext database and must compute each query.
- Leakage. We treat leakage from the scores themselves as a first-class quantity to measure, not an afterthought.
Research Program
Encoding. Each deposited molecule's density is expanded around its center of charge in a public radial-and-spherical-harmonic basis:
$$\rho(\mathbf r)=\sum_{n,l,m} c_{nlm}R_n(r)Y_{lm}(\hat{\mathbf r}).$$
Here $R_n$ are fixed radial functions, $Y_{lm}$ are spherical harmonics, and $c_{nlm}$ are the molecule's coefficients.
The owner computes the invariants $p_{nn'l}=\sum_m c_{nlm}c_{n'lm}$, which do not change when the molecule is rotated. The owner then normalizes the resulting vector $p$ to unit length. The similarity between molecules $A$ and $B$ is $s(A,B)=\langle p_A,p_B\rangle$, a cosine score that needs no alignment step.
Reference densities come from QH9 QH9. QH9 provides B3LYP/Def2SVP Hamiltonians for QM9 molecules; diagonalizing each Hamiltonian together with the overlap matrix (recomputed from the geometry) gives the density.
We also test whether predicted densities are good enough for depositors who cannot afford DFT. The predictor is the Basis Overlap Architecture of A Function-Centric Graph Neural Network Approach for Predicting Electron Densities, which reports 0.116% normalized mean absolute error on QM9. The invariant vector is optionally compressed with a public projection learned on public molecules, to dimension $d$ between 16 and 200.
Encryption. The primary scheme is the function-private IPE of A New Approach for Practical Function-Private Inner Product Encryption. It uses asymmetric pairings under the SXDH assumption, with $2d+8$ group elements per ciphertext and a master key of size linear in $d$.
The deployment works as follows. A consortium curator holds the master key, encrypts deposits, and issues query keys under a budget. The client (or a delegated cloud) scans the encrypted pool. Function privacy means a delegated scanner learns scores but not the query.
The curator does see the query at key issuance. We state this plainly as a trust assumption. It is the price of the budget-enforcing authority, and we compare it directly against the additive-encryption design, where the server never sees the query.
Two parts of the broader compact-FE agenda are out of scope. General-circuit compact FE and multi-input FE rely on obfuscation machinery that remains impractical (Indistinguishability Obfuscation from Compact Functional Encryption; Multi-Input Functional Encryption). For that reason, two-party adsorption-energy evaluation is not attempted.
Precision and decryption. Pairing-based IPE returns $g^{s}$, a group element with the score in the exponent, so the decryptor must solve a discrete logarithm to read the score. This works only when the integer score is small. Suppose the deposit is quantized to $a$ bits and the query to $b$ bits. The integer score then has magnitude up to roughly $d\,2^{a+b}$, and baby-step giant-step search (the standard square-root-time discrete-log method) costs about $\sqrt{d\,2^{a+b}}$ group operations per entry.
We first measure how many bits ranking fidelity actually requires. If a plain search over an interval of about $2^{40}$ suffices, we stop there.
If it does not, we add coarse-to-fine decryption:
- A second key for the rounded query $\lfloor y/2^{t}\rfloor$ (where $y$ is the quantized query vector and $t$ a shift) yields a low-resolution score cheaply.
- That estimate confines the full-precision discrete log to a narrow window.
- This splits one $\sqrt{2^{B}}$ search into two searches of about $\sqrt{2^{B/2}}$ each, where $B$ is the total number of output bits.
- The coarse key reveals little beyond a rounding of the same score. We quantify that extra leakage in the budget study.
Leakage budget. Linear outputs have a hard ceiling. With $d$ linearly independent query keys, a client can recover any deposit's $p$ exactly. The practical danger comes much earlier: scores against a handful of public reference molecules may already pin down a hidden molecule by nearest-neighbor matching.
We simulate an attacker who holds the public part of QM9 and $k$ keys of their choice. The attacker tries to re-identify, or recover the formula and geometry class of, molecules in a held-out "proprietary" split. The measured quantity is the re-identification rate as a function of $k$, compared against the same attack on MACCS-Tanimoto scores. From this we derive the curator's key budget.
Quadratic extension. As an ablation, we encrypt the coefficients $c$ themselves with the public-key quadratic FE of Simple and Efficient FE for Quadratic Functions. Its keys have constant size (6 or 10 group elements), and it computes $c^{\top}Ac$ for a key matrix $A$. Because every invariant is quadratic in $c$, one deposit then supports any rotation-invariant quadratic query without the owner committing to $p$ in advance. Public-key encryption also lets depositors encrypt without the curator.
The cost is that these keys expose $A$, and therefore the query invariants, to whoever decrypts. This extension earns its place only if flexibility or public-key deposit matters more than query privacy.
Baselines
Plaintext reference. The naive reference is plaintext cosine search over the same invariants. It sets the retrieval quality every encrypted variant must match and the speed floor. The same retrieval is also run with MACCS Tanimoto on the same molecules, to check that density similarity is worth protecting at all.
We measure usefulness by k-nearest-neighbor prediction error on QM9 dipole moment and HOMO-LUMO gap, where each held-out molecule's properties are predicted from its retrieved neighbors. Beyond Atoms reports density representations giving the lowest property errors, but the file gives no numeric values, so no reported result was found on Lacuna for density-based retrieval on QM9. Encrypted search "matches plaintext" if recall@10 against the plaintext ranking exceeds 0.99 and the neighbor-prediction error rises by less than 2%.
Additive homomorphic encryption. The strongest existing method is the Secure Similar Compounds Counter Privacy-preserving search for chemical compound databases. On 1,292,344 ChEMBL compounds it reported about 167 seconds on the server and 172 seconds on the client, on a single CPU core. It was also 36,900 times faster than general-purpose secure computation, which did not finish within 24 hours.
We re-implement its lifted-ElGamal inner product on our density invariants. The comparison uses the same $d$, the same quantization, the same pairing-friendly curve library where applicable, and single-core timing on QM9 and a QMugs-scale pool. We report per-entry cost, bandwidth and who learns what.
Beating it on raw speed is unlikely. Pairings cost more than ElGamal additions. The proposal counts as successful if FE stays within a small constant factor, which we set at 20 times per entry, while supporting offline, mutually distrusting depositors and delegated scanning, which the counter protocol cannot.
Trusted execution environment. An Intel SGX-style enclave running plaintext search is the speed ceiling. A Systematic Comparison of Encrypted Machine Learning Solutions for Image Classification reports about 0.14 seconds per inference with TF-Trusted on its Malaria model. We time the same search in an enclave and report it as a reference that relies on trusting the hardware.
Ablations. These isolate the key ingredients:
- plain versus coarse-to-fine discrete log, at matched output precision;
- function-private IPE versus non-function-private quadratic FE on the same queries;
- DFT versus Basis Overlap Architecture densities as deposits.
Why not just…?
Why not just extend the additive-encryption fingerprint search to densities? For a single database owner who is online, this is a real threat and may simply be the better tool. It hides the query from the server, which our curator design does not. The proposal's case rests on a different setting: many depositors who encrypt once and leave, an untrusted repository, and a per-key leakage budget. The head-to-head timing and a written trust comparison will show whether that setting justifies the extra pairing cost. We will report plainly if it does not.
Why not just use approximate-arithmetic fully homomorphic encryption, which handles real numbers and avoids the discrete-log limit? A depth-one inner product is cheap under such schemes, so precision is not the obstacle. The obstacle is topology. The client's ciphertext must be evaluated by a party that holds the plaintext database, and outputs return to the client under the client's key. There is no way for the data owner to cap how many different questions are asked. Reported ciphertext costs for deeper homomorphic workloads are also large: 56 GB and 549 seconds per inference for HE-Transformer on the Malaria model A Systematic Comparison of Encrypted Machine Learning Solutions for Image Classification, and 250-second batches for CryptoNets. Those figures matter less here, because our workload is shallow. We therefore do not rest the argument on them.
Why not just run the search in a secure enclave? For this small workload the enclave's memory limit is not binding, so it would be fast and simple. What it cannot provide is security from a mathematical hardness assumption rather than trust in a hardware vendor. We report it as the speed ceiling. A consortium that accepts hardware trust should use it.
Why not just quantize to a few bits and skip the precision machinery? This may well suffice. The first experiment measures ranking fidelity against quantization bits. Coarse-to-fine decryption is adopted only if the required output range exceeds what a plain search handles within one second per thousand entries.
Proposed Experiments
The first decisive check is the precision curve. We plot recall@10 and neighbor-prediction error against total quantization bits on QM9 invariants for $d\in\{16,64,200\}$. From this we read off the required output range and whether plain discrete-log search is enough.
The second is end-to-end cost. We measure single-core scan time and ciphertext storage per molecule for function-private IPE, quadratic FE and the additive-encryption baseline. Pools are QM9 (about 134,000 molecules) and molecules up to 200 atoms, where the Basis Overlap Architecture reports near-constant density accuracy. We expect pairing count, which grows linearly in $d$ per entry, to dominate, and the compression dimension is chosen accordingly.
The third, and most important, is the leakage curve. We report re-identification rate against key count $k$ for density scores versus MACCS scores, on a held-out split of QM9 and on the molecule-wise split of QH9 (where QH9 reports roughly doubled error relative to its geometry-wise split, making it the natural stress case).
The result would be useful either way. If density scores re-identify molecules within a few dozen keys, the finding is that FE's guarantee must be paired with strict budgets, and we state the budget. If re-identification stays low up to hundreds of keys, private density screening is viable with pairing-based FE at the measured cost.
References
- Privacy-preserving search for chemical compound databases
- Beyond Atoms: Evaluating Electron Density Representation for 3D Molecular Learning
- QH9: A Quantum Hamiltonian Prediction Benchmark for QM9 Molecules
- A Function-Centric Graph Neural Network Approach for Predicting Electron Densities
- A New Approach for Practical Function-Private Inner Product Encryption
- Indistinguishability Obfuscation from Compact Functional Encryption
- Multi-Input Functional Encryption
- Simple and efficient FE for quadratic functions
- A Systematic Comparison of Encrypted Machine Learning Solutions for Image Classification
- CryptoNets: Applying Neural Networks to Encrypted Data with High Throughput and Accuracy