Botan 3.9.0
Crypto and TLS for C&
Botan::AffineCurvePoint< FieldElement, Params > Class Template Referencefinal

#include <pcurves_impl.h>

Public Types

using Self = AffineCurvePoint<FieldElement, Params>

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, typename Params>
class Botan::AffineCurvePoint< FieldElement, Params >

Affine Curve Point

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

Definition at line 875 of file pcurves_impl.h.

Member Typedef Documentation

◆ Self

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

Definition at line 879 of file pcurves_impl.h.

Constructor & Destructor Documentation

◆ AffineCurvePoint() [1/4]

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

Definition at line 883 of file pcurves_impl.h.

883: 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, typename Params>
Botan::AffineCurvePoint< FieldElement, Params >::AffineCurvePoint ( )
inlineconstexpr

Definition at line 885 of file pcurves_impl.h.

◆ AffineCurvePoint() [3/4]

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

◆ AffineCurvePoint() [4/4]

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

◆ ~AffineCurvePoint()

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

Member Function Documentation

◆ _const_time_poison()

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

Definition at line 951 of file pcurves_impl.h.

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

References Botan::CT::poison_all().

◆ _const_time_unpoison()

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

Definition at line 953 of file pcurves_impl.h.

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

References Botan::CT::unpoison_all().

◆ conditional_assign()

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

Conditional assignment of an affine point

Definition at line 947 of file pcurves_impl.h.

947 {
948 FieldElement::conditional_assign(m_x, m_y, cond, pt.x(), pt.y());
949 }

References x(), and y().

◆ ct_select()

template<typename FieldElement, typename Params>
constexpr auto Botan::AffineCurvePoint< FieldElement, Params >::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 921 of file pcurves_impl.h.

921 {
922 auto result = Self::identity(pts[0]);
923
924 // Intentionally wrapping; set to maximum size_t if idx == 0
925 const size_t idx1 = static_cast<size_t>(idx - 1);
926 for(size_t i = 0; i != pts.size(); ++i) {
927 const auto found = CT::Mask<size_t>::is_equal(idx1, i).as_choice();
929 }
930
931 return result;
932 }
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:470

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

◆ identity() [1/2]

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

Definition at line 887 of file pcurves_impl.h.

AffineCurvePoint< FieldElement, Params > Self

Referenced by ct_select().

◆ identity() [2/2]

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

Definition at line 890 of file pcurves_impl.h.

890 {
892 }

◆ is_identity()

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

Definition at line 894 of file pcurves_impl.h.

894{ 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, typename Params>
Self Botan::AffineCurvePoint< FieldElement, Params >::negate ( ) const
inlineconstexpr

Definition at line 902 of file pcurves_impl.h.

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

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

Referenced by negate().

◆ operator=() [1/2]

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

References AffineCurvePoint().

◆ operator=() [2/2]

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

References AffineCurvePoint().

◆ serialize_to()

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

Serialize the point in uncompressed format

Definition at line 907 of file pcurves_impl.h.

907 {
908 BOTAN_STATE_CHECK(this->is_identity().as_bool() == false);
910 pack.append(0x04);
912 y().serialize_to(pack.next<FieldElement::BYTES>());
913 BOTAN_DEBUG_ASSERT(pack.full());
914 }
#define BOTAN_DEBUG_ASSERT(expr)
Definition assert.h:129
#define BOTAN_STATE_CHECK(expr)
Definition assert.h:49
constexpr CT::Choice is_identity() const
constexpr void serialize_to(std::span< uint8_t, Self::BYTES > bytes) const

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

◆ x()

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

Return the affine x coordinate

Definition at line 937 of file pcurves_impl.h.

937{ return m_x; }

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

◆ y()

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

Return the affine y coordinate

Definition at line 942 of file pcurves_impl.h.

942{ 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, typename Params>
size_t Botan::AffineCurvePoint< FieldElement, Params >::BYTES = 1 + 2 * FieldElement::BYTES
staticconstexpr

Definition at line 877 of file pcurves_impl.h.


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