Botan 3.9.0
Crypto and TLS for C&
Botan::CRYSTALS::detail Namespace Reference

Functions

constexpr auto as_byte_source (BufferSlicer &slicer)
template<Domain To, template< typename, Domain > class StructureT, crystals_trait Trait, Domain From>
requires (To != From)
StructureT< Trait, To > domain_cast (StructureT< Trait, From > &&p)
template<crystals_trait Trait>
void dot_product (Polynomial< Trait, Domain::NTT > &out, const PolynomialVector< Trait, Domain::NTT > &a, const PolynomialVector< Trait, Domain::NTT > &b)
template<crystals_trait Trait, Domain D>
void montgomery (Polynomial< Trait, D > &p)

Function Documentation

◆ as_byte_source()

auto Botan::CRYSTALS::detail::as_byte_source ( BufferSlicer & slicer)
constexpr

Definition at line 30 of file pqcrystals_encoding.h.

30 {
31 return [&](std::span<uint8_t> out) { slicer.copy_into(out); };
32}
void copy_into(std::span< uint8_t > sink)
Definition stl_util.h:112

References Botan::BufferSlicer::copy_into().

Referenced by Botan::CRYSTALS::unpack().

◆ domain_cast()

template<Domain To, template< typename, Domain > class StructureT, crystals_trait Trait, Domain From>
requires (To != From)
StructureT< Trait, To > Botan::CRYSTALS::detail::domain_cast ( StructureT< Trait, From > && p)

Converts polynomials or polynomial vectors from one domain to another.

Definition at line 163 of file pqcrystals.h.

163 {
164 // The public factory method `from_domain_cast` is just a workaround for
165 // Xcode and NDK not understanding the friend declaration to allow this
166 // to directly call the private constructor.
167 return StructureT<Trait, To>::from_domain_cast(std::move(p));
168}

Referenced by Botan::CRYSTALS::Polynomial< DilithiumPolyTraits, Botan::CRYSTALS::Domain::NTT >::detail::domain_cast, Botan::CRYSTALS::PolynomialVector< DilithiumPolyTraits, Botan::CRYSTALS::Domain::NTT >::detail::domain_cast, Botan::CRYSTALS::inverse_ntt(), Botan::CRYSTALS::inverse_ntt(), Botan::CRYSTALS::ntt(), and Botan::CRYSTALS::ntt().

◆ dot_product()

template<crystals_trait Trait>
void Botan::CRYSTALS::detail::dot_product ( Polynomial< Trait, Domain::NTT > & out,
const PolynomialVector< Trait, Domain::NTT > & a,
const PolynomialVector< Trait, Domain::NTT > & b )

Definition at line 547 of file pqcrystals.h.

549 {
550 BOTAN_ASSERT(a.size() == b.size(), "Dot product requires equally sized PolynomialVectors");
551 for(size_t i = 0; i < a.size(); ++i) {
552 out += a[i] * b[i];
553 }
554 out.reduce();
555}
#define BOTAN_ASSERT(expr, assertion_made)
Definition assert.h:62
ThisPolynomial & reduce()
Definition pqcrystals.h:320

References BOTAN_ASSERT, Botan::CRYSTALS::Polynomial< Trait, D >::reduce(), and Botan::CRYSTALS::PolynomialVector< Trait, D >::size().

Referenced by Botan::CRYSTALS::operator*().

◆ montgomery()

template<crystals_trait Trait, Domain D>
void Botan::CRYSTALS::detail::montgomery ( Polynomial< Trait, D > & p)

Definition at line 540 of file pqcrystals.h.

540 {
541 for(auto& c : p) {
542 c = Trait::to_montgomery(c);
543 }
544}

Referenced by Botan::CRYSTALS::montgomery(), and Botan::CRYSTALS::montgomery().