Botan 3.5.0
Crypto and TLS for C&
Botan::IntMod< Rep > Class Template Referencefinal

#include <pcurves_impl.h>

Public Types

using Self = IntMod<Rep>
 

Public Member Functions

constexpr void conditional_assign (CT::Choice cond, const Self &other)
 
constexpr void ct_poison () const
 
constexpr void ct_unpoison () const
 
constexpr IntMod ()
 
 IntMod (const Self &other)=default
 
 IntMod (Self &&other)=default
 
constexpr Self invert () const
 
constexpr CT::Choice is_even () const
 
constexpr CT::Choice is_nonzero () const
 
constexpr CT::Choice is_one () const
 
constexpr CT::Choice is_square () const
 
constexpr CT::Choice is_zero () const
 
Self mul2 () const
 Return (*this) multiplied by 2.
 
constexpr Self mul3 () const
 Return (*this) multiplied by 3.
 
constexpr Self mul4 () const
 Return (*this) multiplied by 4.
 
constexpr Self mul8 () const
 Return (*this) multiplied by 8.
 
constexpr Self negate () const
 
constexpr CT::Choice operator!= (const Self &other) const
 
constexpr Selfoperator*= (const Self &other)
 
IntModoperator= (const Self &other)=default
 
IntModoperator= (Self &&other)=default
 
constexpr CT::Choice operator== (const Self &other) const
 
constexpr Self pow_vartime (const std::array< W, N > &exp) const
 
constexpr void serialize_to (std::span< uint8_t, Self::BYTES > bytes) const
 
constexpr Self sqrt () const
 
constexpr Self square () const
 
template<size_t L>
std::array< W, L > stash_value () const
 
constexpr std::array< W, Self::N > to_words () const
 

Static Public Member Functions

static consteval Self constant (int8_t x)
 
static constexpr std::optional< Selfdeserialize (std::span< const uint8_t > bytes)
 
static Self from_bits_with_trunc (std::span< const uint8_t > bytes)
 
template<size_t L>
static Self from_stash (const std::array< W, L > &stash)
 
template<size_t L>
static constexpr Self from_wide_bytes (std::span< const uint8_t, L > bytes)
 
static constexpr std::optional< Selffrom_wide_bytes_varlen (std::span< const uint8_t > bytes)
 
static constexpr Self from_word (W x)
 
template<size_t L>
static constexpr Self from_words (std::array< W, L > w)
 
static constexpr Self one ()
 
static Self random (RandomNumberGenerator &rng)
 
static constexpr Self zero ()
 

Static Public Attributes

static constexpr size_t BITS = count_bits(P)
 
static constexpr size_t BYTES = (BITS + 7) / 8
 
static constexpr auto P_MOD_4 = P[0] % 4
 

Friends

constexpr Self operator* (const Self &a, const Self &b)
 
constexpr Self operator+ (const Self &a, const Self &b)
 
constexpr Self operator- (const Self &a, const Self &b)
 

Detailed Description

template<typename Rep>
class Botan::IntMod< Rep >

Definition at line 68 of file pcurves_impl.h.

Member Typedef Documentation

◆ Self

template<typename Rep >
using Botan::IntMod< Rep >::Self = IntMod<Rep>

Definition at line 84 of file pcurves_impl.h.

Constructor & Destructor Documentation

◆ IntMod() [1/3]

template<typename Rep >
Botan::IntMod< Rep >::IntMod ( )
inlineconstexpr

Definition at line 87 of file pcurves_impl.h.

87: m_val({}) {}

◆ IntMod() [2/3]

template<typename Rep >
Botan::IntMod< Rep >::IntMod ( const Self & other)
default

◆ IntMod() [3/3]

template<typename Rep >
Botan::IntMod< Rep >::IntMod ( Self && other)
default

Member Function Documentation

◆ conditional_assign()

template<typename Rep >
void Botan::IntMod< Rep >::conditional_assign ( CT::Choice cond,
const Self & other )
inlineconstexpr

Definition at line 170 of file pcurves_impl.h.

170 {
171 CT::conditional_assign_mem(cond, m_val.data(), other.data(), N);
172 }
constexpr Mask< T > conditional_assign_mem(T cnd, T *sink, const T *src, size_t elems)
Definition ct_utils.h:438

References Botan::CT::conditional_assign_mem().

◆ constant()

template<typename Rep >
static consteval Self Botan::IntMod< Rep >::constant ( int8_t x)
inlinestaticconsteval

Definition at line 394 of file pcurves_impl.h.

394 {
395 std::array<W, 1> v;
396 v[0] = (x >= 0) ? x : -x;
397 auto s = Self::from_words(v);
398 return (x >= 0) ? s : s.negate();
399 }
static constexpr Self from_words(std::array< W, L > w)

References Botan::IntMod< Rep >::from_words().

◆ ct_poison()

template<typename Rep >
void Botan::IntMod< Rep >::ct_poison ( ) const
inlineconstexpr

Definition at line 401 of file pcurves_impl.h.

401{ CT::poison(m_val.data(), m_val.size()); }
constexpr void poison(const T *p, size_t n)
Definition ct_utils.h:46

References Botan::CT::poison().

◆ ct_unpoison()

template<typename Rep >
void Botan::IntMod< Rep >::ct_unpoison ( ) const
inlineconstexpr

Definition at line 403 of file pcurves_impl.h.

403{ CT::unpoison(m_val.data(), m_val.size()); }
constexpr void unpoison(const T *p, size_t n)
Definition ct_utils.h:57

References Botan::CT::unpoison().

◆ deserialize()

template<typename Rep >
static constexpr std::optional< Self > Botan::IntMod< Rep >::deserialize ( std::span< const uint8_t > bytes)
inlinestaticconstexpr

Definition at line 308 of file pcurves_impl.h.

308 {
309 // We could allow either short inputs or longer zero padded
310 // inputs here, however it seems best to avoid non-canonical
311 // representations unless required
312 if(bytes.size() != Self::BYTES) {
313 return {};
314 }
315
316 const auto words = bytes_to_words<W, N, BYTES>(bytes.first<Self::BYTES>());
317
318 if(!bigint_ct_is_lt(words.data(), N, P.data(), N).as_bool()) {
319 return {};
320 }
321
322 return Self::from_words(words);
323 }
static constexpr size_t BYTES
constexpr auto bigint_ct_is_lt(const W x[], size_t x_size, const W y[], size_t y_size, bool lt_or_equal=false) -> CT::Mask< W >
Definition mp_core.h:639

References Botan::bigint_ct_is_lt(), Botan::IntMod< Rep >::BYTES, and Botan::IntMod< Rep >::from_words().

Referenced by Botan::IntMod< Rep >::random().

◆ from_bits_with_trunc()

template<typename Rep >
static Self Botan::IntMod< Rep >::from_bits_with_trunc ( std::span< const uint8_t > bytes)
inlinestatic

Definition at line 328 of file pcurves_impl.h.

328 {
329 const size_t bit_length = bytes.size() * 8;
330
331 if(bit_length <= Self::BITS) {
332 // No shifting required, but might still need to reduce by modulus
333 std::array<uint8_t, 2 * BYTES> padded_bytes = {};
334 copy_mem(std::span{padded_bytes}.last(bytes.size()), bytes);
335 return Self(Rep::wide_to_rep(bytes_to_words<W, 2 * N, 2 * BYTES>(std::span{padded_bytes})));
336 } else {
337 const size_t shift = bit_length - Self::BITS;
338
339 if(shift % 8 == 0) {
340 // Easy case just copy different bytes
341 const size_t new_length = bytes.size() - (shift / 8);
342 return Self::from_bits_with_trunc(bytes.first(new_length));
343 } else {
344 // fixme
345 throw Not_Implemented("Bit shifting for hash to scalar conversion not implemented");
346 }
347 }
348 }
static constexpr size_t BITS
IntMod< Rep > Self
static Self from_bits_with_trunc(std::span< const uint8_t > bytes)
constexpr void copy_mem(T *out, const T *in, size_t n)
Definition mem_ops.h:146

References Botan::IntMod< Rep >::BITS, Botan::copy_mem(), and Botan::IntMod< Rep >::from_bits_with_trunc().

Referenced by Botan::IntMod< Rep >::from_bits_with_trunc().

◆ from_stash()

template<typename Rep >
template<size_t L>
static Self Botan::IntMod< Rep >::from_stash ( const std::array< W, L > & stash)
inlinestatic

Definition at line 298 of file pcurves_impl.h.

298 {
299 static_assert(L >= N);
300 std::array<W, N> val = {};
301 for(size_t i = 0; i != N; ++i) {
302 val[i] = stash[i];
303 }
304 return Self(val);
305 }

◆ from_wide_bytes()

template<typename Rep >
template<size_t L>
static constexpr Self Botan::IntMod< Rep >::from_wide_bytes ( std::span< const uint8_t, L > bytes)
inlinestaticconstexpr

Definition at line 352 of file pcurves_impl.h.

352 {
353 static_assert(8 * L <= 2 * Self::BITS);
354 std::array<uint8_t, 2 * BYTES> padded_bytes = {};
355 copy_mem(std::span{padded_bytes}.template last<L>(), bytes);
356 return Self(Rep::wide_to_rep(bytes_to_words<W, 2 * N, 2 * BYTES>(std::span{padded_bytes})));
357 }

References Botan::IntMod< Rep >::BITS, and Botan::copy_mem().

◆ from_wide_bytes_varlen()

template<typename Rep >
static constexpr std::optional< Self > Botan::IntMod< Rep >::from_wide_bytes_varlen ( std::span< const uint8_t > bytes)
inlinestaticconstexpr

Definition at line 360 of file pcurves_impl.h.

360 {
361 if(8 * bytes.size() > 2 * Self::BITS) {
362 return {};
363 }
364 std::array<uint8_t, 2 * BYTES> padded_bytes = {};
365 copy_mem(std::span{padded_bytes}.last(bytes.size()), bytes);
366 return Self(Rep::wide_to_rep(bytes_to_words<W, 2 * N, 2 * BYTES>(std::span{padded_bytes})));
367 }

References Botan::IntMod< Rep >::BITS, and Botan::copy_mem().

◆ from_word()

template<typename Rep >
static constexpr Self Botan::IntMod< Rep >::from_word ( W x)
inlinestaticconstexpr

Definition at line 98 of file pcurves_impl.h.

98 {
99 std::array<W, 1> v{x};
100 return Self::from_words(v);
101 }

References Botan::IntMod< Rep >::from_words().

◆ from_words()

template<typename Rep >
template<size_t L>
static constexpr Self Botan::IntMod< Rep >::from_words ( std::array< W, L > w)
inlinestaticconstexpr

Definition at line 104 of file pcurves_impl.h.

104 {
105 if constexpr(L == N) {
106 return Self(Rep::to_rep(w));
107 } else {
108 static_assert(L < N);
109 std::array<W, N> ew = {};
110 copy_mem(std::span{ew}.template first<L>(), w);
111 return Self(Rep::to_rep(ew));
112 }
113 }

References Botan::copy_mem().

Referenced by Botan::IntMod< Rep >::constant(), Botan::IntMod< Rep >::deserialize(), and Botan::IntMod< Rep >::from_word().

◆ invert()

template<typename Rep >
Self Botan::IntMod< Rep >::invert ( ) const
inlineconstexpr

Returns the modular inverse, or 0 if no modular inverse exists.

If the modulus is prime the only value that has no modular inverse is 0.

This uses Fermat's little theorem, and so assumes that p is prime

Definition at line 238 of file pcurves_impl.h.

238{ return pow_vartime(Self::P_MINUS_2); }
constexpr Self pow_vartime(const std::array< W, N > &exp) const

References Botan::IntMod< Rep >::pow_vartime().

◆ is_even()

template<typename Rep >
CT::Choice Botan::IntMod< Rep >::is_even ( ) const
inlineconstexpr

Definition at line 121 of file pcurves_impl.h.

121 {
122 auto v = Rep::from_rep(m_val);
123 return CT::Choice::from_int(0x01 ^ (v[0] & 0x01));
124 }
static constexpr Choice from_int(T v)
Definition ct_utils.h:124

References Botan::CT::Choice::from_int().

◆ is_nonzero()

template<typename Rep >
CT::Choice Botan::IntMod< Rep >::is_nonzero ( ) const
inlineconstexpr

Definition at line 117 of file pcurves_impl.h.

117{ return !is_zero(); }
constexpr CT::Choice is_zero() const

References Botan::IntMod< Rep >::is_zero().

◆ is_one()

template<typename Rep >
CT::Choice Botan::IntMod< Rep >::is_one ( ) const
inlineconstexpr

Definition at line 119 of file pcurves_impl.h.

119{ return (*this == Self::one()); }
static constexpr Self one()

References Botan::IntMod< Rep >::one().

Referenced by Botan::IntMod< Rep >::is_square().

◆ is_square()

template<typename Rep >
CT::Choice Botan::IntMod< Rep >::is_square ( ) const
inlineconstexpr

Definition at line 254 of file pcurves_impl.h.

256 {
257 auto z = pow_vartime(Self::P_MINUS_1_OVER_2);
258 const CT::Choice is_one = z.is_one();
259 const CT::Choice is_zero = z.is_zero();
260 return (is_one || is_zero);
261 }
constexpr CT::Choice is_one() const

References Botan::IntMod< Rep >::is_one(), Botan::IntMod< Rep >::is_zero(), and Botan::IntMod< Rep >::pow_vartime().

◆ is_zero()

template<typename Rep >
CT::Choice Botan::IntMod< Rep >::is_zero ( ) const
inlineconstexpr

Definition at line 115 of file pcurves_impl.h.

115{ return CT::all_zeros(m_val.data(), m_val.size()).as_choice(); }
constexpr CT::Mask< T > all_zeros(const T elem[], size_t len)
Definition ct_utils.h:473

References Botan::CT::all_zeros().

Referenced by Botan::IntMod< Rep >::is_nonzero(), and Botan::IntMod< Rep >::is_square().

◆ mul2()

template<typename Rep >
Self Botan::IntMod< Rep >::mul2 ( ) const
inline

Return (*this) multiplied by 2.

Definition at line 138 of file pcurves_impl.h.

138 {
139 std::array<W, N> t = value();
140 W carry = shift_left<1>(t);
141
142 std::array<W, N> r;
143 bigint_monty_maybe_sub<N>(r.data(), carry, t.data(), P.data());
144 return Self(r);
145 }
constexpr W shift_left(std::array< W, N > &x)
Definition mp_core.h:861
constexpr void bigint_monty_maybe_sub(size_t N, W z[], W x0, const W x[], const W p[])
Definition mp_core.h:374
void carry(int64_t &h0, int64_t &h1)

References Botan::bigint_monty_maybe_sub(), Botan::carry(), and Botan::shift_left().

Referenced by Botan::IntMod< Rep >::mul3(), Botan::IntMod< Rep >::mul4(), and Botan::IntMod< Rep >::mul8().

◆ mul3()

template<typename Rep >
Self Botan::IntMod< Rep >::mul3 ( ) const
inlineconstexpr

Return (*this) multiplied by 3.

Definition at line 148 of file pcurves_impl.h.

148{ return mul2() + (*this); }
Self mul2() const
Return (*this) multiplied by 2.

References Botan::IntMod< Rep >::mul2().

◆ mul4()

template<typename Rep >
Self Botan::IntMod< Rep >::mul4 ( ) const
inlineconstexpr

Return (*this) multiplied by 4.

Definition at line 151 of file pcurves_impl.h.

151{ return mul2().mul2(); }

References Botan::IntMod< Rep >::mul2().

◆ mul8()

template<typename Rep >
Self Botan::IntMod< Rep >::mul8 ( ) const
inlineconstexpr

Return (*this) multiplied by 8.

Definition at line 154 of file pcurves_impl.h.

154{ return mul2().mul2().mul2(); }

References Botan::IntMod< Rep >::mul2().

◆ negate()

template<typename Rep >
Self Botan::IntMod< Rep >::negate ( ) const
inlineconstexpr

Definition at line 181 of file pcurves_impl.h.

181 {
182 auto x_is_zero = CT::all_zeros(this->data(), N);
183
184 std::array<W, N> r;
185 bigint_sub3(r.data(), P.data(), N, this->data(), N);
186 x_is_zero.if_set_zero_out(r.data(), N);
187 return Self(r);
188 }
constexpr auto bigint_sub3(W z[], const W x[], size_t x_size, const W y[], size_t y_size) -> W
Definition mp_core.h:341

References Botan::CT::all_zeros(), and Botan::bigint_sub3().

◆ one()

template<typename Rep >
static constexpr Self Botan::IntMod< Rep >::one ( )
inlinestaticconstexpr

Definition at line 96 of file pcurves_impl.h.

96{ return Self(Rep::one()); }

Referenced by Botan::IntMod< Rep >::is_one(), and Botan::IntMod< Rep >::pow_vartime().

◆ operator!=()

template<typename Rep >
CT::Choice Botan::IntMod< Rep >::operator!= ( const Self & other) const
inlineconstexpr

Definition at line 267 of file pcurves_impl.h.

267 {
268 return CT::is_not_equal(this->data(), other.data(), N).as_choice();
269 }
constexpr CT::Mask< T > is_not_equal(const T x[], const T y[], size_t len)
Definition ct_utils.h:511

References Botan::CT::is_not_equal().

◆ operator*=()

template<typename Rep >
Self & Botan::IntMod< Rep >::operator*= ( const Self & other)
inlineconstexpr

Definition at line 162 of file pcurves_impl.h.

162 {
163 std::array<W, 2 * N> z;
164 comba_mul<N>(z.data(), data(), other.data());
165 m_val = Rep::redc(z);
166 return (*this);
167 }
constexpr void comba_mul(W z[2 *N], const W x[N], const W y[N])
Definition mp_core.h:948

References Botan::comba_mul().

◆ operator=() [1/2]

template<typename Rep >
IntMod & Botan::IntMod< Rep >::operator= ( const Self & other)
default

◆ operator=() [2/2]

template<typename Rep >
IntMod & Botan::IntMod< Rep >::operator= ( Self && other)
default

◆ operator==()

template<typename Rep >
CT::Choice Botan::IntMod< Rep >::operator== ( const Self & other) const
inlineconstexpr

Definition at line 263 of file pcurves_impl.h.

263 {
264 return CT::is_equal(this->data(), other.data(), N).as_choice();
265 }
constexpr CT::Mask< T > is_equal(const T x[], const T y[], size_t len)
Definition ct_utils.h:486

References Botan::CT::is_equal().

◆ pow_vartime()

template<typename Rep >
Self Botan::IntMod< Rep >::pow_vartime ( const std::array< W, N > & exp) const
inlineconstexpr

Definition at line 190 of file pcurves_impl.h.

190 {
191 constexpr size_t WindowBits = (Self::BITS <= 256) ? 4 : 5;
192 constexpr size_t WindowElements = (1 << WindowBits) - 1;
193
194 constexpr size_t Windows = (Self::BITS + WindowBits - 1) / WindowBits;
195
196 std::array<Self, WindowElements> tbl;
197
198 tbl[0] = (*this);
199
200 for(size_t i = 1; i != WindowElements; ++i) {
201 if(i % 2 == 1) {
202 tbl[i] = tbl[i / 2].square();
203 } else {
204 tbl[i] = tbl[i - 1] * tbl[0];
205 }
206 }
207
208 auto r = Self::one();
209
210 const size_t w0 = read_window_bits<WindowBits>(std::span{exp}, (Windows - 1) * WindowBits);
211
212 if(w0 > 0) {
213 r = tbl[w0 - 1];
214 }
215
216 for(size_t i = 1; i != Windows; ++i) {
217 for(size_t j = 0; j != WindowBits; ++j) {
218 r = r.square();
219 }
220
221 const size_t w = read_window_bits<WindowBits>(std::span{exp}, (Windows - i - 1) * WindowBits);
222
223 if(w > 0) {
224 r *= tbl[w - 1];
225 }
226 }
227
228 return r;
229 }

References Botan::IntMod< Rep >::BITS, and Botan::IntMod< Rep >::one().

Referenced by Botan::IntMod< Rep >::invert(), Botan::IntMod< Rep >::is_square(), and Botan::IntMod< Rep >::sqrt().

◆ random()

template<typename Rep >
static Self Botan::IntMod< Rep >::random ( RandomNumberGenerator & rng)
inlinestatic

Definition at line 369 of file pcurves_impl.h.

369 {
370 constexpr size_t MAX_ATTEMPTS = 1000;
371
372 std::array<uint8_t, Self::BYTES> buf;
373
374 for(size_t i = 0; i != MAX_ATTEMPTS; ++i) {
375 rng.randomize(buf);
376
377 // Zero off high bits that if set would certainly cause us
378 // to be out of range
379 if constexpr(Self::BITS % 8 != 0) {
380 constexpr uint8_t mask = 0xFF >> (8 - (Self::BITS % 8));
381 buf[0] &= mask;
382 }
383
384 if(auto s = Self::deserialize(buf)) {
385 if(s.value().is_nonzero().as_bool()) {
386 return s.value();
387 }
388 }
389 }
390
391 throw Internal_Error("Failed to generate random Scalar within bounded number of attempts");
392 }
static constexpr std::optional< Self > deserialize(std::span< const uint8_t > bytes)

References Botan::IntMod< Rep >::BITS, Botan::IntMod< Rep >::deserialize(), and Botan::RandomNumberGenerator::randomize().

◆ serialize_to()

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

Definition at line 273 of file pcurves_impl.h.

273 {
274 auto v = Rep::from_rep(m_val);
275 std::reverse(v.begin(), v.end());
276
277 if constexpr(Self::BYTES == N * WordInfo<W>::bytes) {
278 store_be(bytes, v);
279 } else {
280 // Remove leading zero bytes
281 const auto padded_bytes = store_be(v);
282 constexpr size_t extra = N * WordInfo<W>::bytes - Self::BYTES;
283 copy_mem(bytes, std::span{padded_bytes}.template subspan<extra, Self::BYTES>());
284 }
285 }
constexpr auto store_be(ParamTs &&... params)
Definition loadstor.h:707

References Botan::IntMod< Rep >::BYTES, Botan::copy_mem(), and Botan::store_be().

◆ sqrt()

template<typename Rep >
Self Botan::IntMod< Rep >::sqrt ( ) const
inlineconstexpr

Return the modular square root, or zero if no root exists

Current impl assumes p == 3 (mod 4)

Definition at line 245 of file pcurves_impl.h.

247 {
248 auto z = pow_vartime(Self::P_PLUS_1_OVER_4);
249 const CT::Choice correct = (z.square() == *this);
250 z.conditional_assign(!correct, Self::zero());
251 return z;
252 }
static constexpr Self zero()

References Botan::IntMod< Rep >::pow_vartime(), and Botan::IntMod< Rep >::zero().

◆ square()

template<typename Rep >
Self Botan::IntMod< Rep >::square ( ) const
inlineconstexpr

Definition at line 174 of file pcurves_impl.h.

174 {
175 std::array<W, 2 * N> z;
176 comba_sqr<N>(z.data(), this->data());
177 return Self(Rep::redc(z));
178 }
constexpr void comba_sqr(W z[2 *N], const W x[N])
Definition mp_core.h:984

References Botan::comba_sqr().

◆ stash_value()

template<typename Rep >
template<size_t L>
std::array< W, L > Botan::IntMod< Rep >::stash_value ( ) const
inline

Definition at line 288 of file pcurves_impl.h.

288 {
289 static_assert(L >= N);
290 std::array<W, L> stash = {};
291 for(size_t i = 0; i != N; ++i) {
292 stash[i] = m_val[i];
293 }
294 return stash;
295 }

◆ to_words()

template<typename Rep >
std::array< W, Self::N > Botan::IntMod< Rep >::to_words ( ) const
inlineconstexpr

Definition at line 271 of file pcurves_impl.h.

271{ return Rep::from_rep(m_val); }

◆ zero()

template<typename Rep >
static constexpr Self Botan::IntMod< Rep >::zero ( )
inlinestaticconstexpr

Definition at line 94 of file pcurves_impl.h.

94{ return Self(std::array<W, N>{0}); }

Referenced by Botan::IntMod< Rep >::sqrt().

Friends And Related Symbol Documentation

◆ operator*

template<typename Rep >
Self operator* ( const Self & a,
const Self & b )
friend

Definition at line 156 of file pcurves_impl.h.

156 {
157 std::array<W, 2 * N> z;
158 comba_mul<N>(z.data(), a.data(), b.data());
159 return Self(Rep::redc(z));
160 }

◆ operator+

template<typename Rep >
Self operator+ ( const Self & a,
const Self & b )
friend

Definition at line 126 of file pcurves_impl.h.

126 {
127 std::array<W, N> t;
128 W carry = bigint_add<W, N>(t, a.value(), b.value());
129
130 std::array<W, N> r;
131 bigint_monty_maybe_sub<N>(r.data(), carry, t.data(), P.data());
132 return Self(r);
133 }
constexpr auto bigint_add(std::span< W, N > z, std::span< const W, N > x, std::span< const W, N > y) -> W
Definition mp_core.h:257

◆ operator-

template<typename Rep >
Self operator- ( const Self & a,
const Self & b )
friend

Definition at line 135 of file pcurves_impl.h.

135{ return a + b.negate(); }

Member Data Documentation

◆ BITS

◆ BYTES

template<typename Rep >
size_t Botan::IntMod< Rep >::BYTES = (BITS + 7) / 8
staticconstexpr

◆ P_MOD_4

template<typename Rep >
auto Botan::IntMod< Rep >::P_MOD_4 = P[0] % 4
staticconstexpr

Definition at line 82 of file pcurves_impl.h.


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