Botan 3.6.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:120

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 161 of file pqcrystals.h.

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

Referenced by 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 544 of file pqcrystals.h.

546 {
547 BOTAN_ASSERT(a.size() == b.size(), "Dot product requires equally sized PolynomialVectors");
548 for(size_t i = 0; i < a.size(); ++i) {
549 out += a[i] * b[i];
550 }
551 out.reduce();
552}
#define BOTAN_ASSERT(expr, assertion_made)
Definition assert.h:50
ThisPolynomial & reduce()
Definition pqcrystals.h:318
const SIMD_8x32 & b

References Botan::b, 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 537 of file pqcrystals.h.

537 {
538 for(auto& c : p) {
539 c = Trait::to_montgomery(c);
540 }
541}

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