Botan 3.9.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 FullWindows = compute_full_windows(BlindedScalar::Bits + 1, WindowBits)
static constexpr size_t InitialShift = compute_initial_shift(BlindedScalar::Bits + 1, WindowBits)
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 1451 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 1454 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 1462 of file pcurves_impl.h.

◆ ProjectivePoint

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

Definition at line 1455 of file pcurves_impl.h.

◆ Scalar

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

Definition at line 1453 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 1464 of file pcurves_impl.h.

1464 {
1465 if(sb % wb == 0) {
1466 return (sb - 1) / wb;
1467 } else {
1468 return sb / wb;
1469 }
1470 }

◆ 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 1474 of file pcurves_impl.h.

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

◆ mul()

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

Definition at line 1492 of file pcurves_impl.h.

1492 {
1493 const BlindedScalar bits(s, rng);
1494
1497
1498 for(size_t i = 0; i != FullWindows; ++i) {
1499 const size_t idx = BlindedScalar::Bits - InitialShift - WindowBits * i;
1500
1501 const size_t w_i = bits.get_window(idx);
1502 const auto [tidx, tneg] = booth_recode<WindowBits>(w_i);
1503
1504 // Conditional ok: loop iteration count is public
1505 if(i == 0) {
1506 accum = ProjectivePoint::from_affine(m_table.ct_select(tidx));
1507 accum.conditional_assign(tneg, accum.negate());
1508 } else {
1509 accum = ProjectivePoint::add_or_sub(accum, m_table.ct_select(tidx), tneg);
1510 }
1511
1512 accum = accum.dbl_n(WindowBits);
1513
1514 // Conditional ok: loop iteration count is public
1515 if(i <= 3) {
1516 accum.randomize_rep(rng);
1517 }
1518 }
1519
1520 // final window (note one bit shorter than previous reads)
1521 const size_t w_l = bits.get_window(0) & ((1 << WindowBits) - 1);
1522 const auto [tidx, tneg] = booth_recode<WindowBits>(w_l << 1);
1523 accum = ProjectivePoint::add_or_sub(accum, m_table.ct_select(tidx), tneg);
1524
1526 return accum;
1527 }
static constexpr size_t WindowBits
BlindedScalarBits< C, WindowBits+1 > BlindedScalar
static constexpr size_t InitialShift
static constexpr size_t FullWindows
constexpr void unpoison(const T *p, size_t n)
Definition ct_utils.h:65
constexpr void poison(const T *p, size_t n)
Definition ct_utils.h:54

References Botan::BlindedScalarBits< C, WindowBits+1 >::Bits, FullWindows, Botan::BlindedScalarBits< C, WindowBits >::get_window(), InitialShift, Botan::CT::poison(), Botan::CT::unpoison(), and WindowBits.

Member Data Documentation

◆ FullWindows

template<typename C, size_t W>
size_t Botan::WindowedBoothMulTable< C, W >::FullWindows = compute_full_windows(BlindedScalar::Bits + 1, WindowBits)
staticconstexpr

Definition at line 1472 of file pcurves_impl.h.

Referenced by mul().

◆ InitialShift

template<typename C, size_t W>
size_t Botan::WindowedBoothMulTable< C, W >::InitialShift = compute_initial_shift(BlindedScalar::Bits + 1, WindowBits)
staticconstexpr

Definition at line 1482 of file pcurves_impl.h.

Referenced by mul().

◆ TableBits

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

Definition at line 1457 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 1488 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 1460 of file pcurves_impl.h.

Referenced by mul().


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