1. The FHE flow: move the computation to the ciphertext
Suppose you want a service to calculate a score from a private value. In a conventional service, the server must see the value while calculating. With fully homomorphic encryption (FHE), the client encrypts the value first. The server receives a ciphertext and evaluates a supported program on it. The client decrypts the returned ciphertext to recover the answer.
The function’s output is encrypted too. That is useful when the result itself is sensitive, but it means the service cannot inspect it to decide what to do next. The application must plan who receives the answer and where decryption happens.
2. Keys and roles: separate the ability to evaluate from the ability to decrypt
Public-key FHE starts with key generation. The client keeps a secret key for decryption and gives the evaluator the public material needed to encrypt or carry out selected operations. Multiplication, rotations, and other advanced operations can need additional evaluation keys. These are built so the evaluator can transform ciphertexts without being handed the raw secret key.
encrypt · decrypt
“Public” does not mean that every key should be published everywhere. A protocol should decide which evaluation keys the server receives, authenticate their source, and protect the client’s secret key. FHE separates capabilities, but the surrounding application still has to enforce that separation.
3. Modular arithmetic: a number system that wraps
Many FHE schemes do their internal arithmetic modulo an integer. Think of a clock: after 11 comes 0, so 9 + 5 lands on 2 when counting modulo 12. More formally, numbers are grouped by their remainders. Modulo 7, 16 and 2 represent the same remainder, because their difference is 14, a multiple of 7.
This is an intuition for the arithmetic, not a toy version of secure encryption. Real systems use carefully chosen large moduli and structured objects. The modulus determines which values can be represented and how wraparound is interpreted. For some schemes the plaintext has its own modulus while ciphertext arithmetic uses a larger one.
That distinction matters: a computer can do the modular operations exactly while an application’s intended integer arithmetic may still overflow or wrap if its value bounds were planned poorly. Parameter choices and encoding are part of the program’s correctness.
4. Lattices and LWE: hiding a secret among noisy equations
A lattice is a regular set of points built from integer combinations of basis vectors. In two dimensions it looks like a grid, though the cryptographic lattices used in FHE live in many more dimensions. Certain problems stay hard even when an attacker sees many related samples.
In Learning With Errors (LWE), a public sample can be viewed as a linear relation involving a secret, with a small error added. One sample alone is not the whole security argument. The challenge is to recover the hidden secret from many such noisy relations, under a chosen parameter set. Ring-LWE uses polynomial-shaped values to obtain more compact and efficient constructions.
FHE schemes use this family of hard lattice problems to build encryption. A small error also appears inside ciphertexts. There it has a second, operational role: it gives decryption a margin to distinguish the encoded message. The security error and the growth of a ciphertext’s decryption error are related to the design, but they are not interchangeable concepts.
5. From LWE to RLWE: trade long vectors for structured polynomials
Basic LWE describes a hidden secret as a vector and public equations as noisy dot products. Ring-LWE changes the objects: vectors of coefficients are gathered into polynomials, and dot-product-like algebra becomes multiplication in a polynomial ring. This structure can make keys and operations more compact, and it provides the algebra used by many practical schemes.
The extra structure is deliberate and comes with a security assumption of its own. Ring-LWE is not simply “LWE but faster” with no caveats; parameter selection and the assumed hard problem matter. The diagram shows how data is organized, not a proof that the resulting scheme is secure.
6. Noise and depth: the room left for more work
To build intuition, imagine that a ciphertext contains a signal plus a small amount of uncertainty. Decryption succeeds while the encoded signal remains distinguishable from that uncertainty. Homomorphic operations preserve the message relationship, but they also change the error inside the ciphertext.
Addition usually consumes less of this margin than multiplication. Multiplication can increase ciphertext size and error more sharply. Schemes therefore organize evaluation into levels or “depth”: a planned sequence of operations that fits within the available modulus and decoding margin.
Some schemes can refresh a ciphertext through bootstrapping, enabling further computation. Refreshing is itself an expensive homomorphic computation and has scheme-specific costs and error behavior. It is not simply deleting noise or restoring lost precision.
7. Polynomial rings: compact arithmetic for many coefficients
Ring-based FHE often represents a ciphertext component as a polynomial with a fixed number of coefficients. Instead of adding two lone numbers, the evaluator adds and multiplies these polynomial-shaped objects. The coefficients are computed modulo a large integer, and the polynomial itself is reduced by a selected rule such as xⁿ + 1.
A polynomial with many coefficients is useful because one operation can carry structured work across a large object. Special polynomial choices support fast transforms used to speed up multiplication. In schemes such as CKKS, a carefully designed encoding connects polynomial arithmetic to vectors of approximate values called slots.
This representation is one reason FHE performance depends on more than the input’s number of bytes. Polynomial degree, modulus sizes, number of levels, and the chosen encoding all affect the cost.
8. Encoding and scale: translate application values into scheme values
An encryption routine does not usually accept an arbitrary application object and preserve it automatically. Before encryption, data is encoded into the plaintext space supported by the scheme. After decryption, the result is decoded back into a useful value.
Exact schemes can encode integers or modular values. CKKS maps real or complex numbers into a polynomial representation with a scale factor. The scale preserves useful precision while values are represented with integer coefficients. Multiplication combines scales, so a program must keep scale and modulus levels aligned. Rescaling helps control that growth but discards some precision.
3.1415encode · scalepolynomial slots
[31415, …]encryptciphertext
Enc(m)
The middle drawing is conceptual: CKKS encodings are not decimal digits pasted into slots. It illustrates that encoding is a mathematical transformation with its own precision and range choices. Keep the application’s value bounds, target accuracy, and later operations in view before settling on an encoding.
9. Encrypted operations: addition is the easy part
Homomorphic addition has a pleasing property: combining two ciphertexts can produce a ciphertext that decrypts to the sum of the underlying values. Multiplication has a similar algebraic goal, but it usually makes the internal ciphertext representation larger and increases its error. Schemes use techniques such as relinearization or key switching to bring the representation back to a manageable form using evaluation keys.
Enc(a) ⊕ Enc(b) → Enc(a + b)Compatible ciphertexts combine directly. The result remains encrypted.
Enc(a) ⊗ Enc(b) → Enc(a × b)More costly: manage ciphertext size, error, and remaining levels.
These equations describe the intended decrypted result, not the raw bytes of the ciphertext. Ciphertexts are randomized and their internal components do not look like the original numbers. They also need compatible parameters and encodings before they can be combined safely.
10. Relinearization: keep multiplication results manageable
In common public-key constructions, a ciphertext has a small number of components. Multiplying two ciphertexts combines those components and can produce a larger ciphertext associated with higher powers of the secret key. Repeating this naively would make later work more expensive.
Relinearization uses evaluation-key material to express that expanded result in the usual compact form. Key switching is a broader tool for changing which secret-key representation a ciphertext is tied to, again using special key material rather than revealing the secret. These transformations cost time and memory, so libraries and compilers often schedule them as part of the computation.
c₀, c₁multiplyexpanded
c₀, c₁, c₂relinearizecompact again
c′₀, c′₁
This is a shape-level explanation. The ciphertext components are polynomials, and the actual key-switching algorithms use decompositions and encrypted key material; the little labels here are not an implementation recipe.
11. Levels and rescaling: plan the modulus alongside the circuit
Many leveled schemes use a chain of ciphertext moduli. A multiplication consumes part of this chain, so each ciphertext has a current level that records how much planned computation remains. Combining ciphertexts generally requires compatible levels and parameters.
Exact schemes such as BFV and BGV manage modulus changes in scheme-specific ways. CKKS uses rescaling after multiplication to reduce the scale and move to a smaller modulus. Modulus switching and rescaling are related engineering ideas, but their details and effects on values differ across schemes. Treating them as a generic “noise deletion” operation leads to incorrect programs.
Before implementing a model, write down its multiplicative depth and mark where ciphertexts must be aligned. Then test the actual library’s scale and level behavior with small examples.
12. Bootstrapping: spend computation to continue computing
Bootstrapping refreshes a ciphertext so that additional operations can be evaluated after the original budget is nearly spent. At a high level, the system homomorphically evaluates a decryption-related procedure using encrypted key material, then returns a ciphertext with renewed capacity.
The evaluator still does not receive the plaintext secret key. Instead, bootstrapping relies on a carefully generated set of keys and a scheme-specific circuit. The refresh can be computationally expensive and may add approximation error, especially in approximate schemes. Some TFHE-style bootstrapping also evaluates a selected function while refreshing, which changes the programming model.
budget lowrefreshciphertext
more work available↻
Whether to use bootstrapping depends on the workload. Some applications choose parameters for a fixed bounded depth; others accept the cost of refresh to support longer or less predictable computations.
13. Scheme families: choose the arithmetic your task needs
“FHE” names a capability, not one universal algorithm. Different scheme families represent different kinds of values and trade exactness, approximation, supported operations, and implementation cost.
BFV
Exact modular integer arithmetic. Useful when the application needs discrete values and can manage the plaintext modulus and value range.
BGV
Also supports exact modular arithmetic, with its own approach to managing ciphertext moduli and levels.
CKKS
Approximate arithmetic on real or complex values. It is designed for numerical workloads where a controlled approximation is acceptable.
TFHE
A family suited to Boolean or small discrete computations; programmable bootstrapping can evaluate selected functions while refreshing.
These are broad guideposts, not a complete comparison. Implementations differ, and the right choice depends on the computation, accuracy target, security level, available library, and hardware. A benchmark from one setup does not establish a universal ranking.
14. Packing and rotations: make one ciphertext do vector work
Some encodings place many values into slots inside one ciphertext. Addition and multiplication can then apply slot by slot, much like a vectorized instruction. This can improve throughput when the application’s layout matches the operation.
To compute a sum of products, for example, one must also reduce the slot vector. Rotations shift the packed values so additions can bring partial sums together. Those operations take time and evaluation keys, so the slot layout should be designed around the whole computation, not just the first multiplication.
15. Worked design: a private inference request
Imagine a user who wants a hosted model to score a feature vector without revealing the features to the service. The user encodes and encrypts the vector. The evaluator applies the model’s supported arithmetic and returns an encrypted score. The user decrypts it locally.
- Choose a representation. Decide which values go in each slot and the precision or integer range required.
- Shape the model. Keep operations compatible with the chosen scheme; approximate unsupported nonlinear steps only after measuring their effect on accuracy.
- Plan the circuit. Count multiplicative depth, rotations, key-switches, and required evaluation keys.
- Measure both sides. Include key generation, key transfer, client encoding, encryption, server evaluation, network transfer, and client decryption.
- Check what is revealed. Decide who may decrypt each output and whether repeated predictions expose sensitive information.
There are at least three different quality questions: Does the encrypted computation match its intended arithmetic? Does the transformed model preserve useful predictions? Does the complete service meet its privacy and security goals? A good evaluation reports these separately.
16. What FHE does not do by itself
FHE protects the contents of encrypted data during supported computation under its security assumptions. It does not prove that a server followed the requested program, hide every access pattern or message size, or make the final answer safe to reveal. It also does not eliminate model approximation, numerical error, or the need to choose secure parameters correctly.
A practical design still needs a clear protocol: who owns the secret key, what the evaluator receives, which evaluation keys are exposed, how results are authenticated, and what information decryption reveals. FHE is one powerful part of a privacy system—not the whole system.
17. A practical route from plaintext code to FHE
- Write the trust story. Name the data owner, evaluator, decryptor, and intended output recipient.
- Build a plaintext reference. Fix the function, expected ranges, and accuracy target before encryption enters the picture.
- Pick a scheme by workload. Decide whether exact modular arithmetic, approximate numerical arithmetic, or Boolean-style operations fit the task.
- Map the circuit. Plan encoding, slots, depth, rotations, levels, and evaluation keys on paper.
- Select parameters from maintained guidance. Check library documentation and current security recommendations for the actual configuration.
- Measure the full pipeline. Report latency, memory, communication, setup costs, and output quality; distinguish one-time setup from per-request work.
- Review failure and leakage paths. Test edge inputs, decryption boundaries, result release, and how errors are handled.
Start with a tiny circuit and expand only after its arithmetic, precision, and key flow are understood. FHE implementations are specialized systems; familiar plaintext code does not automatically become efficient encrypted code.
Further reading
This guide is an original explanation with original text and diagrams. Its topic roadmap was informed by Ronny Ko’s The Beginner’s Textbook for Fully Homomorphic Encryption, especially its introductions to modular arithmetic, lattice-based cryptography, generic FHE operations, and the TFHE, BFV, CKKS, and BGV families. No book text or figures are reproduced here.
Ronny Ko, The Beginner’s Textbook for Fully Homomorphic Encryption (arXiv:2503.05136) ↗ · CC BY 4.0 license ↗. Consult the textbook for its detailed derivations and scheme-specific constructions.
For a practical view of parameters, ciphertext levels, keys, and scheme trade-offs, continue with my FHE systems guide →.
← Back to the blog