Botan 3.11.0
Crypto and TLS for C&
Botan::WindowedBoothMulTable< C, W > Class Template Referencefinal

#include <pcurves_impl.h>

Public Types

typedef C::AffinePoint AffinePoint
using BlindedScalar = BlindedScalarBits<C, WindowBits + 1>
typedef C::ProjectivePoint ProjectivePoint
typedef C::Scalar Scalar

Public Member Functions

ProjectivePoint mul (const Scalar &s, RandomNumberGenerator &rng) const
 WindowedBoothMulTable (const AffinePoint &p)

Static Public Member Functions

static constexpr size_t compute_full_windows (size_t sb, size_t wb)
static constexpr size_t compute_initial_shift (size_t sb, size_t wb)

Static Public Attributes

static constexpr size_t TableBits = W
static constexpr size_t TableSize = 1 << TableBits
static constexpr size_t WindowBits = TableBits + 1

Detailed Description

template<typename C, size_t W>
class Botan::WindowedBoothMulTable< C, W >

Precomputed point multiplication table with Booth

Definition at line 1455 of file pcurves_impl.h.

Member Typedef Documentation

◆ AffinePoint

template<typename C, size_t W>
typedef C::AffinePoint Botan::WindowedBoothMulTable< C, W >::AffinePoint

Definition at line 1458 of file pcurves_impl.h.

◆ BlindedScalar

template<typename C, size_t W>
using Botan::WindowedBoothMulTable< C, W >::BlindedScalar = BlindedScalarBits<C, WindowBits + 1>

Definition at line 1466 of file pcurves_impl.h.

◆ ProjectivePoint

template<typename C, size_t W>
typedef C::ProjectivePoint Botan::WindowedBoothMulTable< C, W >::ProjectivePoint

Definition at line 1459 of file pcurves_impl.h.

◆ Scalar

template<typename C, size_t W>
typedef C::Scalar Botan::WindowedBoothMulTable< C, W >::Scalar

Definition at line 1457 of file pcurves_impl.h.

Constructor & Destructor Documentation

◆ WindowedBoothMulTable()

template<typename C, size_t W>
Botan::WindowedBoothMulTable< C, W >::WindowedBoothMulTable ( const AffinePoint & p)
inlineexplicit

Member Function Documentation

◆ compute_full_windows()

template<typename C, size_t W>
constexpr size_t Botan::WindowedBoothMulTable< C, W >::compute_full_windows ( size_t sb,
size_t wb )
inlinestaticconstexpr

Definition at line 1468 of file pcurves_impl.h.

1468 {
1469 if(sb % wb == 0) {
1470 return (sb - 1) / wb;
1471 } else {
1472 return sb / wb;
1473 }
1474 }

Referenced by mul().

◆ compute_initial_shift()

template<typename C, size_t W>
constexpr size_t Botan::WindowedBoothMulTable< C, W >::compute_initial_shift ( size_t sb,
size_t wb )
inlinestaticconstexpr

Definition at line 1476 of file pcurves_impl.h.

1476 {
1477 if(sb % wb == 0) {
1478 return wb;
1479 } else {
1480 return sb - (sb / wb) * wb;
1481 }
1482 }

Referenced by mul().

◆ mul()

template<typename C, size_t W>
ProjectivePoint Botan::WindowedBoothMulTable< C, W >::mul ( const Scalar & s,
RandomNumberGenerator & rng ) const
inline

Definition at line 1489 of file pcurves_impl.h.

1489 {
1490 const BlindedScalar bits(s, rng);
1491
1492 const size_t scalar_bits = bits.bits();
1495
1498
1501
1502 for(size_t i = 0; i != full_windows; ++i) {
1503 const size_t idx = scalar_bits - initial_shift - WindowBits * i;
1504
1505 const size_t w_i = bits.get_window(idx);
1506 const auto [tidx, tneg] = booth_recode<WindowBits>(w_i);
1507
1508 // Conditional ok: loop iteration count is public
1509 if(i == 0) {
1510 accum = ProjectivePoint::from_affine(m_table.ct_select(tidx));
1511 accum.conditional_assign(tneg, accum.negate());
1512 } else {
1513 accum = ProjectivePoint::add_or_sub(accum, m_table.ct_select(tidx), tneg);
1514 }
1515
1516 accum = accum.dbl_n(WindowBits);
1517
1518 // Conditional ok: loop iteration count is public
1519 if(i <= 3) {
1520 accum.randomize_rep(rng);
1521 }
1522 }
1523
1524 // final window (note one bit shorter than previous reads)
1525 const size_t w_l = bits.get_window(0) & ((1 << WindowBits) - 1);
1526 const auto [tidx, tneg] = booth_recode<WindowBits>(w_l << 1);
1527 accum = ProjectivePoint::add_or_sub(accum, m_table.ct_select(tidx), tneg);
1528
1530 return accum;
1531 }
#define BOTAN_DEBUG_ASSERT(expr)
Definition assert.h:129
static constexpr size_t WindowBits
BlindedScalarBits< C, WindowBits+1 > BlindedScalar
static constexpr size_t compute_full_windows(size_t sb, size_t wb)
static constexpr size_t compute_initial_shift(size_t sb, size_t wb)
constexpr void unpoison(const T *p, size_t n)
Definition ct_utils.h:67
constexpr void poison(const T *p, size_t n)
Definition ct_utils.h:56
constexpr std::pair< size_t, CT::Choice > booth_recode(T x)

References Botan::BlindedScalarBits< C, WindowBits >::bits(), Botan::booth_recode(), BOTAN_DEBUG_ASSERT, compute_full_windows(), compute_initial_shift(), Botan::BlindedScalarBits< C, WindowBits >::get_window(), Botan::CT::poison(), Botan::CT::unpoison(), and WindowBits.

Member Data Documentation

◆ TableBits

template<typename C, size_t W>
size_t Botan::WindowedBoothMulTable< C, W >::TableBits = W
staticconstexpr

Definition at line 1461 of file pcurves_impl.h.

◆ TableSize

template<typename C, size_t W>
size_t Botan::WindowedBoothMulTable< C, W >::TableSize = 1 << TableBits
staticconstexpr

Definition at line 1485 of file pcurves_impl.h.

Referenced by WindowedBoothMulTable().

◆ WindowBits

template<typename C, size_t W>
size_t Botan::WindowedBoothMulTable< C, W >::WindowBits = TableBits + 1
staticconstexpr

Definition at line 1464 of file pcurves_impl.h.

Referenced by mul().


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