Botan 3.8.1
Crypto and TLS for C&
Botan::EC_Scalar_Data_PC Class Referencefinal

#include <ec_inner_pc.h>

Inheritance diagram for Botan::EC_Scalar_Data_PC:
Botan::EC_Scalar_Data

Public Member Functions

std::unique_ptr< EC_Scalar_Dataadd (const EC_Scalar_Data &other) const override
 
void assign (const EC_Scalar_Data &y) override
 
size_t bytes () const override
 
std::unique_ptr< EC_Scalar_Dataclone () const override
 
 EC_Scalar_Data_PC (std::shared_ptr< const EC_Group_Data > group, PCurve::PrimeOrderCurve::Scalar v)
 
const std::shared_ptr< const EC_Group_Data > & group () const override
 
std::unique_ptr< EC_Scalar_Datainvert () const override
 
std::unique_ptr< EC_Scalar_Datainvert_vartime () const override
 
bool is_eq (const EC_Scalar_Data &y) const override
 
bool is_zero () const override
 
std::unique_ptr< EC_Scalar_Datamul (const EC_Scalar_Data &other) const override
 
std::unique_ptr< EC_Scalar_Datanegate () const override
 
void serialize_to (std::span< uint8_t > bytes) const override
 
void square_self () override
 
std::unique_ptr< EC_Scalar_Datasub (const EC_Scalar_Data &other) const override
 
const auto & value () const
 

Static Public Member Functions

static const EC_Scalar_Data_PCchecked_ref (const EC_Scalar_Data &data)
 

Detailed Description

Definition at line 16 of file ec_inner_pc.h.

Constructor & Destructor Documentation

◆ EC_Scalar_Data_PC()

Botan::EC_Scalar_Data_PC::EC_Scalar_Data_PC ( std::shared_ptr< const EC_Group_Data > group,
PCurve::PrimeOrderCurve::Scalar v )
inline

Definition at line 18 of file ec_inner_pc.h.

18 :
19 m_group(std::move(group)), m_v(std::move(v)) {}
const std::shared_ptr< const EC_Group_Data > & group() const override

References group().

Referenced by checked_ref().

Member Function Documentation

◆ add()

std::unique_ptr< EC_Scalar_Data > Botan::EC_Scalar_Data_PC::add ( const EC_Scalar_Data & other) const
overridevirtual

Implements Botan::EC_Scalar_Data.

Definition at line 64 of file ec_inner_pc.cpp.

64 {
65 return std::make_unique<EC_Scalar_Data_PC>(m_group, group()->pcurve().scalar_add(m_v, checked_ref(other).m_v));
66}
static const EC_Scalar_Data_PC & checked_ref(const EC_Scalar_Data &data)

References checked_ref(), and group().

◆ assign()

void Botan::EC_Scalar_Data_PC::assign ( const EC_Scalar_Data & y)
overridevirtual

Implements Botan::EC_Scalar_Data.

Definition at line 43 of file ec_inner_pc.cpp.

43 {
44 m_v = checked_ref(other).value();
45}
const auto & value() const
Definition ec_inner_pc.h:51

References checked_ref(), and value().

◆ bytes()

size_t Botan::EC_Scalar_Data_PC::bytes ( ) const
overridevirtual

Implements Botan::EC_Scalar_Data.

Definition at line 25 of file ec_inner_pc.cpp.

25 {
26 return this->group()->order_bytes();
27}

References group().

Referenced by serialize_to().

◆ checked_ref()

const EC_Scalar_Data_PC & Botan::EC_Scalar_Data_PC::checked_ref ( const EC_Scalar_Data & data)
static

Definition at line 13 of file ec_inner_pc.cpp.

13 {
14 const auto* p = dynamic_cast<const EC_Scalar_Data_PC*>(&data);
15 if(!p) {
16 throw Invalid_State("Failed conversion to EC_Scalar_Data_PC");
17 }
18 return *p;
19}
EC_Scalar_Data_PC(std::shared_ptr< const EC_Group_Data > group, PCurve::PrimeOrderCurve::Scalar v)
Definition ec_inner_pc.h:18

References EC_Scalar_Data_PC().

Referenced by add(), assign(), Botan::EC_Group_Data::gk_x_mod_order(), is_eq(), Botan::EC_AffinePoint_Data_PC::mul(), mul(), Botan::EC_Mul2Table_Data_PC::mul2_vartime(), Botan::EC_Mul2Table_Data_PC::mul2_vartime_x_mod_order_eq(), Botan::EC_Group_Data::mul_px_qy(), Botan::EC_AffinePoint_Data_PC::mul_x_only(), Botan::EC_Group_Data::point_g_mul(), and sub().

◆ clone()

std::unique_ptr< EC_Scalar_Data > Botan::EC_Scalar_Data_PC::clone ( ) const
overridevirtual

Implements Botan::EC_Scalar_Data.

Definition at line 29 of file ec_inner_pc.cpp.

29 {
30 return std::make_unique<EC_Scalar_Data_PC>(this->group(), this->value());
31}

References group(), and value().

◆ group()

const std::shared_ptr< const EC_Group_Data > & Botan::EC_Scalar_Data_PC::group ( ) const
overridevirtual

Implements Botan::EC_Scalar_Data.

Definition at line 21 of file ec_inner_pc.cpp.

21 {
22 return m_group;
23}

Referenced by add(), bytes(), clone(), EC_Scalar_Data_PC(), is_eq(), is_zero(), mul(), and sub().

◆ invert()

std::unique_ptr< EC_Scalar_Data > Botan::EC_Scalar_Data_PC::invert ( ) const
overridevirtual

Implements Botan::EC_Scalar_Data.

Definition at line 56 of file ec_inner_pc.cpp.

56 {
57 return std::make_unique<EC_Scalar_Data_PC>(m_group, m_group->pcurve().scalar_invert(m_v));
58}

◆ invert_vartime()

std::unique_ptr< EC_Scalar_Data > Botan::EC_Scalar_Data_PC::invert_vartime ( ) const
overridevirtual

Implements Botan::EC_Scalar_Data.

Definition at line 60 of file ec_inner_pc.cpp.

60 {
61 return std::make_unique<EC_Scalar_Data_PC>(m_group, m_group->pcurve().scalar_invert_vartime(m_v));
62}

◆ is_eq()

bool Botan::EC_Scalar_Data_PC::is_eq ( const EC_Scalar_Data & y) const
overridevirtual

Implements Botan::EC_Scalar_Data.

Definition at line 38 of file ec_inner_pc.cpp.

38 {
39 auto& pcurve = group()->pcurve();
40 return pcurve.scalar_equal(m_v, checked_ref(other).m_v);
41}

References checked_ref(), and group().

◆ is_zero()

bool Botan::EC_Scalar_Data_PC::is_zero ( ) const
overridevirtual

Implements Botan::EC_Scalar_Data.

Definition at line 33 of file ec_inner_pc.cpp.

33 {
34 auto& pcurve = this->group()->pcurve();
35 return pcurve.scalar_is_zero(m_v);
36}

References group().

◆ mul()

std::unique_ptr< EC_Scalar_Data > Botan::EC_Scalar_Data_PC::mul ( const EC_Scalar_Data & other) const
overridevirtual

Implements Botan::EC_Scalar_Data.

Definition at line 72 of file ec_inner_pc.cpp.

72 {
73 return std::make_unique<EC_Scalar_Data_PC>(m_group, group()->pcurve().scalar_mul(m_v, checked_ref(other).m_v));
74}

References checked_ref(), and group().

◆ negate()

std::unique_ptr< EC_Scalar_Data > Botan::EC_Scalar_Data_PC::negate ( ) const
overridevirtual

Implements Botan::EC_Scalar_Data.

Definition at line 52 of file ec_inner_pc.cpp.

52 {
53 return std::make_unique<EC_Scalar_Data_PC>(m_group, m_group->pcurve().scalar_negate(m_v));
54}

◆ serialize_to()

void Botan::EC_Scalar_Data_PC::serialize_to ( std::span< uint8_t > bytes) const
overridevirtual

Implements Botan::EC_Scalar_Data.

Definition at line 76 of file ec_inner_pc.cpp.

76 {
77 BOTAN_ARG_CHECK(bytes.size() == m_group->order_bytes(), "Invalid output length");
78 m_group->pcurve().serialize_scalar(bytes, m_v);
79}
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:31
size_t bytes() const override

References BOTAN_ARG_CHECK, and bytes().

◆ square_self()

void Botan::EC_Scalar_Data_PC::square_self ( )
overridevirtual

Implements Botan::EC_Scalar_Data.

Definition at line 47 of file ec_inner_pc.cpp.

47 {
48 // TODO square in place
49 m_v = m_group->pcurve().scalar_square(m_v);
50}

◆ sub()

std::unique_ptr< EC_Scalar_Data > Botan::EC_Scalar_Data_PC::sub ( const EC_Scalar_Data & other) const
overridevirtual

Implements Botan::EC_Scalar_Data.

Definition at line 68 of file ec_inner_pc.cpp.

68 {
69 return std::make_unique<EC_Scalar_Data_PC>(m_group, group()->pcurve().scalar_sub(m_v, checked_ref(other).m_v));
70}

References checked_ref(), and group().

◆ value()

const auto & Botan::EC_Scalar_Data_PC::value ( ) const
inline

Definition at line 51 of file ec_inner_pc.h.

51{ return m_v; }

Referenced by assign(), clone(), Botan::EC_AffinePoint_Data_PC::mul(), and Botan::EC_AffinePoint_Data_PC::mul_x_only().


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