Encrypted Merit-Order Setup for Fast Frequency Response

Power grids that run mostly on solar, wind and batteries have little spinning mass, so after a sudden loss of generation their frequency falls fast. Thousands of small privately owned batteries and flexible loads could catch that fall, but coordinating them well requires each owner's private data: their spare capacity, their cost of responding, how long they can sustain output. Homomorphic encryption lets an operator compute on data it cannot read. It is too slow to sit inside a control loop that must act within a few hundred milliseconds, and every sequential multiplication it performs, its multiplicative depth, makes all of its arithmetic slower. We propose moving all encrypted computation off the event-time critical path. Every few minutes, a shallow encrypted computation turns private owner data into a private response curve for each device, delivered only to that device. When a disturbance hits, each device reads its own curve against locally measured frequency, with no communication and no cryptography.

The algorithmic contribution sits in that periodic setup step. The most useful coordination rule is to activate the cheapest devices first and escalate to expensive ones only for larger disturbances, a merit order. Computing it naively over encrypted data means sorting encrypted costs and then filling capacity down the sorted list. That is a long chain of comparisons, each already several levels deep. We show the merit order can be computed at the depth of a single encrypted comparison plus one multiplication, with no sorting and no division. We then measure the chain that links the two fields: circuit depth sets encryption parameters, parameters set setup latency, latency sets how stale the private data can get, and staleness sets the frequency low point (nadir) the grid actually reaches.

Core Claim

Let $n$ devices have private costs $c_i$ and private headroom $h_i$ (MW available). Define device $i$'s offset as the total headroom of all devices cheaper than it:

$$A_i = \sum_{j \ne i} \mathbb{1}[c_j < c_i]\, h_j .$$

Here $\mathbb{1}[\cdot]$ is 1 when the condition holds and 0 otherwise, with ties broken by device index. For a system-wide shortfall $D$, merit-order dispatch gives device $i$ exactly $u_i(D) = \mathrm{clip}(D - A_i,\, 0,\, h_i)$. Every indicator can be evaluated in parallel, and each is multiplied once by an encrypted $h_j$. The encrypted depth is therefore $d_{\mathrm{cmp}} + 1$, where $d_{\mathrm{cmp}}$ is the depth of one approximate comparison. The sequential fill has depth $n \cdot d_{\mathrm{cmp}}$, and a sorting network has depth roughly $\log^2 n \cdot d_{\mathrm{cmp}}$. Only $A_i$ is decrypted, and only for device $i$. The clip is then applied in plaintext at the device.

Two further steps make the scheme local. First, the operator publishes an aggregate stiffness $\beta$ in MW per Hz that maps local frequency deviation $\Delta f$ to an implied shortfall. Second, device $i$ enforces $u_i(\Delta f) = \mathrm{clip}(\beta|\Delta f| - A_i, 0, h_i)$ using its own frequency measurement. The result is a staggered droop: cheap devices respond to small dips and expensive ones only to deep dips, and nothing crosses the network during the event.

The revealed quantity $A_i$ is inherent to the functionality. Any merit-order rule tells device $i$ when it starts responding, and that start point is equivalent to $A_i$. So the protocol leaks nothing beyond its output. The claim rests on two properties. The event-time loop carries zero cryptographic latency. The setup circuit is shallow enough that refreshing every few minutes is feasible for feeder-sized populations of hundreds of devices.

Where the Pieces Come From

Three kinds of prior work shape this design. Two papers from the grid side motivate it by showing what coordination buys and what it costs. Reinforcement Learning for Distributed Transient Frequency Control with Stability and Safety Guarantees shares stability budgets across buses on the IEEE 39-bus system. It keeps frequency within 59.8 to 60.2 Hz at a control cost of 1.1628, against 2.2054 for a non-learning safe controller. That result is evidence that coordination beats rigid local rules, but the paper computes everything in plaintext. Fast frequency response with heterogeneous communication delay management under the SCION Internet architecture dispatches reserves to 100,000 devices with a heuristic that finishes within 100 ms. It reports 99th-percentile network latency of about 410 ms under SCION versus about 480 ms under ordinary internet routing. That latency is a large fraction of the sub-second response window, and it is paid on every event. Our design removes event-time messaging entirely, at the price of reacting to local frequency rather than a centrally estimated disturbance. Grid-Forming and Spatially Distributed Control Design of Dynamic Virtual Power Plants splits an aggregate response across devices using participation factors. It flags the real-time exchange of those factors, which reveal state of charge and limits, as an open problem. We address the privacy half of that problem for the simpler merit-order structure.

Work on encrypted control constrains the design. Implementing homomorphic encryption based secure feedback control runs a linear controller under additive-only Paillier encryption on an FPGA at 500 Hz, but only with 256-bit keys, far below standard strength. Secure and Private Implementation of Dynamic Controllers Using Semi-Homomorphic Encryption shows that encrypted controller state overflows within 1.2 s at 10 ms sampling unless the state is reset. A reset of that kind would inject power steps into a grid. Privacy preserving distributed optimization using homomorphic encryption solves demand response and optimal power flow on the IEEE 14- and 37-bus systems, taking about 1.5 s per iteration with 4000-bit Paillier keys. Together these results argue against putting encryption inside the fast loop at all. That is why our encrypted computation is stateless, periodic and feed-forward.

Work on multiplicative depth supplies the method. Efficient Homomorphic Comparison Methods with Optimal Complexity builds comparisons from repeated compositions of a simple odd polynomial, reaching asymptotically optimal depth at 1.43 ms amortized per 20-bit comparison. We use it for the indicators. Revisiting ML Training under Fully Homomorphic Encryption: Convergence Guarantees, Differential Privacy, and Efficient Algorithms cuts per-iteration depth from 24 to 9 by reformulating the objective so that comparisons disappear. Our prefix-offset rewrite follows the same idea: restructure the problem rather than approximate the expensive step. It is also a special case of the tree-style depth flattening in Generating One-Hot Maps under Encryption. That paper makes the price explicit: minimizing depth costs extra work. Here the extra work is $n^2$ comparisons instead of $n \log n$.

Research Program

We will build the setup protocol in OpenFHE using the CKKS scheme, an encryption that supports approximate real-number arithmetic. Costs and headroom will be packed so that all $n^2$ pairwise differences $c_j - c_i$ come from rotations of two ciphertexts. The composite-polynomial sign function is then applied once to all of them together, and the result is multiplied by the packed $h_j$ and summed with rotations. Decryption of $A_i$ is split between the operator and device $i$ in a threshold arrangement, so neither can decrypt alone.

The approximate comparison introduces error near ties, so an encrypted $A_i$ can be off by up to one neighbour's headroom. We will bound the resulting error in dispatched power and treat it as a tunable accuracy target. We will also extend the rule in two ways. The first uses energy-limited headroom: device $i$ caps its contribution by $\min(h_i, E_i/\tau)$ for a sustain time $\tau$. Because $\tau$ is public and each device applies this cap locally before encryption, depth does not change. The second is a two-level hierarchy in which feeder-level merit orders are merged at the transmission level. This keeps $n^2$ bounded, and we will measure how much optimality the hierarchy gives up.

The quantity we want to characterize is setup latency against refresh period against nadir. We will measure how setup latency scales with $n$ and with depth. Then, in simulation, we will measure how stale offsets degrade nadir, rate of change of frequency, and under-frequency load-shedding triggers as private headroom drifts between refreshes.

Baselines

The naive reference is uniform local droop. Every device responds in proportion to $|\Delta f|$ using a gain set from its own headroom, with no coordination and no privacy cost. It will be run on the same device population and the same disturbances. Our method must match its nadir while lowering dispatch cost. Otherwise the coordination is not worth having.

The strongest privacy-preserving competitor is additive-only secure aggregation followed by proportional sharing. Each device learns the encrypted-then-revealed total headroom, and all devices respond proportionally. This needs no ciphertext multiplications. It can run under Paillier as in Privacy preserving distributed optimization using homomorphic encryption, or under CKKS with depth zero. It will receive the same refresh period, the same key-strength target of at least 128-bit security, and the same hardware. Beating it means lower dispatch cost at equal or better nadir, because proportional sharing ignores cost order. If the cost gap is small, the multiplicative part of this proposal is unjustified.

The plaintext oracle is the SCION-paper heuristic allocation computed centrally with instantaneous knowledge of all private data, driven by the SCION latency traces. It has no privacy. For its dispatch speed, the file reports under 100 ms for 100,000 devices (Fast frequency response with heterogeneous communication delay management under the SCION Internet architecture). No reported result found on Lacuna for the nadir that this heuristic achieves on a named benchmark, so we will reproduce it. Our target is to come within a small fraction of its nadir and cost while revealing nothing but $A_i$. On IEEE 39-bus control cost, the reference numbers are 1.1628 for the coordinated method and 2.2054 for the non-learning safe baseline (Reinforcement Learning for Distributed Transient Frequency Control with Stability and Safety Guarantees). We will report where our cost falls relative to both, with the caveat that that paper's cost definition must be matched.

Two ablations isolate the key ingredients. The first computes the same merit order by sequential encrypted fill and by an encrypted sorting network. It holds the output fixed and measures how depth, encryption parameters and latency change, which isolates the prefix-offset rewrite. The second, an encrypted-in-the-loop variant, computes $u_i(D)$ under encryption at event time, after the disturbance is estimated. It isolates the value of moving cryptography off the critical path.

Why not just…?

Why not just use additive-only encryption and proportional sharing? This is the real threat. It is cheap, and its only leakage is total headroom. If device costs are nearly homogeneous, or if the grid rarely calls on more than the cheapest tier, proportional sharing may be nearly as good. The proportional-sharing baseline settles the question directly. We will sweep the spread of private costs and the size of the disturbance, and report the cost gap at equal nadir. If the gap is negligible at realistic cost spreads, we will say so, and the contribution narrows to the depth analysis.

Why not just add differential-privacy noise to the reported costs and headroom? Perturbed headroom produces dispatched power that devices cannot actually deliver. Under a 59.8 to 60.2 Hz envelope, the kind enforced in Reinforcement Learning for Distributed Transient Frequency Control with Stability and Safety Guarantees, shortfalls at the frequency low point are exactly what trips load shedding. We will include a noise-perturbed plaintext merit order as an extra arm, sweeping the privacy parameter, to measure the nadir penalty against our exact-output protocol.

Why not just let each device respond locally with no coordination? The uniform-droop baseline tests exactly this. Our scheme is itself local at event time, so the question is only whether the setup-time coordination changes cost. It is not about latency or robustness to communication loss, since both designs send nothing during an event.

Why not just run the coordination encrypted at event time, with bootstrapping for depth? Bootstrapping refreshes a ciphertext so that it can be multiplied further. In the CKKS setting it pushed one statistical transform to 4.09 hours (De Bello Homomorphico: Investigation of the extensibility of the OpenFHE library with basic mathematical functions by means of common approaches using the example of the CKKS cryptosystem). Even a shallow, non-bootstrapped comparison batch adds to the 410 ms network tail. The encrypted-in-the-loop ablation measures this cost directly.

Proposed Experiments

We will measure cryptographic cost in OpenFHE on a single multicore CPU. For $n$ in the range 16 to 1024, we will record depth, ring dimension, setup wall-clock time and bandwidth for our rewrite, for sequential fill and for a sorting network, all at 128-bit security. Using the 1.43 ms amortized comparison as a rough guide, $n^2$ comparisons put roughly 100 devices in the tens-of-seconds range and 1000 devices near half an hour. Those estimates are why the hierarchical variant is part of the program, not an afterthought.

Grid experiments use the IEEE 39-bus system for transmission-level frequency dynamics and the IEEE 37-bus feeder to host device populations. Device populations are synthetic, with cost and headroom distributions of varying spread, because the file contains no real device-level dataset. Event-time messaging for the plaintext oracle and the encrypted-in-the-loop baseline is driven by the SCION real-world latency traces. Disturbances are generation losses of increasing size. Metrics are frequency nadir, rate of change of frequency, count of under-frequency load-shedding triggers, dispatch cost, and bytes revealed per device.

The decisive checks are three. First, at a realistic cost spread, our method must reach nadir parity with uniform droop and proportional sharing while being clearly cheaper than both. Second, with refresh periods of minutes and realistic headroom drift, the degradation from stale offsets must stay below the gap to proportional sharing. Third, the encrypted-in-the-loop variant must fall outside the frequency envelope on large disturbances where our local-at-event-time design stays within it. If the first check fails, the multiplicative-depth work is not needed for this application, and we will report that as the finding.