Python Implementation of the Number Theoretic Transform (NTT), developed with numpy. NTT PY supports both the cyclic form and negacylic form of the transform.
Ensure all prerequisies are satisfied (pip install -r requirements.txt).
Use ntt for the forward transform:
>>> import numpy as np
>>> from src.ntt import ntt, intt
>>> q = 11; w = 3;
>>> a_hat = ntt(np.array([7, 8, 3, 4, 10]), w, q)
>>> print(a_hat)
[10. 8. 10. 8. 10.]and intt for the backwards transform:
>>> a = intt(a_hat, w, q)
>>> print(a)
[ 7. 8. 3. 4. 10.]Import with from src.ntt_n import ntt_n, intt_n and use ntt_n for the forward transform and intt_n for the backward transform.
Given the finite field
for
which is an expression of the Chinese Remainder Theorem. Note that in the product ring, multiplication is point-wise. Thus, one can easily perform multiplication in
where
Here, we require some
for
Note that here, the inverse transform is: