Botan 3.9.0
Crypto and TLS for C&
Botan::AffinePointTable< C, R > Class Template Referencefinal

#include <pcurves_mul.h>

Public Types

using AffinePoint = typename C::AffinePoint
using ProjectivePoint = typename C::ProjectivePoint
using WordType = typename C::WordType

Public Member Functions

 AffinePointTable (std::span< const ProjectivePoint > pts)
AffinePoint ct_select (size_t idx) const
AffinePoint ct_select (size_t idx, size_t iter) const

Static Public Attributes

static constexpr bool WholeRangeSearch = (R == 0)

Detailed Description

template<typename C, size_t R = 0>
class Botan::AffinePointTable< C, R >

A precomputed table of affine points with constant time lookup

If R is zero then the entire table is scanned for each lookup.

If R is not zero, then the table must be a multiple of R points long. Each lookup will be examine a range of length R, as in pts[0..R], pts[R..2*R], ...

Definition at line 38 of file pcurves_mul.h.

Member Typedef Documentation

◆ AffinePoint

template<typename C, size_t R = 0>
using Botan::AffinePointTable< C, R >::AffinePoint = typename C::AffinePoint

Definition at line 40 of file pcurves_mul.h.

◆ ProjectivePoint

template<typename C, size_t R = 0>
using Botan::AffinePointTable< C, R >::ProjectivePoint = typename C::ProjectivePoint

Definition at line 41 of file pcurves_mul.h.

◆ WordType

template<typename C, size_t R = 0>
using Botan::AffinePointTable< C, R >::WordType = typename C::WordType

Definition at line 42 of file pcurves_mul.h.

Constructor & Destructor Documentation

◆ AffinePointTable()

template<typename C, size_t R = 0>
Botan::AffinePointTable< C, R >::AffinePointTable ( std::span< const ProjectivePoint > pts)
inlineexplicit

Definition at line 46 of file pcurves_mul.h.

46 {
47 BOTAN_ASSERT_NOMSG(pts.size() > 1);
48
49 if constexpr(R > 0) {
50 BOTAN_ASSERT_NOMSG(pts.size() % R == 0);
51 }
52
53 // TODO scatter/gather with SIMD lookup
54 m_table = to_affine_batch<C>(pts);
55 }
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:75
auto to_affine_batch(std::span< const typename C::ProjectivePoint > projective)

References BOTAN_ASSERT_NOMSG, and Botan::to_affine_batch().

Member Function Documentation

◆ ct_select() [1/2]

template<typename C, size_t R = 0>
AffinePoint Botan::AffinePointTable< C, R >::ct_select ( size_t idx) const
inline

If idx is zero then return the identity element. Otherwise return pts[idx - 1]

Definition at line 60 of file pcurves_mul.h.

62 {
63 BOTAN_DEBUG_ASSERT(idx < m_table.size() + 1);
64
65 auto result = AffinePoint::identity(m_table[0]);
66
67 // Intentionally wrapping; set to maximum size_t if idx == 0
68 const size_t idx1 = static_cast<size_t>(idx - 1);
69 for(size_t i = 0; i != m_table.size(); ++i) {
70 const auto found = CT::Mask<size_t>::is_equal(idx1, i).as_choice();
71 result.conditional_assign(found, m_table[i]);
72 }
73
74 return result;
75 }
#define BOTAN_DEBUG_ASSERT(expr)
Definition assert.h:129
static constexpr Mask< T > is_equal(T x, T y)
Definition ct_utils.h:470

References BOTAN_DEBUG_ASSERT, Botan::CT::Mask< T >::is_equal(), and WholeRangeSearch.

Referenced by Botan::mul2_exec(), and Botan::varpoint_exec().

◆ ct_select() [2/2]

template<typename C, size_t R = 0>
AffinePoint Botan::AffinePointTable< C, R >::ct_select ( size_t idx,
size_t iter ) const
inline

If idx is zero then return the identity element. Otherwise return pts[idx - 1] out of the table subrange pts[iter*R..(iter+1)*R]

Definition at line 81 of file pcurves_mul.h.

83 {
85 BOTAN_DEBUG_ASSERT(R * (iter + 1) <= m_table.size());
86
87 auto result = AffinePoint::identity(m_table[R * iter]);
88
89 // Intentionally wrapping; set to maximum size_t if idx == 0
90 const size_t idx1 = static_cast<size_t>(idx - 1);
91 for(size_t i = 0; i != R; ++i) {
92 const auto found = CT::Mask<size_t>::is_equal(idx1, i).as_choice();
93 result.conditional_assign(found, m_table[R * iter + i]);
94 }
95
96 return result;
97 }

References BOTAN_DEBUG_ASSERT, Botan::CT::Mask< T >::is_equal(), and WholeRangeSearch.

Member Data Documentation

◆ WholeRangeSearch

template<typename C, size_t R = 0>
bool Botan::AffinePointTable< C, R >::WholeRangeSearch = (R == 0)
staticconstexpr

Definition at line 44 of file pcurves_mul.h.

Referenced by ct_select(), and ct_select().


The documentation for this class was generated from the following file: