#include <dilithium_polynomial.h>
|
static constexpr void | barrett_reduce (std::span< T, N > poly) |
|
static constexpr void | inverse_ntt (std::span< T, N > coeffs) |
|
static constexpr void | ntt (std::span< T, N > coeffs) |
|
static constexpr void | poly_add (std::span< T, N > result, std::span< const T, N > lhs, std::span< const T, N > rhs) |
|
static constexpr void | poly_cadd_q (std::span< T, N > coeffs) |
| Adds Q if the coefficient is negative.
|
|
static constexpr void | poly_pointwise_montgomery (std::span< T, N > result, std::span< const T, N > lhs, std::span< const T, N > rhs) |
|
static constexpr void | poly_sub (std::span< T, N > result, std::span< const T, N > lhs, std::span< const T, N > rhs) |
|
static constexpr void | polyvec_pointwise_acc_montgomery (std::span< T, N > w, std::span< const T > u, std::span< const T > v) |
| Multiplication and accumulation of 2 polynomial vectors u and v .
|
|
static constexpr T | to_montgomery (T a) |
|
|
static constexpr T | N |
|
static constexpr T | Q |
|
Definition at line 22 of file dilithium_polynomial.h.
◆ T2
◆ barrett_reduce()
|
inlinestaticconstexprinherited |
Definition at line 120 of file pqcrystals.h.
120 {
121 for(auto& coeff : poly) {
122 coeff = DerivedT::barrett_reduce_coefficient(coeff);
123 }
124 }
◆ fqmul()
|
inlinestaticconstexprprotectedinherited |
◆ inverse_ntt()
static constexpr void Botan::DilithiumPolyTraits::inverse_ntt |
( |
std::span< T, N > | coeffs | ) |
|
|
inlinestaticconstexpr |
NIST FIPS 204, Algorithm 42 (NTT^-1).
The output is effectively multiplied by the montgomery parameter 2^32 mod q so that the input factors 2^(-32) mod q are eliminated. Note that factors 2^(-32) mod q are introduced by multiplication and reduction of values not in montgomery domain.
Produces the result of the inverse NTT transformation with a montgomery factor of (2^32 mod q) added (!). See above.
Definition at line 78 of file dilithium_polynomial.h.
78 {
79 size_t j;
81 for(
size_t len = 1; len <
N; len <<= 1) {
82 for(
size_t start = 0; start <
N; start = j + len) {
83 const T zeta = -
zetas[--k];
84 for(j = start; j < start + len; ++j) {
86 coeffs[j] = t + coeffs[j + len];
87 coeffs[j + len] = t - coeffs[j + len];
88
89 coeffs[j + len] =
fqmul(zeta, coeffs[j + len]);
90 }
91 }
92 }
93
94 for(auto& coeff : coeffs) {
96 }
97 }
static constexpr T F_WITH_MONTY_SQUARED
static constexpr T fqmul(T a, T b)
static constexpr auto zetas
References Botan::CRYSTALS::Trait_Base< DilithiumConstants, DilithiumPolyTraits >::F_WITH_MONTY_SQUARED, Botan::CRYSTALS::Trait_Base< DilithiumConstants, DilithiumPolyTraits >::fqmul(), Botan::CRYSTALS::Trait_Base< DilithiumConstants, DilithiumPolyTraits >::N, and Botan::CRYSTALS::Trait_Base< DilithiumConstants, DilithiumPolyTraits >::zetas.
◆ ntt()
static constexpr void Botan::DilithiumPolyTraits::ntt |
( |
std::span< T, N > | coeffs | ) |
|
|
inlinestaticconstexpr |
◆ poly_add()
|
inlinestaticconstexprinherited |
Definition at line 97 of file pqcrystals.h.
97 {
98 for(
size_t i = 0; i <
N; ++i) {
99 result[i] = lhs[i] + rhs[i];
100 }
101 }
◆ poly_cadd_q()
|
inlinestaticconstexprinherited |
Adds Q if the coefficient is negative.
Definition at line 110 of file pqcrystals.h.
110 {
111 for(auto& coeff : coeffs) {
112 using unsigned_T = std::make_unsigned_t<T>;
114 coeff += is_negative.if_set_return(
Q);
115 }
116 }
static constexpr Mask< T > expand_top_bit(T v)
◆ poly_in_polyvec()
|
inlinestaticconstexprprotectedinherited |
- Returns
- the
index-th
polynomial in the polynomial vector polyvec
.
Definition at line 87 of file pqcrystals.h.
87 {
90 auto polyspan = polyvec.subspan(index *
N,
N);
91 return std::span<U, N>{polyspan.data(), polyspan.size()};
92 }
#define BOTAN_DEBUG_ASSERT(expr)
◆ poly_pointwise_montgomery()
static constexpr void Botan::DilithiumPolyTraits::poly_pointwise_montgomery |
( |
std::span< T, N > | result, |
|
|
std::span< const T, N > | lhs, |
|
|
std::span< const T, N > | rhs ) |
|
inlinestaticconstexpr |
◆ poly_sub()
|
inlinestaticconstexprinherited |
Definition at line 103 of file pqcrystals.h.
103 {
104 for(
size_t i = 0; i <
N; ++i) {
105 result[i] = lhs[i] - rhs[i];
106 }
107 }
◆ polys_in_polyvec()
|
inlinestaticconstexprprotectedinherited |
- Returns
- the number of polynomials in the polynomial vector
polyvec
.
Definition at line 79 of file pqcrystals.h.
79 {
81 return polyvec.size() /
N;
82 }
◆ polyvec_pointwise_acc_montgomery()
|
inlinestaticconstexprinherited |
Multiplication and accumulation of 2 polynomial vectors u
and v
.
Definition at line 127 of file pqcrystals.h.
129 {
131 std::array<T, N> t;
135 }
137 }
static constexpr void barrett_reduce(std::span< T, N > poly)
static constexpr void poly_add(std::span< T, N > result, std::span< const T, N > lhs, std::span< const T, N > rhs)
static constexpr size_t polys_in_polyvec(std::span< const T > polyvec)
static constexpr std::span< U, N > poly_in_polyvec(std::span< U > polyvec, size_t index)
constexpr void clear_mem(T *ptr, size_t n)
◆ to_montgomery()
|
inlinestaticconstexprinherited |
Definition at line 118 of file pqcrystals.h.
static constexpr T MONTY_SQUARED
◆ CRYSTALS::Trait_Base< DilithiumConstants, DilithiumPolyTraits >
◆ F_WITH_MONTY_SQUARED
|
staticconstexprprotectedinherited |
◆ MONTY
|
staticconstexprprotectedinherited |
◆ MONTY_SQUARED
|
staticconstexprprotectedinherited |
◆ Q_inverse
|
staticconstexprprotectedinherited |
◆ zetas
|
staticconstexprprotectedinherited |
The documentation for this class was generated from the following file: