|
Botan 3.14.1
Crypto and TLS for C&
|
#include <pqcrystals.h>
Public Types | |
| using | T = typename ConstantsT::T |
Static Public Member Functions | |
| 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 void | poly_cadd_q (std::span< T, N > coeffs) |
| Adds Q if the coefficient is negative. | |
| 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 Public Attributes | |
| static constexpr T | BARRETT_V = ((1U << 26) + Q / 2) / Q |
| static constexpr T | N = ConstantsT::N |
| static constexpr T | Q = ConstantsT::Q |
Protected Types | |
| using | T2 = next_longer_int_t<T> |
Protected Member Functions | |
| Trait_Base ()=default | |
Static Protected Member Functions | |
| static constexpr T | fqmul (T a, T b) |
| template<typename U> | |
| static constexpr std::span< U, N > | poly_in_polyvec (std::span< U > polyvec, size_t index) |
| static constexpr size_t | polys_in_polyvec (std::span< const T > polyvec) |
Static Protected Attributes | |
Pre-computed algorithm constants | |
| static constexpr T | Q_inverse = modular_inverse(Q) |
| static constexpr T | MONTY = montgomery_R(Q) |
| static constexpr T | MONTY_SQUARED = montgomery_R2(Q) |
| static constexpr T | F_WITH_MONTY_SQUARED = (static_cast<T2>(ConstantsT::F) * MONTY_SQUARED) % Q |
| static constexpr auto | zetas = precompute_zetas<ConstantsT::NTT_Degree>(Q, MONTY, ConstantsT::ROOT_OF_UNITY) |
This implements basic polynomial operations for Kyber and Dilithium based on the given algorithm constants (ConstantsT) and back- references some of the operations to the actual implementation into the derived class (CRTP DerivedT).
Polynomial parameters are passed as spans of coefficients for maximum flexibility.
It is assumed that this is subclassed with the actual implementation with establishing a CRTP back-reference.
Definition at line 49 of file pqcrystals.h.
| using Botan::CRYSTALS::Trait_Base< ConstantsT, DerivedT >::T = typename ConstantsT::T |
Definition at line 51 of file pqcrystals.h.
|
protected |
Definition at line 58 of file pqcrystals.h.
|
protecteddefault |
|
inlinestaticconstexpr |
Definition at line 124 of file pqcrystals.h.
Referenced by polyvec_pointwise_acc_montgomery().
|
inlinestaticconstexprprotected |
|
inlinestaticconstexpr |
Definition at line 101 of file pqcrystals.h.
References N.
Referenced by polyvec_pointwise_acc_montgomery().
|
inlinestaticconstexpr |
Adds Q if the coefficient is negative.
Definition at line 114 of file pqcrystals.h.
References Botan::CT::Mask< T >::expand_top_bit(), and Q.
|
inlinestaticconstexprprotected |
index-th polynomial in the polynomial vector polyvec. Definition at line 91 of file pqcrystals.h.
References BOTAN_DEBUG_ASSERT, and N.
Referenced by polyvec_pointwise_acc_montgomery().
|
inlinestaticconstexprprotected |
polyvec. Definition at line 83 of file pqcrystals.h.
References BOTAN_DEBUG_ASSERT, and N.
Referenced by polyvec_pointwise_acc_montgomery().
|
inlinestaticconstexpr |
Multiplication and accumulation of 2 polynomial vectors u and v.
Definition at line 131 of file pqcrystals.h.
References barrett_reduce(), Botan::clear_mem(), poly_add(), poly_in_polyvec(), and polys_in_polyvec().
|
inlinestaticconstexpr |
Definition at line 122 of file pqcrystals.h.
References fqmul(), and MONTY_SQUARED.
|
staticconstexpr |
Definition at line 55 of file pqcrystals.h.
|
staticconstexprprotected |
Definition at line 73 of file pqcrystals.h.
|
staticconstexprprotected |
Definition at line 64 of file pqcrystals.h.
|
staticconstexprprotected |
Definition at line 65 of file pqcrystals.h.
Referenced by to_montgomery().
|
staticconstexpr |
Definition at line 52 of file pqcrystals.h.
Referenced by poly_add(), poly_in_polyvec(), poly_sub(), and polys_in_polyvec().
|
staticconstexpr |
Definition at line 53 of file pqcrystals.h.
Referenced by poly_cadd_q().
|
staticconstexprprotected |
Definition at line 63 of file pqcrystals.h.
|
staticconstexprprotected |
Definition at line 75 of file pqcrystals.h.