Botan  2.11.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 69 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 334 of file point_mul.cpp.

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

336  {
337  std::vector<BigInt> ws(PointGFp::WORKSPACE_SIZE);
338 
339  PointGFp x2 = x;
340  x2.mult2(ws);
341 
342  const PointGFp x3(x2.plus(x, ws));
343 
344  PointGFp y2 = y;
345  y2.mult2(ws);
346 
347  const PointGFp y3(y2.plus(y, ws));
348 
349  m_M.reserve(15);
350 
351  m_M.push_back(x);
352  m_M.push_back(x2);
353  m_M.push_back(x3);
354 
355  m_M.push_back(y);
356  m_M.push_back(y.plus(x, ws));
357  m_M.push_back(y.plus(x2, ws));
358  m_M.push_back(y.plus(x3, ws));
359 
360  m_M.push_back(y2);
361  m_M.push_back(y2.plus(x, ws));
362  m_M.push_back(y2.plus(x2, ws));
363  m_M.push_back(y2.plus(x3, ws));
364 
365  m_M.push_back(y3);
366  m_M.push_back(y3.plus(x, ws));
367  m_M.push_back(y3.plus(x2, ws));
368  m_M.push_back(y3.plus(x3, ws));
369 
370  PointGFp::force_all_affine(m_M, ws[0].get_word_vector());
371  }
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 373 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().

375  {
376  std::vector<BigInt> ws(PointGFp::WORKSPACE_SIZE);
377 
378  const size_t z_bits = round_up(std::max(z1.bits(), z2.bits()), 2);
379 
380  PointGFp H = m_M[0].zero();
381 
382  for(size_t i = 0; i != z_bits; i += 2)
383  {
384  if(i > 0)
385  {
386  H.mult2i(2, ws);
387  }
388 
389  const uint32_t z1_b = z1.get_substring(z_bits - i - 2, 2);
390  const uint32_t z2_b = z2.get_substring(z_bits - i - 2, 2);
391 
392  const uint32_t z12 = (4*z2_b) + z1_b;
393 
394  // This function is not intended to be const time
395  if(z12)
396  {
397  H.add_affine(m_M[z12-1], ws);
398  }
399  }
400 
401  if(z1.is_negative() != z2.is_negative())
402  H.negate();
403 
404  return H;
405  }
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: