#include <point_gfp.h>
Definition at line 289 of file point_gfp.h.
Botan::Blinded_Point_Multiply::Blinded_Point_Multiply |
( |
const PointGFp & |
base, |
|
|
const BigInt & |
order, |
|
|
size_t |
h = 0 |
|
) |
| |
Definition at line 308 of file point_gfp.cpp.
References Botan::PointGFp::get_curve(), and Botan::PointGFp::zero_of().
309 m_h(h > 0 ? h : 4), m_order(order), m_ws(9)
312 if(m_h < 1 || m_h > 8)
313 throw Invalid_Argument(
"Blinded_Point_Multiply invalid h param");
315 const CurveGFp& curve = base.get_curve();
317 const PointGFp inv = -base;
319 m_U.resize(6*m_h + 3);
325 for(
size_t i = 1; i <= 3 * m_h + 1; ++i)
327 m_U[3*m_h+1+i] = m_U[3*m_h+i];
328 m_U[3*m_h+1+i].add(base, m_ws);
330 m_U[3*m_h+1-i] = m_U[3*m_h+2-i];
331 m_U[3*m_h+1-i].add(inv, m_ws);
static PointGFp zero_of(const CurveGFp &curve)
Definition at line 335 of file point_gfp.cpp.
References Botan::BigInt::bits(), Botan::BigInt::get_bit(), Botan::BigInt::is_negative(), Botan::RandomNumberGenerator::next_byte(), and Botan::PointGFp::randomize_repr().
338 if(scalar_in.is_negative())
339 throw Invalid_Argument(
"Blinded_Point_Multiply scalar must be positive");
341 #if BOTAN_POINTGFP_USE_SCALAR_BLINDING
343 const BigInt mask(rng, (m_order.
bits()+1)/2,
false);
344 const BigInt scalar = scalar_in + m_order * mask;
346 const BigInt& scalar = scalar_in;
349 const size_t scalar_bits = scalar.
bits();
352 for(
size_t i = 0; i != m_U.size(); ++i)
353 m_U[i].randomize_repr(rng);
355 PointGFp R = m_U.at(3*m_h + 2);
358 R.randomize_repr(rng);
368 for(
size_t i = scalar_bits; i > 0; i--)
370 const int32_t ki = scalar.get_bit(i);
373 const int32_t gamma =
static_cast<int32_t
>((rng.next_byte() % (2*m_h))) - m_h;
374 const int32_t l = gamma - 2*alpha + ki - (ki ^ 1);
377 R.add(m_U.at(3*m_h + 1 + l), m_ws);
381 const int32_t k0 = scalar.get_bit(0);
382 R.add(m_U[3*m_h + 1 - alpha - (k0 ^ 1)], m_ws);
The documentation for this class was generated from the following files: