Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
bn::EcT< T > Class Template Reference

#include <bn.h>

Public Member Functions

 EcT ()
 
 EcT (const T &x, const T &y, bool verify=true)
 
 EcT (const T &x, const T &y, const T &z, bool verify=true)
 
void normalize () const
 
bool isValid () const
 
void set (const T &x, const T &y, bool verify=true)
 
void set (const T &x, const T &y, const T &z, bool verify=true)
 
void clear ()
 
template<class N >
EcToperator*= (const N &y)
 
template<class N >
EcT operator* (const N &y) const
 
bool operator== (const EcT &rhs) const
 
bool operator!= (const EcT &rhs) const
 
bool isZero () const
 
EcToperator+= (const EcT &rhs)
 
EcToperator-= (const EcT &rhs)
 
bool isValid () const
 
bool isValid () const
 

Static Public Member Functions

static void dbl (EcT &R, const EcT &P)
 
static void add (EcT &R, const EcT &P, const EcT &Q)
 
static void sub (EcT &R, const EcT &P, const EcT &Q)
 
static void neg (EcT &R, const EcT &P)
 
template<class N >
static void mul (EcT &R, const EcT &P, const N &y)
 

Public Attributes

T p [3]
 

Friends

std::ostream & operator<< (std::ostream &os, const EcT &self)
 
std::istream & operator>> (std::istream &is, EcT &self)
 
EcT operator+ (const EcT &a, const EcT &b)
 
EcT operator- (const EcT &a, const EcT &b)
 

Detailed Description

template<class T>
class bn::EcT< T >

Definition at line 2815 of file bn.h.

Constructor & Destructor Documentation

◆ EcT() [1/3]

template<class T >
bn::EcT< T >::EcT ( )
inline

Definition at line 2818 of file bn.h.

2818{}

◆ EcT() [2/3]

template<class T >
bn::EcT< T >::EcT ( const T & x,
const T & y,
bool verify = true )
inline

Definition at line 2819 of file bn.h.

2820 {
2821 set(x, y, verify);
2822 }
void verify(const char *msg, const T &a, const S &b)
Definition minitest.cpp:13
bool set
Here is the call graph for this function:

◆ EcT() [3/3]

template<class T >
bn::EcT< T >::EcT ( const T & x,
const T & y,
const T & z,
bool verify = true )
inline

Definition at line 2823 of file bn.h.

2824 {
2825 set(x, y, z, verify);
2826 }
Here is the call graph for this function:

Member Function Documentation

◆ add()

template<class T >
static void bn::EcT< T >::add ( EcT< T > & R,
const EcT< T > & P,
const EcT< T > & Q )
inlinestatic

Definition at line 2871 of file bn.h.

2872 {
2873 ecop::ECAdd(R.p, P.p, Q.p);
2874 }
#define P
Definition dtoa.c:437
void ECAdd(FF *out, const FF *a, const FF *b)
Definition bn.h:2526
#define R
Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear()

template<class T >
void bn::EcT< T >::clear ( )
inline

Definition at line 2860 of file bn.h.

2861 {
2862 p[0].clear();
2863 p[1].clear();
2864 p[2].clear();
2865 }
T p[3]
Definition bn.h:2817
Here is the caller graph for this function:

◆ dbl()

template<class T >
static void bn::EcT< T >::dbl ( EcT< T > & R,
const EcT< T > & P )
inlinestatic

Definition at line 2867 of file bn.h.

2868 {
2869 ecop::ECDouble(R.p, P.p);
2870 }
void ECDouble(FF *out, const FF *in)
Definition bn.h:2497
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isValid() [1/3]

template<class T >
bool bn::EcT< T >::isValid ( ) const
Here is the caller graph for this function:

◆ isValid() [2/3]

bool bn::EcT< Fp2 >::isValid ( ) const
inline

Definition at line 2978 of file bn.h.

2979{
2980 return ecop::isOnTwistECJac3(p);
2981}
bool isOnTwistECJac3(const Fp2T< Fp > *P)
Definition bn.h:2409
Here is the call graph for this function:

◆ isValid() [3/3]

bool bn::EcT< Fp >::isValid ( ) const
inline

Definition at line 2984 of file bn.h.

2985{
2986 return ecop::isOnECJac3(p);
2987}
bool isOnECJac3(const Fp *P)
Definition bn.h:2361
Here is the call graph for this function:

◆ isZero()

template<class T >
bool bn::EcT< T >::isZero ( ) const
inline

Definition at line 2911 of file bn.h.

2912 {
2913 return p[2].isZero();
2914 }
Here is the caller graph for this function:

◆ mul()

template<class T >
template<class N >
static void bn::EcT< T >::mul ( EcT< T > & R,
const EcT< T > & P,
const N & y )
inlinestatic

Definition at line 2888 of file bn.h.

2889 {
2890 ecop::ScalarMult(R.p, P.p, y);
2891 }
void ScalarMult(FF *out, const FF *in, const INT &m)
Definition bn.h:2590
Here is the call graph for this function:
Here is the caller graph for this function:

◆ neg()

template<class T >
static void bn::EcT< T >::neg ( EcT< T > & R,
const EcT< T > & P )
inlinestatic

Definition at line 2881 of file bn.h.

2882 {
2883 R.p[0] = P.p[0];
2884 T::neg(R.p[1], P.p[1]);
2885 R.p[2] = P.p[2];
2886 }
Here is the caller graph for this function:

◆ normalize()

template<class T >
void bn::EcT< T >::normalize ( ) const
inline

Definition at line 2827 of file bn.h.

2828 {
2829 if (isZero() || p[2] == 1) return;
2830 T r;
2831 r = p[2];
2832 r.inverse();
2833 T::square(p[2], r);
2834 p[0] *= p[2];
2835 r *= p[2];
2836 p[1] *= r;
2837 p[2] = 1;
2838 }
const mie::Vuint & r
Definition bn.cpp:28
bool isZero() const
Definition bn.h:2911
#define T(meth, val, expected)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator!=()

template<class T >
bool bn::EcT< T >::operator!= ( const EcT< T > & rhs) const
inline

Definition at line 2907 of file bn.h.

2908 {
2909 return !operator==(rhs);
2910 }
bool operator==(const EcT &rhs) const
Definition bn.h:2896
Here is the call graph for this function:

◆ operator*()

template<class T >
template<class N >
EcT bn::EcT< T >::operator* ( const N & y) const
inline

Definition at line 2895 of file bn.h.

2895{ EcT c; mul(c, *this, y); return c; }
EcT()
Definition bn.h:2818
static void mul(EcT &R, const EcT &P, const N &y)
Definition bn.h:2888
Here is the call graph for this function:

◆ operator*=()

template<class T >
template<class N >
EcT & bn::EcT< T >::operator*= ( const N & y)
inline

Definition at line 2893 of file bn.h.

2893{ mul(*this, *this, y); return *this; }
Here is the call graph for this function:

◆ operator+=()

template<class T >
EcT & bn::EcT< T >::operator+= ( const EcT< T > & rhs)
inline

Definition at line 2942 of file bn.h.

2942{ add(*this, *this, rhs); return *this; }
static void add(EcT &R, const EcT &P, const EcT &Q)
Definition bn.h:2871
Here is the call graph for this function:

◆ operator-=()

template<class T >
EcT & bn::EcT< T >::operator-= ( const EcT< T > & rhs)
inline

Definition at line 2943 of file bn.h.

2943{ sub(*this, *this, rhs); return *this; }
static void sub(EcT &R, const EcT &P, const EcT &Q)
Definition bn.h:2875
Here is the call graph for this function:

◆ operator==()

template<class T >
bool bn::EcT< T >::operator== ( const EcT< T > & rhs) const
inline

Definition at line 2896 of file bn.h.

2897 {
2898 normalize();
2899 rhs.normalize();
2900 if (isZero()) {
2901 if (rhs.isZero()) return true;
2902 return false;
2903 }
2904 if (rhs.isZero()) return false;
2905 return p[0] == rhs.p[0] && p[1] == rhs.p[1];
2906 }
void normalize() const
Definition bn.h:2827
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set() [1/2]

template<class T >
void bn::EcT< T >::set ( const T & x,
const T & y,
bool verify = true )
inline

Definition at line 2842 of file bn.h.

2843 {
2844 p[0] = x;
2845 p[1] = y;
2846 p[2] = 1;
2847 if (verify && !isValid()) {
2848 throw std::runtime_error("set(x, y) : bad point");
2849 }
2850 }
bool isValid() const
uint64_t y
Definition sha3.cpp:34
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set() [2/2]

template<class T >
void bn::EcT< T >::set ( const T & x,
const T & y,
const T & z,
bool verify = true )
inline

Definition at line 2851 of file bn.h.

2852 {
2853 p[0] = x;
2854 p[1] = y;
2855 p[2] = z;
2856 if (verify && !isValid()) {
2857 throw std::runtime_error("set(x, y, z) : bad point");
2858 }
2859 }
Here is the call graph for this function:

◆ sub()

template<class T >
static void bn::EcT< T >::sub ( EcT< T > & R,
const EcT< T > & P,
const EcT< T > & Q )
inlinestatic

Definition at line 2875 of file bn.h.

2876 {
2877 EcT negQ;
2878 neg(negQ, Q);
2879 add(R, P, negQ);
2880 }
static void neg(EcT &R, const EcT &P)
Definition bn.h:2881
Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ operator+

template<class T >
EcT operator+ ( const EcT< T > & a,
const EcT< T > & b )
friend

Definition at line 2944 of file bn.h.

2944{ EcT c; EcT::add(c, a, b); return c; }
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181

◆ operator-

template<class T >
EcT operator- ( const EcT< T > & a,
const EcT< T > & b )
friend

Definition at line 2945 of file bn.h.

2945{ EcT c; EcT::sub(c, a, b); return c; }

◆ operator<<

template<class T >
std::ostream & operator<< ( std::ostream & os,
const EcT< T > & self )
friend

Definition at line 2915 of file bn.h.

2916 {
2917 if (self.isZero()) {
2918 return os << '0';
2919 } else {
2920 self.normalize();
2921 return os << self.p[0].toString(16) << '_' << self.p[1].toString(16);
2922 }
2923 }
os_t os
@ self
the connection is to itself
Definition protocol.hpp:48

◆ operator>>

template<class T >
std::istream & operator>> ( std::istream & is,
EcT< T > & self )
friend

Definition at line 2924 of file bn.h.

2925 {
2926 std::string str;
2927 is >> str;
2928 if (str == "0") {
2929 self.clear();
2930 } else {
2931 self.p[2] = 1;
2932 size_t pos = str.find('_');
2933 if (pos == std::string::npos) {
2934 throw std::runtime_error("operator>>:bad format");
2935 }
2936 str[pos] = '\0';
2937 self.p[0].set(&str[0]);
2938 self.p[1].set(&str[pos + 1]);
2939 }
2940 return is;
2941 }
return str
Definition CLI11.hpp:1359

Member Data Documentation

◆ p

template<class T >
T bn::EcT< T >::p[3]
mutable

Definition at line 2817 of file bn.h.


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