Polynomials, the Canonical Embedding, and Encoding

surprisetalk1 pts0 comments

CKKS — Polynomials, the Canonical Embedding, and Encoding || Math ∩ Programming

CKKS — Polynomials, the Canonical Embedding, and Encoding<br>#cryptography<br>#ckks<br>#ckks tutorial<br>#homomorphic encryption<br>#programming<br>#mathematics<br>#python<br>2026-04-29<br>Table of Contents<br>In this tutorial series, I will introduce the CKKS homomorphic encryption<br>scheme from the ground up, in rather intricate detail. Each article in this<br>series corresponds to a pull request on a GitHub<br>repository. The code for this article<br>is in this pull request.<br>Follow along by cloning the<br>repository and checking out the code at the relevant commit.<br>This first article will cover some of the mathematical background necessary in<br>the formulation of the CKKS encryption scheme, specifically the polynomial ring<br>used in the most basic version of CKKS, and the canonical embedding used to<br>encode cleartext messages as plaintexts.<br>This series will contain plenty of mathematics, but I may abbreviate some<br>verbose definitions, especially those that I would expect to be familiar to<br>readers of this blog (such as the formal definition of a ring). In other words,<br>I&rsquo;ll assume basic undergraduate mathematics familiarity, with some reminders. A<br>good accompaniment for this series would be The Beginner&rsquo;s Textbook for Fully<br>Homomorphic Encryption by Ronny Ko, which<br>complements this series in giving more complete (albeit terse) definitions,<br>formulas, and proofs.<br>A brief history of CKKS<br>Some of the terms used in this section may make more sense if you&rsquo;ve read<br>my high-level technical overview of homomorphic encryption.<br>We will re-cover all of this in detail in future articles.<br>The original CKKS homomorphic encryption scheme was introduced in the 2016<br>paper Homomorphic Encryption for Arithmetic of Approximate<br>Numbers by Jung Hee Cheon, Andrey Kim, Miran<br>Kim, and Yongsoo Song as a joint collaboration between Seoul National<br>University and UC San Diego.1 Its primary innovation was to handle<br>approximate arithmetic on real or complex numbers, rather than prior schemes<br>which only handled exact arithmetic on integers. This is relevant in contexts<br>like neural network inference, where the calculations can be inexact and still<br>useful. In particular, CKKS allows the inexactness of fixed-point arithmetic<br>to coexist with the error introduced by the homomorphic encryption scheme itself.<br>After its initial publication, several followup papers made improvements to<br>CKKS that elevated it to the state of the art. First, and most importantly, a<br>bootstrapping procedure was found in 2018<br>that made CKKS &ldquo;fully homomorphic.&rdquo; Subsequent years saw a plethora of additional<br>improvements and variants to CKKS bootstrapping. Experts would even say<br>there are too many variants to keep track of.<br>The second major improvement was the introduction of the residue number system<br>variant of CKKS in 2017. The original CKKS<br>scheme used large integer arithmetic, in particular doing arithmetic modulo<br>hundred-bit or even thousand-bit moduli. Using a residue number system (RNS)<br>allows one to replace the (inherently serial) carry propagation required for<br>large-precision arithmetic with parallel operations on vectors of 64-bit<br>values.2<br>Combining RNS with bootstrapping produces what, in my view, is the &ldquo;baseline&rdquo;<br>version of CKKS that most new works extend or use for contrast.<br>Plaintexts and a polynomial ring<br>The main setting for CKKS is a particular polynomial ring. We start with<br>some ring $R$ of coefficients for the polynomials $R[x]$;<br>sometimes $R$ will be the integers, reals,<br>but more often it will be the field of integers modulo a prime.<br>CKKS is an encryption scheme, and in every encryption scheme there are three<br>distinct spaces: the cleartext space, the plaintext space, and the<br>ciphertext space.<br>Cleartexts describe the atomic message units<br>(e.g., a vector of 32-bit integers of a fixed size).<br>The user must decide how to split their larger program data into cleartext units, say, by chunking.<br>Plaintexts describe preprocessing required to make a cleartext compatible with the encryption scheme.<br>And ciphertexts are the form of the messages after they are encrypted.<br>I spell all this out because, while many encryption schemes don&rsquo;t have major differences<br>between cleartext and plaintext space, CKKS uses a sophisticated transformation.<br>This article focuses purely on the conversion between the cleartext and plaintext space.<br>Fix a parameter $N$, a power of two, which will be used to define the polynomial ring.<br>A CKKS cleartext is a vector of $N/2$ complex numbers.3<br>A CKKS plaintext is an element of the ring<br>\[ (\mathbb{Z}/Q\mathbb{Z})[x] \Big / (x^N+1) \]As a reminder, the coefficients $\mathbb{Z}/Q\mathbb{Z}$ form the ring of integers<br>with arithmetic done modulo $Q$. If $Q$ were a prime, this would form a field, but<br>in most cases $Q$ is composite.<br>As a second reminder, the polynomial modulus converts the ring of polynomials<br>mod $Q$ into a quotient ring where two polynomials $p(x)$ and...

ckks encryption ring homomorphic scheme arithmetic

Related Articles