Botan 2.19.1
Crypto and TLS for C&
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 343 of file point_mul.cpp.

345 {
346 std::vector<BigInt> ws(PointGFp::WORKSPACE_SIZE);
347
348 PointGFp x2 = x;
349 x2.mult2(ws);
350
351 const PointGFp x3(x2.plus(x, ws));
352
353 PointGFp y2 = y;
354 y2.mult2(ws);
355
356 const PointGFp y3(y2.plus(y, ws));
357
358 m_M.reserve(15);
359
360 m_M.push_back(x);
361 m_M.push_back(x2);
362 m_M.push_back(x3);
363
364 m_M.push_back(y);
365 m_M.push_back(y.plus(x, ws));
366 m_M.push_back(y.plus(x2, ws));
367 m_M.push_back(y.plus(x3, ws));
368
369 m_M.push_back(y2);
370 m_M.push_back(y2.plus(x, ws));
371 m_M.push_back(y2.plus(x2, ws));
372 m_M.push_back(y2.plus(x3, ws));
373
374 m_M.push_back(y3);
375 m_M.push_back(y3.plus(x, ws));
376 m_M.push_back(y3.plus(x2, ws));
377 m_M.push_back(y3.plus(x3, ws));
378
379 bool no_infinity = true;
380 for(auto& pt : m_M)
381 {
382 if(pt.is_zero())
383 no_infinity = false;
384 }
385
386 if(no_infinity)
387 {
388 PointGFp::force_all_affine(m_M, ws[0].get_word_vector());
389 }
390
391 m_no_infinity = no_infinity;
392 }
static void force_all_affine(std::vector< PointGFp > &points, secure_vector< word > &ws)
Definition: point_gfp.cpp:420

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

Member Function Documentation

◆ multi_exp()

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

Definition at line 394 of file point_mul.cpp.

396 {
397 std::vector<BigInt> ws(PointGFp::WORKSPACE_SIZE);
398
399 const size_t z_bits = round_up(std::max(z1.bits(), z2.bits()), 2);
400
401 PointGFp H = m_M[0].zero();
402
403 for(size_t i = 0; i != z_bits; i += 2)
404 {
405 if(i > 0)
406 {
407 H.mult2i(2, ws);
408 }
409
410 const uint32_t z1_b = z1.get_substring(z_bits - i - 2, 2);
411 const uint32_t z2_b = z2.get_substring(z_bits - i - 2, 2);
412
413 const uint32_t z12 = (4*z2_b) + z1_b;
414
415 // This function is not intended to be const time
416 if(z12)
417 {
418 if(m_no_infinity)
419 H.add_affine(m_M[z12-1], ws);
420 else
421 H.add(m_M[z12-1], ws);
422 }
423 }
424
425 if(z1.is_negative() != z2.is_negative())
426 H.negate();
427
428 return H;
429 }
size_t round_up(size_t n, size_t align_to)
Definition: rounding.h:21

References Botan::PointGFp::add(), 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().


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