Botan 3.5.0
Crypto and TLS for C&
Botan::MontgomeryRep< Params > Class Template Referencefinal

#include <pcurves_impl.h>

Public Types

using Self = MontgomeryRep<Params>
 
typedef Params::W W
 

Static Public Member Functions

static constexpr std::array< W, Nfrom_rep (const std::array< W, N > &z)
 
static constexpr std::array< W, None ()
 
static constexpr std::array< W, Nredc (const std::array< W, 2 *N > &z)
 
static constexpr std::array< W, Nto_rep (const std::array< W, N > &x)
 
static constexpr std::array< W, Nwide_to_rep (const std::array< W, 2 *N > &x)
 

Static Public Attributes

static constexpr size_t N = Params::N
 
static constexpr auto P = Params::P
 
static constexpr auto P_dash = monty_inverse(P[0])
 
static constexpr auto R1 = montygomery_r(P)
 
static constexpr auto R2 = mul_mod(R1, R1, P)
 
static constexpr auto R3 = mul_mod(R1, R2, P)
 

Detailed Description

template<typename Params>
class Botan::MontgomeryRep< Params >

Definition at line 21 of file pcurves_impl.h.

Member Typedef Documentation

◆ Self

template<typename Params >
using Botan::MontgomeryRep< Params >::Self = MontgomeryRep<Params>

Definition at line 23 of file pcurves_impl.h.

◆ W

template<typename Params >
typedef Params::W Botan::MontgomeryRep< Params >::W

Definition at line 27 of file pcurves_impl.h.

Member Function Documentation

◆ from_rep()

template<typename Params >
static constexpr std::array< W, N > Botan::MontgomeryRep< Params >::from_rep ( const std::array< W, N > & z)
inlinestaticconstexpr

Definition at line 60 of file pcurves_impl.h.

60 {
61 std::array<W, 2 * N> ze = {};
62 copy_mem(std::span{ze}.template first<N>(), z);
63 return Self::redc(ze);
64 }
static constexpr std::array< W, N > redc(const std::array< W, 2 *N > &z)
constexpr void copy_mem(T *out, const T *in, size_t n)
Definition mem_ops.h:146

References Botan::copy_mem(), and Botan::MontgomeryRep< Params >::redc().

◆ one()

template<typename Params >
static constexpr std::array< W, N > Botan::MontgomeryRep< Params >::one ( )
inlinestaticconstexpr

Definition at line 37 of file pcurves_impl.h.

37{ return R1; }
static constexpr auto R1

References Botan::MontgomeryRep< Params >::R1.

◆ redc()

template<typename Params >
static constexpr std::array< W, N > Botan::MontgomeryRep< Params >::redc ( const std::array< W, 2 *N > & z)
inlinestaticconstexpr

Definition at line 39 of file pcurves_impl.h.

39 {
40 if constexpr(P_dash == 1) {
41 return monty_redc_pdash1(z, P);
42 } else {
43 return monty_redc(z, P, P_dash);
44 }
45 }
static constexpr auto P_dash
static constexpr auto P

References Botan::MontgomeryRep< Params >::P, and Botan::MontgomeryRep< Params >::P_dash.

Referenced by Botan::MontgomeryRep< Params >::from_rep(), Botan::MontgomeryRep< Params >::to_rep(), and Botan::MontgomeryRep< Params >::wide_to_rep().

◆ to_rep()

template<typename Params >
static constexpr std::array< W, N > Botan::MontgomeryRep< Params >::to_rep ( const std::array< W, N > & x)
inlinestaticconstexpr

Definition at line 47 of file pcurves_impl.h.

47 {
48 std::array<W, 2 * N> z;
49 comba_mul<N>(z.data(), x.data(), R2.data());
50 return Self::redc(z);
51 }
static constexpr auto R2
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(), Botan::MontgomeryRep< Params >::R2, and Botan::MontgomeryRep< Params >::redc().

◆ wide_to_rep()

template<typename Params >
static constexpr std::array< W, N > Botan::MontgomeryRep< Params >::wide_to_rep ( const std::array< W, 2 *N > & x)
inlinestaticconstexpr

Definition at line 53 of file pcurves_impl.h.

53 {
54 auto redc_x = Self::redc(x);
55 std::array<W, 2 * N> z;
56 comba_mul<N>(z.data(), redc_x.data(), R3.data());
57 return Self::redc(z);
58 }
static constexpr auto R3

References Botan::comba_mul(), Botan::MontgomeryRep< Params >::R3, and Botan::MontgomeryRep< Params >::redc().

Member Data Documentation

◆ N

template<typename Params >
size_t Botan::MontgomeryRep< Params >::N = Params::N
staticconstexpr

Definition at line 26 of file pcurves_impl.h.

◆ P

template<typename Params >
auto Botan::MontgomeryRep< Params >::P = Params::P
staticconstexpr

Definition at line 25 of file pcurves_impl.h.

Referenced by Botan::MontgomeryRep< Params >::redc().

◆ P_dash

template<typename Params >
auto Botan::MontgomeryRep< Params >::P_dash = monty_inverse(P[0])
staticconstexpr

Definition at line 31 of file pcurves_impl.h.

Referenced by Botan::MontgomeryRep< Params >::redc().

◆ R1

template<typename Params >
auto Botan::MontgomeryRep< Params >::R1 = montygomery_r(P)
staticconstexpr

Definition at line 33 of file pcurves_impl.h.

Referenced by Botan::MontgomeryRep< Params >::one().

◆ R2

template<typename Params >
auto Botan::MontgomeryRep< Params >::R2 = mul_mod(R1, R1, P)
staticconstexpr

Definition at line 34 of file pcurves_impl.h.

Referenced by Botan::MontgomeryRep< Params >::to_rep().

◆ R3

template<typename Params >
auto Botan::MontgomeryRep< Params >::R3 = mul_mod(R1, R2, P)
staticconstexpr

Definition at line 35 of file pcurves_impl.h.

Referenced by Botan::MontgomeryRep< Params >::wide_to_rep().


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