Botan 3.5.0
Crypto and TLS for C&
Botan::PCurve::PrimeOrderCurveImpl< C > Class Template Referencefinal

#include <pcurves_wrap.h>

Inheritance diagram for Botan::PCurve::PrimeOrderCurveImpl< C >:
Botan::PCurve::PrimeOrderCurve

Classes

class  PrecomputedMul2TableC
 

Public Types

typedef std::shared_ptr< const PrimeOrderCurveCurvePtr
 
typedef std::array< word, StorageWordsStorageUnit
 

Public Member Functions

bool affine_point_is_identity (const AffinePoint &pt) const override
 
Scalar base_point_mul_x_mod_order (const Scalar &scalar, RandomNumberGenerator &rng) const override
 
std::optional< AffinePointdeserialize_point (std::span< const uint8_t > bytes) const override
 
std::optional< Scalardeserialize_scalar (std::span< const uint8_t > bytes) const override
 
size_t field_element_bytes () const override
 
AffinePoint generator () const override
 Return the standard generator.
 
ProjectivePoint hash_to_curve (std::string_view hash, std::span< const uint8_t > input, std::span< const uint8_t > domain_sep, bool random_oracle) const override
 
ProjectivePoint mul (const AffinePoint &pt, const Scalar &scalar, RandomNumberGenerator &rng) const override
 
std::unique_ptr< const PrecomputedMul2Tablemul2_setup (const AffinePoint &x, const AffinePoint &y) const override
 Setup a table for 2-ary multiplication.
 
std::optional< ProjectivePointmul2_vartime (const PrecomputedMul2Table &tableb, const Scalar &s1, const Scalar &s2) const override
 
std::optional< Scalarmul2_vartime_x_mod_order (const PrecomputedMul2Table &tableb, const Scalar &s1, const Scalar &s2) const override
 
ProjectivePoint mul_by_g (const Scalar &scalar, RandomNumberGenerator &rng) const override
 
size_t order_bits () const override
 Return the bit length of the group order.
 
ProjectivePoint point_add (const ProjectivePoint &a, const ProjectivePoint &b) const override
 
ProjectivePoint point_add_mixed (const ProjectivePoint &a, const AffinePoint &b) const override
 
ProjectivePoint point_double (const ProjectivePoint &pt) const override
 
ProjectivePoint point_negate (const ProjectivePoint &pt) const override
 
AffinePoint point_to_affine (const ProjectivePoint &pt) const override
 
ProjectivePoint point_to_projective (const AffinePoint &pt) const override
 
 PrimeOrderCurveImpl ()
 
Scalar random_scalar (RandomNumberGenerator &rng) const override
 
Scalar scalar_add (const Scalar &a, const Scalar &b) const override
 
size_t scalar_bytes () const override
 Return the byte length of the scalar element.
 
bool scalar_equal (const Scalar &a, const Scalar &b) const override
 
Scalar scalar_from_bits_with_trunc (std::span< const uint8_t > bytes) const override
 
Scalar scalar_from_u32 (uint32_t x) const override
 
std::optional< Scalarscalar_from_wide_bytes (std::span< const uint8_t > bytes) const override
 
Scalar scalar_invert (const Scalar &s) const override
 
bool scalar_is_zero (const Scalar &s) const override
 
Scalar scalar_mul (const Scalar &a, const Scalar &b) const override
 
Scalar scalar_negate (const Scalar &s) const override
 
Scalar scalar_one () const override
 
Scalar scalar_square (const Scalar &s) const override
 
Scalar scalar_sub (const Scalar &a, const Scalar &b) const override
 
Scalar scalar_zero () const override
 
void serialize_point (std::span< uint8_t > bytes, const AffinePoint &pt) const override
 
void serialize_point_compressed (std::span< uint8_t > bytes, const AffinePoint &pt) const override
 
void serialize_point_x (std::span< uint8_t > bytes, const AffinePoint &pt) const override
 
void serialize_scalar (std::span< uint8_t > bytes, const Scalar &scalar) const override
 

Static Public Member Functions

static std::shared_ptr< const PrimeOrderCurvefrom_id (PrimeOrderCurveId id)
 
static std::shared_ptr< const PrimeOrderCurvefrom_name (std::string_view name)
 
static std::shared_ptr< const PrimeOrderCurveinstance ()
 

Static Public Attributes

static const size_t MaximumBitLength = 521
 
static const size_t MaximumByteLength = (MaximumBitLength + 7) / 8
 
static const size_t StorageWords = (MaximumByteLength + sizeof(word) - 1) / sizeof(word)
 Number of words used to store MaximumByteLength.
 

Detailed Description

template<typename C>
class Botan::PCurve::PrimeOrderCurveImpl< C >

Definition at line 16 of file pcurves_wrap.h.

Member Typedef Documentation

◆ CurvePtr

typedef std::shared_ptr<const PrimeOrderCurve> Botan::PCurve::PrimeOrderCurve::CurvePtr
inherited

Definition at line 55 of file pcurves.h.

◆ StorageUnit

typedef std::array<word, StorageWords> Botan::PCurve::PrimeOrderCurve::StorageUnit
inherited

Definition at line 54 of file pcurves.h.

Constructor & Destructor Documentation

◆ PrimeOrderCurveImpl()

template<typename C >
Botan::PCurve::PrimeOrderCurveImpl< C >::PrimeOrderCurveImpl ( )
inline

Definition at line 215 of file pcurves_wrap.h.

215: m_mul_by_g(C::G) {}

Member Function Documentation

◆ affine_point_is_identity()

template<typename C >
bool Botan::PCurve::PrimeOrderCurveImpl< C >::affine_point_is_identity ( const AffinePoint & pt) const
inlineoverridevirtual

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 117 of file pcurves_wrap.h.

117 {
118 return from_stash(pt).is_identity().as_bool();
119 }

◆ base_point_mul_x_mod_order()

template<typename C >
Scalar Botan::PCurve::PrimeOrderCurveImpl< C >::base_point_mul_x_mod_order ( const Scalar & scalar,
RandomNumberGenerator & rng ) const
inlineoverridevirtual

Base point multiplication, returning only the x coordinate modulo the group order

Multiply by the standard generator point g, then extract the x coordinate as an integer, then reduce the x coordinate modulo the group order

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 88 of file pcurves_wrap.h.

88 {
89 auto pt = m_mul_by_g.mul(from_stash(scalar), rng);
90 std::array<uint8_t, C::FieldElement::BYTES> x_bytes;
91 pt.to_affine().x().serialize_to(std::span{x_bytes});
92 return stash(C::Scalar::from_wide_bytes(std::span<const uint8_t, C::FieldElement::BYTES>{x_bytes}));
93 }
ProjectivePoint mul(const Scalar &s, RandomNumberGenerator &rng) const

References Botan::PrecomputedBaseMulTable< C, W >::mul(), and Botan::PCurve::PrimeOrderCurve::ProjectivePoint::to_affine().

◆ deserialize_point()

template<typename C >
std::optional< AffinePoint > Botan::PCurve::PrimeOrderCurveImpl< C >::deserialize_point ( std::span< const uint8_t > bytes) const
inlineoverridevirtual

Deserialize a point

Both compressed and uncompressed encodings are accepted

Note that the deprecated "hybrid" encoding is not supported here

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 164 of file pcurves_wrap.h.

164 {
165 if(auto pt = C::AffinePoint::deserialize(bytes)) {
166 return stash(*pt);
167 } else {
168 return {};
169 }
170 }

◆ deserialize_scalar()

template<typename C >
std::optional< Scalar > Botan::PCurve::PrimeOrderCurveImpl< C >::deserialize_scalar ( std::span< const uint8_t > bytes) const
inlineoverridevirtual

Deserialize a scalar

This function requires the input length be exactly scalar_bytes long; it does not accept inputs that are shorter, or with excess leading zero padding bytes.

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 142 of file pcurves_wrap.h.

142 {
143 if(auto scalar = C::Scalar::deserialize(bytes)) {
144 if(!scalar->is_zero().as_bool()) {
145 return stash(*scalar);
146 }
147 }
148
149 return {};
150 }

◆ field_element_bytes()

template<typename C >
size_t Botan::PCurve::PrimeOrderCurveImpl< C >::field_element_bytes ( ) const
inlineoverridevirtual

Return the byte length of a field element

Each point consists of two field elements

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 38 of file pcurves_wrap.h.

38{ return C::FieldElement::BYTES; }

◆ from_id()

std::shared_ptr< const PrimeOrderCurve > Botan::PCurve::PrimeOrderCurve::from_id ( PrimeOrderCurveId id)
staticinherited

Definition at line 80 of file pcurves.cpp.

80 {
81 switch(id.code()) {
100 }
101 return {};
102}
static std::shared_ptr< const PrimeOrderCurve > secp521r1()
Definition pcurves.cpp:33
static std::shared_ptr< const PrimeOrderCurve > secp256k1()
Definition pcurves.cpp:40
static std::shared_ptr< const PrimeOrderCurve > secp384r1()
Definition pcurves.cpp:26
static std::shared_ptr< const PrimeOrderCurve > brainpool384r1()
Definition pcurves.cpp:54
static std::shared_ptr< const PrimeOrderCurve > brainpool512r1()
Definition pcurves.cpp:61
static std::shared_ptr< const PrimeOrderCurve > frp256v1()
Definition pcurves.cpp:68
static std::shared_ptr< const PrimeOrderCurve > brainpool256r1()
Definition pcurves.cpp:47
static std::shared_ptr< const PrimeOrderCurve > sm2p256v1()
Definition pcurves.cpp:75
static std::shared_ptr< const PrimeOrderCurve > secp256r1()
Definition pcurves.cpp:19

References Botan::PCurve::PCurveInstance::brainpool256r1(), Botan::PCurve::PrimeOrderCurveId::brainpool256r1, Botan::PCurve::PCurveInstance::brainpool384r1(), Botan::PCurve::PrimeOrderCurveId::brainpool384r1, Botan::PCurve::PCurveInstance::brainpool512r1(), Botan::PCurve::PrimeOrderCurveId::brainpool512r1, Botan::PCurve::PCurveInstance::frp256v1(), Botan::PCurve::PrimeOrderCurveId::frp256v1, Botan::PCurve::PCurveInstance::secp256k1(), Botan::PCurve::PrimeOrderCurveId::secp256k1, Botan::PCurve::PCurveInstance::secp256r1(), Botan::PCurve::PrimeOrderCurveId::secp256r1, Botan::PCurve::PCurveInstance::secp384r1(), Botan::PCurve::PrimeOrderCurveId::secp384r1, Botan::PCurve::PCurveInstance::secp521r1(), Botan::PCurve::PrimeOrderCurveId::secp521r1, Botan::PCurve::PCurveInstance::sm2p256v1(), and Botan::PCurve::PrimeOrderCurveId::sm2p256v1.

Referenced by Botan::hash_to_curve_sswu().

◆ from_name()

static std::shared_ptr< const PrimeOrderCurve > Botan::PCurve::PrimeOrderCurve::from_name ( std::string_view name)
inlinestaticinherited

Definition at line 44 of file pcurves.h.

44 {
46 return PrimeOrderCurve::from_id(id.value());
47 } else {
48 return {};
49 }
50 }
static std::optional< PrimeOrderCurveId > from_string(std::string_view name)
Map a string to a curve identifier.
Definition pcurves.cpp:144
static std::shared_ptr< const PrimeOrderCurve > from_id(PrimeOrderCurveId id)
Definition pcurves.cpp:80
std::string name

References name.

◆ generator()

template<typename C >
AffinePoint Botan::PCurve::PrimeOrderCurveImpl< C >::generator ( ) const
inlineoverridevirtual

Return the standard generator.

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 95 of file pcurves_wrap.h.

95{ return stash(C::G); }

◆ hash_to_curve()

template<typename C >
ProjectivePoint Botan::PCurve::PrimeOrderCurveImpl< C >::hash_to_curve ( std::string_view hash,
std::span< const uint8_t > input,
std::span< const uint8_t > domain_sep,
bool random_oracle ) const
inlineoverridevirtual

RFC 9380 hash to curve

This is currently only supported for a few specific curves

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 172 of file pcurves_wrap.h.

175 {
176 if constexpr(C::ValidForSswuHash) {
177 return stash(hash_to_curve_sswu<C>(hash, random_oracle, input, domain_sep));
178 } else {
179 throw Not_Implemented("Hash to curve is not implemented for this curve");
180 }
181 }
auto hash_to_curve_sswu(std::string_view hash, bool random_oracle, std::span< const uint8_t > pw, std::span< const uint8_t > dst) -> typename C::ProjectivePoint

References Botan::hash_to_curve_sswu().

◆ instance()

template<typename C >
static std::shared_ptr< const PrimeOrderCurve > Botan::PCurve::PrimeOrderCurveImpl< C >::instance ( )
inlinestatic

Definition at line 217 of file pcurves_wrap.h.

217 {
218 static auto g_curve = std::make_shared<const PrimeOrderCurveImpl<C>>();
219 return g_curve;
220 }

◆ mul()

template<typename C >
ProjectivePoint Botan::PCurve::PrimeOrderCurveImpl< C >::mul ( const AffinePoint & pt,
const Scalar & scalar,
RandomNumberGenerator & rng ) const
inlineoverridevirtual

Generic point multiplication

Multiply an arbitrary point by a scalar

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 44 of file pcurves_wrap.h.

44 {
45 auto tbl = WindowedMulTable<C, 4>(from_stash(pt));
46 return stash(tbl.mul(from_stash(scalar), rng));
47 }

◆ mul2_setup()

template<typename C >
std::unique_ptr< const PrecomputedMul2Table > Botan::PCurve::PrimeOrderCurveImpl< C >::mul2_setup ( const AffinePoint & pt1,
const AffinePoint & pt2 ) const
inlineoverridevirtual

Setup a table for 2-ary multiplication.

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 49 of file pcurves_wrap.h.

50 {
51 return std::make_unique<PrecomputedMul2TableC>(from_stash(x), from_stash(y));
52 }

◆ mul2_vartime()

template<typename C >
std::optional< ProjectivePoint > Botan::PCurve::PrimeOrderCurveImpl< C >::mul2_vartime ( const PrecomputedMul2Table & table,
const Scalar & s1,
const Scalar & s2 ) const
inlineoverridevirtual

Perform 2-ary multiplication (variable time)

Compute s1*pt1 + s2*pt2 in variable time

Returns nullopt if the produced point is the point at infinity

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 54 of file pcurves_wrap.h.

56 {
57 try {
58 const auto& table = dynamic_cast<const PrecomputedMul2TableC&>(tableb);
59 auto pt = table.table().mul2_vartime(from_stash(s1), from_stash(s2));
60 if(pt.is_identity().as_bool()) {
61 return {};
62 } else {
63 return stash(pt);
64 }
65 } catch(std::bad_cast&) {
66 throw Invalid_Argument("Curve mismatch");
67 }
68 }

References Botan::WindowedMul2Table< C, W >::mul2_vartime(), and Botan::PCurve::PrimeOrderCurveImpl< C >::PrecomputedMul2TableC::table().

◆ mul2_vartime_x_mod_order()

template<typename C >
std::optional< Scalar > Botan::PCurve::PrimeOrderCurveImpl< C >::mul2_vartime_x_mod_order ( const PrecomputedMul2Table & table,
const Scalar & s1,
const Scalar & s2 ) const
inlineoverridevirtual

Perform 2-ary multiplication (variable time), reducing x modulo order

Compute s1*pt1 + s2*pt2 in variable time, then extract the x coordinate of the result, and reduce x modulo the group order

Returns nullopt if the produced point is the point at infinity

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 70 of file pcurves_wrap.h.

72 {
73 try {
74 const auto& table = dynamic_cast<const PrecomputedMul2TableC&>(tableb);
75 const auto pt = table.table().mul2_vartime(from_stash(s1), from_stash(s2));
76 // Variable time here, so the early return is fine
77 if(pt.is_identity().as_bool()) {
78 return {};
79 }
80 std::array<uint8_t, C::FieldElement::BYTES> x_bytes;
81 pt.to_affine().x().serialize_to(std::span{x_bytes});
82 return stash(C::Scalar::from_wide_bytes(std::span<const uint8_t, C::FieldElement::BYTES>{x_bytes}));
83 } catch(std::bad_cast&) {
84 throw Invalid_Argument("Curve mismatch");
85 }
86 }

References Botan::WindowedMul2Table< C, W >::mul2_vartime(), Botan::PCurve::PrimeOrderCurveImpl< C >::PrecomputedMul2TableC::table(), and Botan::PCurve::PrimeOrderCurve::ProjectivePoint::to_affine().

◆ mul_by_g()

template<typename C >
ProjectivePoint Botan::PCurve::PrimeOrderCurveImpl< C >::mul_by_g ( const Scalar & scalar,
RandomNumberGenerator & rng ) const
inlineoverridevirtual

Base point multiplication

Multiply by the standard generator point g

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 40 of file pcurves_wrap.h.

40 {
41 return stash(m_mul_by_g.mul(from_stash(scalar), rng));
42 }

References Botan::PrecomputedBaseMulTable< C, W >::mul().

◆ order_bits()

template<typename C >
size_t Botan::PCurve::PrimeOrderCurveImpl< C >::order_bits ( ) const
inlineoverridevirtual

Return the bit length of the group order.

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 34 of file pcurves_wrap.h.

34{ return C::OrderBits; }

◆ point_add()

template<typename C >
ProjectivePoint Botan::PCurve::PrimeOrderCurveImpl< C >::point_add ( const ProjectivePoint & a,
const ProjectivePoint & b ) const
inlineoverridevirtual

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 107 of file pcurves_wrap.h.

107 {
108 return stash(from_stash(a) + from_stash(b));
109 }

◆ point_add_mixed()

template<typename C >
ProjectivePoint Botan::PCurve::PrimeOrderCurveImpl< C >::point_add_mixed ( const ProjectivePoint & a,
const AffinePoint & b ) const
inlineoverridevirtual

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 111 of file pcurves_wrap.h.

111 {
112 return stash(from_stash(a) + from_stash(b));
113 }

◆ point_double()

template<typename C >
ProjectivePoint Botan::PCurve::PrimeOrderCurveImpl< C >::point_double ( const ProjectivePoint & pt) const
inlineoverridevirtual

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 105 of file pcurves_wrap.h.

105{ return stash(from_stash(pt).dbl()); }

◆ point_negate()

template<typename C >
ProjectivePoint Botan::PCurve::PrimeOrderCurveImpl< C >::point_negate ( const ProjectivePoint & pt) const
inlineoverridevirtual

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 115 of file pcurves_wrap.h.

115{ return stash(from_stash(pt).negate()); }

◆ point_to_affine()

template<typename C >
AffinePoint Botan::PCurve::PrimeOrderCurveImpl< C >::point_to_affine ( const ProjectivePoint & pt) const
inlineoverridevirtual

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 97 of file pcurves_wrap.h.

97 {
98 return stash(from_stash(pt).to_affine());
99 }

◆ point_to_projective()

template<typename C >
ProjectivePoint Botan::PCurve::PrimeOrderCurveImpl< C >::point_to_projective ( const AffinePoint & pt) const
inlineoverridevirtual

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 101 of file pcurves_wrap.h.

101 {
102 return stash(C::ProjectivePoint::from_affine(from_stash(pt)));
103 }

◆ random_scalar()

template<typename C >
Scalar Botan::PCurve::PrimeOrderCurveImpl< C >::random_scalar ( RandomNumberGenerator & rng) const
inlineoverridevirtual

Return a new random scalar

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 213 of file pcurves_wrap.h.

213{ return stash(C::Scalar::random(rng)); }

◆ scalar_add()

template<typename C >
Scalar Botan::PCurve::PrimeOrderCurveImpl< C >::scalar_add ( const Scalar & a,
const Scalar & b ) const
inlineoverridevirtual

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 183 of file pcurves_wrap.h.

183 {
184 return stash(from_stash(a) + from_stash(b));
185 }

◆ scalar_bytes()

template<typename C >
size_t Botan::PCurve::PrimeOrderCurveImpl< C >::scalar_bytes ( ) const
inlineoverridevirtual

Return the byte length of the scalar element.

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 36 of file pcurves_wrap.h.

36{ return C::Scalar::BYTES; }

◆ scalar_equal()

template<typename C >
bool Botan::PCurve::PrimeOrderCurveImpl< C >::scalar_equal ( const Scalar & a,
const Scalar & b ) const
inlineoverridevirtual

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 203 of file pcurves_wrap.h.

203 {
204 return (from_stash(a) == from_stash(b)).as_bool();
205 }

◆ scalar_from_bits_with_trunc()

template<typename C >
Scalar Botan::PCurve::PrimeOrderCurveImpl< C >::scalar_from_bits_with_trunc ( std::span< const uint8_t > bytes) const
inlineoverridevirtual

Deserialize a scalar using ECDSA truncation rules

ECDSA and other signature schemes use a specific rule for converting a hash output into a scalar.

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 152 of file pcurves_wrap.h.

152 {
153 return stash(C::Scalar::from_bits_with_trunc(bytes));
154 }

◆ scalar_from_u32()

template<typename C >
Scalar Botan::PCurve::PrimeOrderCurveImpl< C >::scalar_from_u32 ( uint32_t x) const
inlineoverridevirtual

Return a small scalar

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 211 of file pcurves_wrap.h.

211{ return stash(C::Scalar::from_word(x)); }

◆ scalar_from_wide_bytes()

template<typename C >
std::optional< Scalar > Botan::PCurve::PrimeOrderCurveImpl< C >::scalar_from_wide_bytes ( std::span< const uint8_t > bytes) const
inlineoverridevirtual

Reduce an integer modulo the group order

The input can be at most twice the bit length of the order; if larger than this nullopt is returned

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 156 of file pcurves_wrap.h.

156 {
157 if(auto s = C::Scalar::from_wide_bytes_varlen(bytes)) {
158 return stash(*s);
159 } else {
160 return {};
161 }
162 }

◆ scalar_invert()

template<typename C >
Scalar Botan::PCurve::PrimeOrderCurveImpl< C >::scalar_invert ( const Scalar & s) const
inlineoverridevirtual

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 197 of file pcurves_wrap.h.

197{ return stash(from_stash(s).invert()); }

◆ scalar_is_zero()

template<typename C >
bool Botan::PCurve::PrimeOrderCurveImpl< C >::scalar_is_zero ( const Scalar & s) const
inlineoverridevirtual

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 201 of file pcurves_wrap.h.

201{ return from_stash(s).is_zero().as_bool(); }

◆ scalar_mul()

template<typename C >
Scalar Botan::PCurve::PrimeOrderCurveImpl< C >::scalar_mul ( const Scalar & a,
const Scalar & b ) const
inlineoverridevirtual

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 191 of file pcurves_wrap.h.

191 {
192 return stash(from_stash(a) * from_stash(b));
193 }

◆ scalar_negate()

template<typename C >
Scalar Botan::PCurve::PrimeOrderCurveImpl< C >::scalar_negate ( const Scalar & s) const
inlineoverridevirtual

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 199 of file pcurves_wrap.h.

199{ return stash(from_stash(s).negate()); }

◆ scalar_one()

template<typename C >
Scalar Botan::PCurve::PrimeOrderCurveImpl< C >::scalar_one ( ) const
inlineoverridevirtual

Return the scalar one

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 209 of file pcurves_wrap.h.

209{ return stash(C::Scalar::one()); }

◆ scalar_square()

template<typename C >
Scalar Botan::PCurve::PrimeOrderCurveImpl< C >::scalar_square ( const Scalar & s) const
inlineoverridevirtual

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 195 of file pcurves_wrap.h.

195{ return stash(from_stash(s).square()); }
BigInt square(const BigInt &x)
Definition numthry.cpp:157

References Botan::square().

◆ scalar_sub()

template<typename C >
Scalar Botan::PCurve::PrimeOrderCurveImpl< C >::scalar_sub ( const Scalar & a,
const Scalar & b ) const
inlineoverridevirtual

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 187 of file pcurves_wrap.h.

187 {
188 return stash(from_stash(a) - from_stash(b));
189 }

◆ scalar_zero()

template<typename C >
Scalar Botan::PCurve::PrimeOrderCurveImpl< C >::scalar_zero ( ) const
inlineoverridevirtual

Return the scalar zero

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 207 of file pcurves_wrap.h.

207{ return stash(C::Scalar::zero()); }

◆ serialize_point()

template<typename C >
void Botan::PCurve::PrimeOrderCurveImpl< C >::serialize_point ( std::span< uint8_t > bytes,
const AffinePoint & pt ) const
inlineoverridevirtual

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 121 of file pcurves_wrap.h.

121 {
122 BOTAN_ARG_CHECK(bytes.size() == C::AffinePoint::BYTES, "Invalid length for serialize_point");
123 from_stash(pt).serialize_to(bytes.subspan<0, C::AffinePoint::BYTES>());
124 }
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:29

References BOTAN_ARG_CHECK.

◆ serialize_point_compressed()

template<typename C >
void Botan::PCurve::PrimeOrderCurveImpl< C >::serialize_point_compressed ( std::span< uint8_t > bytes,
const AffinePoint & pt ) const
inlineoverridevirtual

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 126 of file pcurves_wrap.h.

126 {
127 BOTAN_ARG_CHECK(bytes.size() == C::AffinePoint::COMPRESSED_BYTES,
128 "Invalid length for serialize_point_compressed");
129 from_stash(pt).serialize_compressed_to(bytes.subspan<0, C::AffinePoint::COMPRESSED_BYTES>());
130 }

References BOTAN_ARG_CHECK.

◆ serialize_point_x()

template<typename C >
void Botan::PCurve::PrimeOrderCurveImpl< C >::serialize_point_x ( std::span< uint8_t > bytes,
const AffinePoint & pt ) const
inlineoverridevirtual

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 132 of file pcurves_wrap.h.

132 {
133 BOTAN_ARG_CHECK(bytes.size() == C::FieldElement::BYTES, "Invalid length for serialize_point_x");
134 from_stash(pt).x().serialize_to(bytes.subspan<0, C::FieldElement::BYTES>());
135 }

References BOTAN_ARG_CHECK.

◆ serialize_scalar()

template<typename C >
void Botan::PCurve::PrimeOrderCurveImpl< C >::serialize_scalar ( std::span< uint8_t > bytes,
const Scalar & scalar ) const
inlineoverridevirtual

Implements Botan::PCurve::PrimeOrderCurve.

Definition at line 137 of file pcurves_wrap.h.

137 {
138 BOTAN_ARG_CHECK(bytes.size() == C::Scalar::BYTES, "Invalid length to serialize_scalar");
139 return from_stash(scalar).serialize_to(bytes.subspan<0, C::Scalar::BYTES>());
140 }

References BOTAN_ARG_CHECK.

Member Data Documentation

◆ MaximumBitLength

const size_t Botan::PCurve::PrimeOrderCurve::MaximumBitLength = 521
staticinherited

Somewhat arbitrary maximum size for a field or scalar

Sized to fit at least P-521

Definition at line 37 of file pcurves.h.

◆ MaximumByteLength

const size_t Botan::PCurve::PrimeOrderCurve::MaximumByteLength = (MaximumBitLength + 7) / 8
staticinherited

Definition at line 39 of file pcurves.h.

◆ StorageWords

const size_t Botan::PCurve::PrimeOrderCurve::StorageWords = (MaximumByteLength + sizeof(word) - 1) / sizeof(word)
staticinherited

Number of words used to store MaximumByteLength.

Definition at line 42 of file pcurves.h.


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