Botan 3.6.1
Crypto and TLS for C&
Botan::PCurve::PrimeOrderCurve::Scalar Class Referencefinal

#include <pcurves.h>

Public Member Functions

const auto & _curve () const
 
const auto & _value () const
 
size_t bytes () const
 
Scalar invert () const
 
bool is_zero () const
 
Scalar negate () const
 
Scalaroperator= (const Scalar &other)=default
 
Scalaroperator= (Scalar &&other)=default
 
 Scalar (const Scalar &other)=default
 
 Scalar (Scalar &&other)=default
 
template<concepts::resizable_byte_buffer T = std::vector<uint8_t>>
T serialize () const
 
Scalar square () const
 
 ~Scalar ()=default
 

Static Public Member Functions

static Scalar _create (CurvePtr curve, StorageUnit v)
 

Friends

Scalar operator* (const Scalar &a, const Scalar &b)
 
Scalar operator+ (const Scalar &a, const Scalar &b)
 
Scalar operator- (const Scalar &a, const Scalar &b)
 
bool operator== (const Scalar &a, const Scalar &b)
 

Detailed Description

Elliptic curve scalar

This refers to the set of integers modulo the (prime) group order of the elliptic curve.

Definition at line 61 of file pcurves.h.

Constructor & Destructor Documentation

◆ Scalar() [1/2]

Botan::PCurve::PrimeOrderCurve::Scalar::Scalar ( const Scalar & other)
default

◆ Scalar() [2/2]

Botan::PCurve::PrimeOrderCurve::Scalar::Scalar ( Scalar && other)
default

◆ ~Scalar()

Botan::PCurve::PrimeOrderCurve::Scalar::~Scalar ( )
default

Member Function Documentation

◆ _create()

static Scalar Botan::PCurve::PrimeOrderCurve::Scalar::_create ( CurvePtr curve,
StorageUnit v )
inlinestatic

Definition at line 130 of file pcurves.h.

130{ return Scalar(std::move(curve), v); }
Scalar(const Scalar &other)=default

◆ _curve()

const auto & Botan::PCurve::PrimeOrderCurve::Scalar::_curve ( ) const
inline

Definition at line 126 of file pcurves.h.

126{ return m_curve; }

◆ _value()

const auto & Botan::PCurve::PrimeOrderCurve::Scalar::_value ( ) const
inline

Definition at line 128 of file pcurves.h.

128{ return m_value; }

◆ bytes()

size_t Botan::PCurve::PrimeOrderCurve::Scalar::bytes ( ) const
inline

Return the size of the byte encoding of Scalars

Definition at line 72 of file pcurves.h.

72{ return m_curve->scalar_bytes(); }

◆ invert()

Scalar Botan::PCurve::PrimeOrderCurve::Scalar::invert ( ) const
inline

Return the modular inverse of *this

If *this is zero then returns zero.

Definition at line 119 of file pcurves.h.

119{ return m_curve->scalar_invert(*this); }

Referenced by Botan::EC_Scalar_Data_PC::invert().

◆ is_zero()

bool Botan::PCurve::PrimeOrderCurve::Scalar::is_zero ( ) const
inline

Returns true if this is equal to zero

Definition at line 124 of file pcurves.h.

124{ return m_curve->scalar_is_zero(*this); }

◆ negate()

Scalar Botan::PCurve::PrimeOrderCurve::Scalar::negate ( ) const
inline

Negate modulo the group order (ie return p - *this where p is the group order)

Definition at line 107 of file pcurves.h.

107{ return m_curve->scalar_negate(*this); }

Referenced by Botan::EC_Scalar_Data_PC::negate().

◆ operator=() [1/2]

Scalar & Botan::PCurve::PrimeOrderCurve::Scalar::operator= ( const Scalar & other)
default

◆ operator=() [2/2]

Scalar & Botan::PCurve::PrimeOrderCurve::Scalar::operator= ( Scalar && other)
default

◆ serialize()

template<concepts::resizable_byte_buffer T = std::vector<uint8_t>>
T Botan::PCurve::PrimeOrderCurve::Scalar::serialize ( ) const
inline

Return the fixed length serialization of this scalar

Definition at line 78 of file pcurves.h.

78 {
79 T bytes(this->bytes());
80 m_curve->serialize_scalar(bytes, *this);
81 return bytes;
82 }
FE_25519 T
Definition ge.cpp:34

References T.

◆ square()

Scalar Botan::PCurve::PrimeOrderCurve::Scalar::square ( ) const
inline

Square modulo the group order

Definition at line 112 of file pcurves.h.

112{ return m_curve->scalar_square(*this); }

Referenced by Botan::EC_Scalar_Data_PC::square_self().

Friends And Related Symbol Documentation

◆ operator*

Scalar operator* ( const Scalar & a,
const Scalar & b )
friend

Perform integer multiplication modulo the group order

Definition at line 87 of file pcurves.h.

87{ return a.m_curve->scalar_mul(a, b); }
const SIMD_8x32 & b

◆ operator+

Scalar operator+ ( const Scalar & a,
const Scalar & b )
friend

Perform integer addition modulo the group order

Definition at line 92 of file pcurves.h.

92{ return a.m_curve->scalar_add(a, b); }

◆ operator-

Scalar operator- ( const Scalar & a,
const Scalar & b )
friend

Perform integer subtraction modulo the group order

Definition at line 97 of file pcurves.h.

97{ return a.m_curve->scalar_sub(a, b); }

◆ operator==

bool operator== ( const Scalar & a,
const Scalar & b )
friend

Check for equality

Definition at line 102 of file pcurves.h.

102{ return a.m_curve->scalar_equal(a, b); }

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