diff --git a/README.md b/README.md index d70df69..3bf37e1 100644 --- a/README.md +++ b/README.md @@ -15,5 +15,6 @@ Notes, code and documents done while reading books and papers. - [Notes on Spartan](notes_spartan.pdf) - [Notes on Nova](notes_nova.pdf) - [Notes on HyperNova](notes_hypernova.pdf) +- [Notes on NTT](notes_ntt.pdf) Also some Sage implementations can be found in the `*.sage` files of this repo. diff --git a/notes_ntt.pdf b/notes_ntt.pdf new file mode 100644 index 0000000..28dda1f Binary files /dev/null and b/notes_ntt.pdf differ diff --git a/notes_ntt.tex b/notes_ntt.tex new file mode 100644 index 0000000..b8eec0b --- /dev/null +++ b/notes_ntt.tex @@ -0,0 +1,290 @@ +\documentclass{article} +\usepackage[utf8]{inputenc} +\usepackage{amsfonts} +\usepackage{amsthm} +\usepackage{amsmath} +\usepackage{enumerate} + +\usepackage{hyperref} +\hypersetup{ + colorlinks, + citecolor=black, + filecolor=black, + linkcolor=black, + urlcolor=blue +} + + +\newcommand{\Zq}{\mathbb{Z}_q} +\newcommand{\Rq}{\mathbb{Z}_q[X]/(X^n+1)} + + +\title{NTT for Negacyclic Polynomial Multiplication} +\author{arnaucube} +\date{January 2025} + +\begin{document} + +\maketitle + +\begin{abstract} + Notes taken while studying the NTT, mostly from \cite{10177902}. + + Usually while reading books and papers I take handwritten notes in a notebook, this document contains some of them re-written to $LaTeX$. + + The notes are not complete, don't include all the steps neither all the proofs. + + An implementation of the NTT can be found at\\ + \href{https://github.com/arnaucube/fhe-study/blob/main/arithmetic/src/ntt.rs}{https://github.com/arnaucube/fhe-study/blob/main/arithmetic/src/ntt.rs}. +\end{abstract} + +\tableofcontents + +\section{Main idea} +For doing multiplications in the \emph{negacyclic polynomial ring} ($\Rq$), rather than doing it in a naive way, it is more +efficient to do it through the NTT. + +This is, let $a(X), b(X) \in \Rq$, and suppose we want to +obtain $a(X) \cdot b(X)$. First apply the NTT to the two ring +elements that we want to multiply, +$$\hat{a}(X) = NTT(a(X)),~~ \hat{b}(X)=NTT(b(X))$$ +then multiply the result element-wise, +% $$\hat{c}(X) = \sum \hat{a}_i \cdot \hat{b}_i$$ +$$c= \hat{a} \circ \hat{b}$$ +where $\circ$ means the element-wise vector multiplication in $\Zq$. + +Then apply the NTT$^{-1}$ to the result, obtaining the actual value of +multiplying $a(X) \cdot b(X)$. + +\section{Cyclotomic vs Negacyclic} + +\subsection{Cyclotomic: \texorpdfstring{$\mathbb{Z}_q[X]/(X^n-1)$}{Zq[X]/(X**n-1)}} +In the cyclotomic case, the primitive n-th root of unity in $Z_q$ is $w^n \equiv 1 \pmod q$ (and +$w^k \not\equiv 1 \pmod q ~~ for k