Botan 3.11.0
Crypto and TLS for C&
Botan::AffineCurvePoint< FieldElement > Class Template Referencefinal

#include <pcurves_impl.h>

Public Types

using Self = AffineCurvePoint<FieldElement>

Public Member Functions

constexpr void _const_time_poison () const
constexpr void _const_time_unpoison () const
constexpr AffineCurvePoint ()
constexpr AffineCurvePoint (const FieldElement &x, const FieldElement &y)
 AffineCurvePoint (const Self &other)=default
 AffineCurvePoint (Self &&other)=default
constexpr void conditional_assign (CT::Choice cond, const Self &pt)
constexpr CT::Choice is_identity () const
constexpr Self negate () const
AffineCurvePointoperator= (const Self &other)=default
AffineCurvePointoperator= (Self &&other)=default
constexpr void serialize_to (std::span< uint8_t, Self::BYTES > bytes) const
constexpr const FieldElement & x () const
constexpr const FieldElement & y () const
 ~AffineCurvePoint ()=default

Static Public Member Functions

static constexpr auto ct_select (std::span< const Self > pts, size_t idx)
static constexpr Self identity ()
static constexpr Self identity (const Self &)

Static Public Attributes

static constexpr size_t BYTES = 1 + 2 * FieldElement::BYTES

Detailed Description

template<typename FieldElement>
class Botan::AffineCurvePoint< FieldElement >

Affine Curve Point

This contains a pair of integers (x,y) which satisfy the curve equation

Definition at line 909 of file pcurves_impl.h.

Member Typedef Documentation

◆ Self

template<typename FieldElement>
using Botan::AffineCurvePoint< FieldElement >::Self = AffineCurvePoint<FieldElement>

Definition at line 913 of file pcurves_impl.h.

Constructor & Destructor Documentation

◆ AffineCurvePoint() [1/4]

template<typename FieldElement>
Botan::AffineCurvePoint< FieldElement >::AffineCurvePoint ( const FieldElement & x,
const FieldElement & y )
inlineconstexpr

Definition at line 917 of file pcurves_impl.h.

917: m_x(x), m_y(y) {}
constexpr const FieldElement & y() const
constexpr const FieldElement & x() const

References x(), and y().

Referenced by operator=(), and operator=().

◆ AffineCurvePoint() [2/4]

template<typename FieldElement>
Botan::AffineCurvePoint< FieldElement >::AffineCurvePoint ( )
inlineconstexpr

Definition at line 919 of file pcurves_impl.h.

◆ AffineCurvePoint() [3/4]

template<typename FieldElement>
Botan::AffineCurvePoint< FieldElement >::AffineCurvePoint ( const Self & other)
default

◆ AffineCurvePoint() [4/4]

template<typename FieldElement>
Botan::AffineCurvePoint< FieldElement >::AffineCurvePoint ( Self && other)
default

◆ ~AffineCurvePoint()

template<typename FieldElement>
Botan::AffineCurvePoint< FieldElement >::~AffineCurvePoint ( )
default

Member Function Documentation

◆ _const_time_poison()

template<typename FieldElement>
void Botan::AffineCurvePoint< FieldElement >::_const_time_poison ( ) const
inlineconstexpr

Definition at line 985 of file pcurves_impl.h.

985{ CT::poison_all(m_x, m_y); }
constexpr void poison_all(const Ts &... ts)
Definition ct_utils.h:201

References Botan::CT::poison_all().

◆ _const_time_unpoison()

template<typename FieldElement>
void Botan::AffineCurvePoint< FieldElement >::_const_time_unpoison ( ) const
inlineconstexpr

Definition at line 987 of file pcurves_impl.h.

987{ CT::unpoison_all(m_x, m_y); }
constexpr void unpoison_all(const Ts &... ts)
Definition ct_utils.h:207

References Botan::CT::unpoison_all().

◆ conditional_assign()

template<typename FieldElement>
void Botan::AffineCurvePoint< FieldElement >::conditional_assign ( CT::Choice cond,
const Self & pt )
inlineconstexpr

Conditional assignment of an affine point

Definition at line 981 of file pcurves_impl.h.

981 {
982 FieldElement::conditional_assign(m_x, m_y, cond, pt.x(), pt.y());
983 }

References x(), and y().

◆ ct_select()

template<typename FieldElement>
constexpr auto Botan::AffineCurvePoint< FieldElement >::ct_select ( std::span< const Self > pts,
size_t idx )
inlinestaticconstexpr

If idx is zero then return the identity element. Otherwise return pts[idx - 1]

Returns the identity element also if idx is out of range

Definition at line 955 of file pcurves_impl.h.

955 {
956 auto result = Self::identity(pts[0]);
957
958 // Intentionally wrapping; set to maximum size_t if idx == 0
959 const size_t idx1 = static_cast<size_t>(idx - 1);
960 for(size_t i = 0; i != pts.size(); ++i) {
961 const auto found = CT::Mask<size_t>::is_equal(idx1, i).as_choice();
963 }
964
965 return result;
966 }
static constexpr Self identity()
constexpr void conditional_assign(CT::Choice cond, const Self &pt)
static constexpr Mask< T > is_equal(T x, T y)
Definition ct_utils.h:442

References identity(), and Botan::CT::Mask< T >::is_equal().

◆ identity() [1/2]

template<typename FieldElement>
constexpr Self Botan::AffineCurvePoint< FieldElement >::identity ( )
inlinestaticconstexpr

Definition at line 921 of file pcurves_impl.h.

AffineCurvePoint< FieldElement > Self

Referenced by ct_select().

◆ identity() [2/2]

template<typename FieldElement>
constexpr Self Botan::AffineCurvePoint< FieldElement >::identity ( const Self & )
inlinestaticconstexpr

Definition at line 924 of file pcurves_impl.h.

924 {
926 }

◆ is_identity()

template<typename FieldElement>
CT::Choice Botan::AffineCurvePoint< FieldElement >::is_identity ( ) const
inlineconstexpr

Definition at line 928 of file pcurves_impl.h.

928{ return x().is_zero() && y().is_zero(); }

References x(), and y().

Referenced by Botan::ProjectiveCurvePoint< FieldElement, Params >::from_affine(), and serialize_to().

◆ negate()

template<typename FieldElement>
Self Botan::AffineCurvePoint< FieldElement >::negate ( ) const
inlineconstexpr

Definition at line 936 of file pcurves_impl.h.

936{ return Self(x(), y().negate()); }
constexpr Self negate() const

References negate(), x(), and y().

Referenced by negate().

◆ operator=() [1/2]

template<typename FieldElement>
AffineCurvePoint & Botan::AffineCurvePoint< FieldElement >::operator= ( const Self & other)
default

References AffineCurvePoint().

◆ operator=() [2/2]

template<typename FieldElement>
AffineCurvePoint & Botan::AffineCurvePoint< FieldElement >::operator= ( Self && other)
default

References AffineCurvePoint().

◆ serialize_to()

template<typename FieldElement>
void Botan::AffineCurvePoint< FieldElement >::serialize_to ( std::span< uint8_t, Self::BYTES > bytes) const
inlineconstexpr

Serialize the point in uncompressed format

Definition at line 941 of file pcurves_impl.h.

941 {
942 BOTAN_STATE_CHECK(this->is_identity().as_bool() == false);
944 pack.append(0x04);
946 y().serialize_to(pack.next<FieldElement::BYTES>());
947 BOTAN_DEBUG_ASSERT(pack.full());
948 }
#define BOTAN_DEBUG_ASSERT(expr)
Definition assert.h:129
#define BOTAN_STATE_CHECK(expr)
Definition assert.h:49
constexpr void serialize_to(std::span< uint8_t, Self::BYTES > bytes) const
constexpr CT::Choice is_identity() const

References BOTAN_DEBUG_ASSERT, BOTAN_STATE_CHECK, is_identity(), x(), and y().

◆ x()

template<typename FieldElement>
const FieldElement & Botan::AffineCurvePoint< FieldElement >::x ( ) const
inlineconstexpr

Return the affine x coordinate

Definition at line 971 of file pcurves_impl.h.

971{ return m_x; }

Referenced by AffineCurvePoint(), conditional_assign(), Botan::ProjectiveCurvePoint< FieldElement, Params >::from_affine(), is_identity(), negate(), and serialize_to().

◆ y()

template<typename FieldElement>
const FieldElement & Botan::AffineCurvePoint< FieldElement >::y ( ) const
inlineconstexpr

Return the affine y coordinate

Definition at line 976 of file pcurves_impl.h.

976{ return m_y; }

Referenced by AffineCurvePoint(), conditional_assign(), Botan::ProjectiveCurvePoint< FieldElement, Params >::from_affine(), is_identity(), negate(), and serialize_to().

Member Data Documentation

◆ BYTES

template<typename FieldElement>
size_t Botan::AffineCurvePoint< FieldElement >::BYTES = 1 + 2 * FieldElement::BYTES
staticconstexpr

Definition at line 911 of file pcurves_impl.h.


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