Botan 3.6.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 | N = ConstantsT::N |
static constexpr T | Q = ConstantsT::Q |
Protected Types | |
using | T2 = next_longer_int_t<T> |
Static Protected Member Functions | |
static constexpr T | fqmul (T a, T b) |
template<typename U > requires (std::same_as<T, U> || std::same_as<const T, 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 56 of file pqcrystals.h.
|
inlinestaticconstexpr |
Definition at line 120 of file pqcrystals.h.
Referenced by Botan::CRYSTALS::Trait_Base< ConstantsT, DerivedT >::polyvec_pointwise_acc_montgomery().
|
inlinestaticconstexprprotected |
Definition at line 94 of file pqcrystals.h.
References Botan::b.
Referenced by Botan::CRYSTALS::Trait_Base< ConstantsT, DerivedT >::to_montgomery().
|
inlinestaticconstexpr |
Definition at line 97 of file pqcrystals.h.
References Botan::CRYSTALS::Trait_Base< ConstantsT, DerivedT >::N.
Referenced by Botan::CRYSTALS::Trait_Base< ConstantsT, DerivedT >::polyvec_pointwise_acc_montgomery().
|
inlinestaticconstexpr |
Adds Q if the coefficient is negative.
Definition at line 110 of file pqcrystals.h.
References Botan::CT::Mask< T >::expand_top_bit(), and Botan::CRYSTALS::Trait_Base< ConstantsT, DerivedT >::Q.
|
inlinestaticconstexprprotected |
index-th
polynomial in the polynomial vector polyvec
. Definition at line 87 of file pqcrystals.h.
References BOTAN_DEBUG_ASSERT, and Botan::CRYSTALS::Trait_Base< ConstantsT, DerivedT >::N.
Referenced by Botan::CRYSTALS::Trait_Base< ConstantsT, DerivedT >::polyvec_pointwise_acc_montgomery().
|
inlinestaticconstexpr |
Definition at line 103 of file pqcrystals.h.
References Botan::CRYSTALS::Trait_Base< ConstantsT, DerivedT >::N.
|
inlinestaticconstexprprotected |
polyvec
. Definition at line 79 of file pqcrystals.h.
References BOTAN_DEBUG_ASSERT, and Botan::CRYSTALS::Trait_Base< ConstantsT, DerivedT >::N.
Referenced by Botan::CRYSTALS::Trait_Base< ConstantsT, DerivedT >::polyvec_pointwise_acc_montgomery().
|
inlinestaticconstexpr |
Multiplication and accumulation of 2 polynomial vectors u
and v
.
Definition at line 127 of file pqcrystals.h.
References Botan::CRYSTALS::Trait_Base< ConstantsT, DerivedT >::barrett_reduce(), Botan::clear_mem(), Botan::CRYSTALS::Trait_Base< ConstantsT, DerivedT >::poly_add(), Botan::CRYSTALS::Trait_Base< ConstantsT, DerivedT >::poly_in_polyvec(), and Botan::CRYSTALS::Trait_Base< ConstantsT, DerivedT >::polys_in_polyvec().
|
inlinestaticconstexpr |
Definition at line 118 of file pqcrystals.h.
References Botan::CRYSTALS::Trait_Base< ConstantsT, DerivedT >::fqmul(), and Botan::CRYSTALS::Trait_Base< ConstantsT, DerivedT >::MONTY_SQUARED.
|
staticconstexprprotected |
Definition at line 71 of file pqcrystals.h.
|
staticconstexprprotected |
Definition at line 62 of file pqcrystals.h.
|
staticconstexprprotected |
Definition at line 63 of file pqcrystals.h.
Referenced by Botan::CRYSTALS::Trait_Base< ConstantsT, DerivedT >::to_montgomery().
|
staticconstexpr |
Definition at line 52 of file pqcrystals.h.
Referenced by Botan::CRYSTALS::Trait_Base< ConstantsT, DerivedT >::poly_add(), Botan::CRYSTALS::Trait_Base< ConstantsT, DerivedT >::poly_in_polyvec(), Botan::CRYSTALS::Trait_Base< ConstantsT, DerivedT >::poly_sub(), and Botan::CRYSTALS::Trait_Base< ConstantsT, DerivedT >::polys_in_polyvec().
|
staticconstexpr |
Definition at line 53 of file pqcrystals.h.
Referenced by Botan::CRYSTALS::Trait_Base< ConstantsT, DerivedT >::poly_cadd_q().
|
staticconstexprprotected |
Definition at line 61 of file pqcrystals.h.
|
staticconstexprprotected |
Definition at line 73 of file pqcrystals.h.