Botan  2.15.0
Crypto and TLS for C++11
Public Member Functions | List of all members
Botan::PointGFp_Multi_Point_Precompute Class Referencefinal

#include <point_mul.h>

Public Member Functions

PointGFp multi_exp (const BigInt &k1, const BigInt &k2) const
 
 PointGFp_Multi_Point_Precompute (const PointGFp &g1, const PointGFp &g2)
 

Detailed Description

Definition at line 66 of file point_mul.h.

Constructor & Destructor Documentation

◆ PointGFp_Multi_Point_Precompute()

Botan::PointGFp_Multi_Point_Precompute::PointGFp_Multi_Point_Precompute ( const PointGFp g1,
const PointGFp g2 
)

Definition at line 342 of file point_mul.cpp.

References Botan::PointGFp::force_all_affine(), Botan::PointGFp::mult2(), Botan::PointGFp::plus(), and Botan::PointGFp::WORKSPACE_SIZE.

344  {
345  std::vector<BigInt> ws(PointGFp::WORKSPACE_SIZE);
346 
347  PointGFp x2 = x;
348  x2.mult2(ws);
349 
350  const PointGFp x3(x2.plus(x, ws));
351 
352  PointGFp y2 = y;
353  y2.mult2(ws);
354 
355  const PointGFp y3(y2.plus(y, ws));
356 
357  m_M.reserve(15);
358 
359  m_M.push_back(x);
360  m_M.push_back(x2);
361  m_M.push_back(x3);
362 
363  m_M.push_back(y);
364  m_M.push_back(y.plus(x, ws));
365  m_M.push_back(y.plus(x2, ws));
366  m_M.push_back(y.plus(x3, ws));
367 
368  m_M.push_back(y2);
369  m_M.push_back(y2.plus(x, ws));
370  m_M.push_back(y2.plus(x2, ws));
371  m_M.push_back(y2.plus(x3, ws));
372 
373  m_M.push_back(y3);
374  m_M.push_back(y3.plus(x, ws));
375  m_M.push_back(y3.plus(x2, ws));
376  m_M.push_back(y3.plus(x3, ws));
377 
378  PointGFp::force_all_affine(m_M, ws[0].get_word_vector());
379  }
static void force_all_affine(std::vector< PointGFp > &points, secure_vector< word > &ws)
Definition: point_gfp.cpp:420

Member Function Documentation

◆ multi_exp()

PointGFp Botan::PointGFp_Multi_Point_Precompute::multi_exp ( const BigInt k1,
const BigInt k2 
) const

Definition at line 381 of file point_mul.cpp.

References Botan::PointGFp::add_affine(), Botan::BigInt::bits(), Botan::BigInt::get_substring(), Botan::BigInt::is_negative(), Botan::PointGFp::mult2i(), Botan::PointGFp::negate(), Botan::round_up(), and Botan::PointGFp::WORKSPACE_SIZE.

Referenced by Botan::multi_exponentiate(), and Botan::EC_Group::point_multiply().

383  {
384  std::vector<BigInt> ws(PointGFp::WORKSPACE_SIZE);
385 
386  const size_t z_bits = round_up(std::max(z1.bits(), z2.bits()), 2);
387 
388  PointGFp H = m_M[0].zero();
389 
390  for(size_t i = 0; i != z_bits; i += 2)
391  {
392  if(i > 0)
393  {
394  H.mult2i(2, ws);
395  }
396 
397  const uint32_t z1_b = z1.get_substring(z_bits - i - 2, 2);
398  const uint32_t z2_b = z2.get_substring(z_bits - i - 2, 2);
399 
400  const uint32_t z12 = (4*z2_b) + z1_b;
401 
402  // This function is not intended to be const time
403  if(z12)
404  {
405  H.add_affine(m_M[z12-1], ws);
406  }
407  }
408 
409  if(z1.is_negative() != z2.is_negative())
410  H.negate();
411 
412  return H;
413  }
size_t round_up(size_t n, size_t align_to)
Definition: rounding.h:21

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