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

#include <bn.h>

Inheritance diagram for bn::Fp6T< T >:
Collaboration diagram for bn::Fp6T< T >:

Classes

struct  Dbl
 

Public Types

typedef T Fp2
 
typedef T::Fp Fp
 
typedef ParamT< Fp2Param
 
typedef Fp2::Dbl Fp2Dbl
 

Public Member Functions

 Fp6T ()
 
 Fp6T (int x)
 
 Fp6T (const Fp2 &a, const Fp2 &b, const Fp2 &c)
 
 Fp6T (const Fp &a0, const Fp &a1, const Fp &a2, const Fp &a3, const Fp &a4, const Fp &a5)
 
void clear ()
 
Fpget ()
 
const Fpget () const
 
Fp2getFp2 ()
 
const Fp2getFp2 () const
 
void set (const Fp2 &v0, const Fp2 &v1, const Fp2 &v2)
 
bool isZero () const
 
void inverse ()
 
bool operator== (const Fp6T &rhs) const
 
bool operator!= (const Fp6T &rhs) const
 
- Public Member Functions inherited from mie::local::addsubmul< Fp6T< T >, mie::local::hasNegative< Fp6T< T > > >
MIE_FORCE_INLINE Toperator+= (const N &rhs)
 
MIE_FORCE_INLINE Toperator-= (const T &rhs)
 
MIE_FORCE_INLINE Toperator*= (const T &rhs)
 
- Public Member Functions inherited from mie::local::hasNegative< Fp6T< T > >
MIE_FORCE_INLINE T operator- () const
 

Static Public Member Functions

static void addC (Fp6T &z, const Fp6T &x, const Fp6T &y)
 
static void subC (Fp6T &z, const Fp6T &x, const Fp6T &y)
 
static void neg (Fp6T &z, const Fp6T &x)
 
static void mulC (Fp6T &z, const Fp6T &x, const Fp6T &y)
 
static void square (Fp6T &z, const Fp6T &x)
 
static void pointDblLineEvalWithoutPC (Fp6T &l, Fp2 *R)
 
static void mulFp6_24_Fp_01 (Fp6T &l, const Fp *P)
 
static void pointDblLineEvalC (Fp6T &l, Fp2 *R, const Fp *P)
 
static void pointAddLineEvalWithoutP (Fp6T &l, Fp2 *R, const Fp2 *Q)
 
static void pointAddLineEval (Fp6T &l, Fp2 *R, const Fp2 *Q, const Fp *P)
 
static void mul_Fp_b (Fp6T &z, const Fp &x)
 
static void mul_Fp_c (Fp6T &z, const Fp &x)
 

Public Attributes

Fp2 a_
 
Fp2 b_
 
Fp2 c_
 

Static Public Attributes

static void(* add )(Fp6T &z, const Fp6T &x, const Fp6T &y)
 
static void(* sub )(Fp6T &z, const Fp6T &x, const Fp6T &y)
 
static void(* mul )(Fp6T &z, const Fp6T &x, const Fp6T &y)
 
static void(* pointDblLineEval )(Fp6T &l, Fp2 *R, const Fp *P)
 
static void(* pointDblLineEvalWithoutP )(Fp6T &l, Fp2 *R)
 

Friends

std::ostream & operator<< (std::ostream &os, const Fp6T &x)
 
std::istream & operator>> (std::istream &is, Fp6T &x)
 

Detailed Description

template<class T>
struct bn::Fp6T< T >

Definition at line 836 of file bn.h.

Member Typedef Documentation

◆ Fp

template<class T >
T::Fp bn::Fp6T< T >::Fp

Definition at line 839 of file bn.h.

◆ Fp2

template<class T >
T bn::Fp6T< T >::Fp2

Definition at line 838 of file bn.h.

◆ Fp2Dbl

template<class T >
Fp2::Dbl bn::Fp6T< T >::Fp2Dbl

Definition at line 841 of file bn.h.

◆ Param

template<class T >
ParamT<Fp2> bn::Fp6T< T >::Param

Definition at line 840 of file bn.h.

Constructor & Destructor Documentation

◆ Fp6T() [1/4]

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

Definition at line 843 of file bn.h.

843{ }

◆ Fp6T() [2/4]

template<class T >
bn::Fp6T< T >::Fp6T ( int x)
inline

Definition at line 844 of file bn.h.

845 : a_(x)
846 , b_(0)
847 , c_(0)
848 {
849 }
Fp2 c_
Definition bn.h:842
Fp2 a_
Definition bn.h:842
Fp2 b_
Definition bn.h:842

◆ Fp6T() [3/4]

template<class T >
bn::Fp6T< T >::Fp6T ( const Fp2 & a,
const Fp2 & b,
const Fp2 & c )
inline

Definition at line 850 of file bn.h.

851 : a_(a)
852 , b_(b)
853 , c_(c)
854 {
855 }
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181

◆ Fp6T() [4/4]

template<class T >
bn::Fp6T< T >::Fp6T ( const Fp & a0,
const Fp & a1,
const Fp & a2,
const Fp & a3,
const Fp & a4,
const Fp & a5 )
inline

Definition at line 856 of file bn.h.

857 : a_(a0, a1)
858 , b_(a2, a3)
859 , c_(a4, a5)
860 {
861 }

Member Function Documentation

◆ addC()

template<class T >
static void bn::Fp6T< T >::addC ( Fp6T< T > & z,
const Fp6T< T > & x,
const Fp6T< T > & y )
inlinestatic

Definition at line 884 of file bn.h.

885 {
886 Fp2::add(z.a_, x.a_, y.a_);
887 Fp2::add(z.b_, x.b_, y.b_);
888 Fp2::add(z.c_, x.c_, y.c_);
889 }
uint64_t y
Definition sha3.cpp:34
static void(* add)(Fp2T &z, const Fp2T &x, const Fp2T &y)
Definition bn.h:368

◆ clear()

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

Definition at line 862 of file bn.h.

863 {
864 a_.clear();
865 b_.clear();
866 c_.clear();
867 }

◆ get() [1/2]

template<class T >
Fp * bn::Fp6T< T >::get ( )
inline

Definition at line 869 of file bn.h.

869{ return a_.get(); }
Here is the caller graph for this function:

◆ get() [2/2]

template<class T >
const Fp * bn::Fp6T< T >::get ( ) const
inline

Definition at line 870 of file bn.h.

870{ return a_.get(); }

◆ getFp2() [1/2]

template<class T >
Fp2 * bn::Fp6T< T >::getFp2 ( )
inline

Definition at line 871 of file bn.h.

871{ return &a_; }

◆ getFp2() [2/2]

template<class T >
const Fp2 * bn::Fp6T< T >::getFp2 ( ) const
inline

Definition at line 872 of file bn.h.

872{ return &a_; }

◆ inverse()

template<class T >
void bn::Fp6T< T >::inverse ( )
inline

Definition at line 937 of file bn.h.

938 {
939 Fp6T z;
940 Fp2 t0, t1, t2, t4, t5;
941 Fp2::mul(t0, b_, c_);
942 Fp2::mul_xi(z.a_, t0);
943 Fp2::square(t0, a_);
944 Fp2::sub(z.a_, t0, z.a_);
945 Fp2::square(t1, b_);
946 Fp2::mul(t5, a_, c_);
947 Fp2::sub(z.c_, t1, t5);
948 Fp2::square(t2, c_);
949 Fp2::mul(t4, a_, b_);
950 Fp2::mul_xi(z.b_, t2);
951 z.b_ -= t4;
952 Fp2::mul(t1, a_, z.a_);
953 Fp2::mul(t5, c_, z.b_);
954 Fp2::mul_xi(t4, t5);
955 t1 += t4;
956 Fp2::mul(t5, b_, z.c_);
957 Fp2::mul_xi(t4, t5);
958 t1 += t4;
959 t1.inverse();
960 Fp2::mul(a_, z.a_, t1);
961 Fp2::mul(b_, z.b_, t1);
962 Fp2::mul(c_, z.c_, t1);
963 }
static void(* square)(Fp2T &z, const Fp2T &x)
Definition bn.h:373
static void(* sub)(Fp2T &z, const Fp2T &x, const Fp2T &y)
Definition bn.h:370
static void(* mul_xi)(Fp2T &z, const Fp2T &x)
Definition bn.h:374
static void(* mul)(Fp2T &z, const Fp2T &x, const Fp2T &y)
Definition bn.h:372
Fp6T()
Definition bn.h:843
Here is the caller graph for this function:

◆ isZero()

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

Definition at line 879 of file bn.h.

880 {
881 return a_.isZero() && b_.isZero() && c_.isZero();
882 }

◆ mul_Fp_b()

template<class T >
static void bn::Fp6T< T >::mul_Fp_b ( Fp6T< T > & z,
const Fp & x )
inlinestatic

Definition at line 1149 of file bn.h.

1150 {
1151 Fp2::mul_Fp_0(z.b_, z.b_, x);
1152 }
static void(* mul_Fp_0)(Fp2T &z, const Fp2T &x, const Fp &b)
Definition bn.h:375

◆ mul_Fp_c()

template<class T >
static void bn::Fp6T< T >::mul_Fp_c ( Fp6T< T > & z,
const Fp & x )
inlinestatic

Definition at line 1153 of file bn.h.

1154 {
1155 Fp2::mul_Fp_0(z.c_, z.c_, x);
1156 }

◆ mulC()

template<class T >
static void bn::Fp6T< T >::mulC ( Fp6T< T > & z,
const Fp6T< T > & x,
const Fp6T< T > & y )
inlinestatic

Definition at line 904 of file bn.h.

905 {
906 Dbl zd;
907 Dbl::mul(zd, x, y);
908 Dbl::mod(z, zd);
909 }
static void(* mul)(Dbl &, const Fp6T &x, const Fp6T &y)
Definition bn.h:1262
static void mod(Fp6T &z, const Dbl &x)
Definition bn.h:1328
Here is the call graph for this function:

◆ mulFp6_24_Fp_01()

template<class T >
static void bn::Fp6T< T >::mulFp6_24_Fp_01 ( Fp6T< T > & l,
const Fp * P )
inlinestatic

Definition at line 1074 of file bn.h.

1075 {
1076 Fp2::mul_Fp_0(l.c_, l.c_, P[0]);
1077 Fp2::mul_Fp_0(l.b_, l.b_, P[1]);
1078 }
#define P
Definition dtoa.c:437
int l
Here is the caller graph for this function:

◆ neg()

template<class T >
static void bn::Fp6T< T >::neg ( Fp6T< T > & z,
const Fp6T< T > & x )
inlinestatic

Definition at line 896 of file bn.h.

897 {
898 Fp2::neg(z.a_, x.a_);
899 Fp2::neg(z.b_, x.b_);
900 Fp2::neg(z.c_, x.c_);
901 }
static void neg(Fp2T &z, const Fp2T &x)
Definition bn.h:400
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator!=()

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

Definition at line 969 of file bn.h.

969{ return !operator==(rhs); }
bool operator==(const Fp6T &rhs) const
Definition bn.h:965
Here is the call graph for this function:

◆ operator==()

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

Definition at line 965 of file bn.h.

966 {
967 return a_ == rhs.a_ && b_ == rhs.b_ && c_ == rhs.c_;
968 }
Here is the caller graph for this function:

◆ pointAddLineEval()

template<class T >
static void bn::Fp6T< T >::pointAddLineEval ( Fp6T< T > & l,
Fp2 * R,
const Fp2 * Q,
const Fp * P )
inlinestatic

Definition at line 1143 of file bn.h.

1144 {
1146 // # 13, #19
1148 }
static void mulFp6_24_Fp_01(Fp6T &l, const Fp *P)
Definition bn.h:1074
static void pointAddLineEvalWithoutP(Fp6T &l, Fp2 *R, const Fp2 *Q)
Definition bn.h:1094
#define R
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pointAddLineEvalWithoutP()

template<class T >
static void bn::Fp6T< T >::pointAddLineEvalWithoutP ( Fp6T< T > & l,
Fp2 * R,
const Fp2 * Q )
inlinestatic

Definition at line 1094 of file bn.h.

1095 {
1096 Fp2 t1, t2, t3, t4;
1097 Fp2Dbl T1, T2;
1098 // # 1
1099 Fp2::mul(t1, R[2], Q[0]);
1100 Fp2::mul(t2, R[2], Q[1]);
1101 // # 2
1102 Fp2::sub(t1, R[0], t1);
1103 Fp2::sub(t2, R[1], t2);
1104 // # 3
1105 Fp2::square(t3, t1);
1106 // # 4
1107 Fp2::mul(R[0], t3, R[0]);
1108 Fp2::square(t4, t2);
1109 // # 5
1110 t3 *= t1;
1111 t4 *= R[2];
1112 // # 6
1113 t4 += t3;
1114 // # 7
1115 t4 -= R[0];
1116 // # 8
1117 t4 -= R[0];
1118 // # 9
1119 R[0] -= t4;
1120 // # 10
1121 Fp2Dbl::mulOpt1(T1, t2, R[0]);
1122 Fp2Dbl::mulOpt1(T2, t3, R[1]);
1123 // # 11
1124 Fp2Dbl::sub(T2, T1, T2);
1125 // # 12
1126 Fp2Dbl::mod(R[1], T2);
1127 Fp2::mul(R[0], t1, t4);
1128 Fp2::mul(R[2], t3, R[2]);
1129 // # 14
1130 Fp2::neg(l.c_, t2);
1131 // # 15
1132 Fp2Dbl::mulOpt1(T1, t2, Q[0]);
1133 Fp2Dbl::mulOpt1(T2, t1, Q[1]);
1134 // # 16
1135 Fp2Dbl::sub(T1, T1, T2);
1136 // # 17
1137 Fp2Dbl::mod(t2, T1);
1138 // ### @note: Be careful, below fomulas are typo.
1139 // # 18
1140 Fp2::mul_xi(l.a_, t2);
1141 l.b_ = t1;
1142 }
static bin_op * sub
Definition bn.h:654
static void(* mod)(Fp2T &z, const Dbl &x)
Definition bn.h:660
static void(* mulOpt1)(Dbl &z, const Fp2T &x, const Fp2T &y)
Definition bn.h:657
Fp2::Dbl Fp2Dbl
Definition bn.h:841
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pointDblLineEvalC()

template<class T >
static void bn::Fp6T< T >::pointDblLineEvalC ( Fp6T< T > & l,
Fp2 * R,
const Fp * P )
inlinestatic

Definition at line 1079 of file bn.h.

1080 {
1082 // # 16, #17
1084 }
static void(* pointDblLineEvalWithoutP)(Fp6T &l, Fp2 *R)
Definition bn.h:987
Here is the call graph for this function:

◆ pointDblLineEvalWithoutPC()

template<class T >
static void bn::Fp6T< T >::pointDblLineEvalWithoutPC ( Fp6T< T > & l,
Fp2 * R )
inlinestatic

Definition at line 1001 of file bn.h.

1002 {
1003 Fp2 t0, t1, t2, t3, t4, t5;
1004 Fp2Dbl T0, T1, T2;
1005 // X1, Y1, Z1 == R[0], R[1], R[2]
1006 // xp, yp = P[0], P[1]
1007
1008 // # 1
1009 Fp2::square(t0, R[2]);
1010 Fp2::mul(t4, R[0], R[1]);
1011 Fp2::square(t1, R[1]);
1012 // # 2
1013 Fp2::add(t3, t0, t0);
1014 Fp2::divBy2(t4, t4);
1015 Fp2::add(t5, t0, t1);
1016 // # 3
1017 t0 += t3;
1018 // # 4
1019#ifdef BN_SUPPORT_SNARK
1020 if (ParamT<Fp2>::b == 82) {
1021 // (a + bu) * (9 - u) = (9a + b) + (9b - a)u
1022 t3.a_ = t0.b_;
1023 t3.b_ = t0.a_;
1024 Fp2::mul_xi(t0, t3);
1025 t2.a_ = t0.b_;
1026 t2.b_ = t0.a_;
1027 } else {
1028 // (a + bu) * binv_xi
1030 }
1031#else
1032 // (a + bu)(1 - u) = (a + b) + (b - a)u
1033 Fp::add(t2.a_, t0.a_, t0.b_);
1034 Fp::sub(t2.b_, t0.b_, t0.a_);
1035#endif
1036 // # 5
1037 Fp2::square(t0, R[0]);
1038 Fp2::add(t3, t2, t2);
1039 // ## 6
1040 t3 += t2;
1041 Fp2::addNC(l.c_, t0, t0);
1042 // ## 7
1043 Fp2::sub(R[0], t1, t3);
1044 Fp2::addNC(l.c_, l.c_, t0);
1045 t3 += t1;
1046 // # 8
1047 R[0] *= t4;
1048 Fp2::divBy2(t3, t3);
1049 // ## 9
1050 Fp2Dbl::square(T0, t3);
1051 Fp2Dbl::square(T1, t2);
1052 // # 10
1053 Fp2Dbl::addNC(T2, T1, T1);
1054 Fp2::add(t3, R[1], R[2]);
1055 // # 11
1056#ifdef BN_SUPPORT_SNARK
1057 Fp2Dbl::add(T2, T2, T1);
1058#else
1059 Fp2Dbl::addNC(T2, T2, T1);
1060#endif
1061 Fp2::square(t3, t3);
1062 // # 12
1063 t3 -= t5;
1064 // # 13
1065 T0 -= T2;
1066 // # 14
1067 Fp2Dbl::mod(R[1], T0);
1068 Fp2::mul(R[2], t1, t3);
1069 t2 -= t1;
1070 // # 15
1071 Fp2::mul_xi(l.a_, t2);
1072 Fp2::neg(l.b_, t3);
1073 }
static void(* add)(Fp &out, const Fp &x, const Fp &y)
Definition zm2.h:83
static void(* sub)(Fp &out, const Fp &x, const Fp &y)
Definition zm2.h:91
static bin_op * addNC
Definition bn.h:652
static bin_op * add
Definition bn.h:651
static void(* square)(Dbl &z, const Fp2T &x)
Definition bn.h:659
static void(* addNC)(Fp2T &z, const Fp2T &x, const Fp2T &y)
Definition bn.h:369
static void(* divBy2)(Fp2T &z, const Fp2T &x)
Definition bn.h:376
static int b
Definition bn.h:194
static Fp2 b_invxi
Definition bn.h:195
Here is the call graph for this function:

◆ set()

template<class T >
void bn::Fp6T< T >::set ( const Fp2 & v0,
const Fp2 & v1,
const Fp2 & v2 )
inline

Definition at line 873 of file bn.h.

874 {
875 a_ = v0;
876 b_ = v1;
877 c_ = v2;
878 }

◆ square()

template<class T >
static void bn::Fp6T< T >::square ( Fp6T< T > & z,
const Fp6T< T > & x )
inlinestatic

Definition at line 914 of file bn.h.

915 {
916 assert(&z != &x);
917 Fp2 v3, v4, v5;
918 Fp2::add(v4, x.a_, x.a_);
919 Fp2::mul(v4, v4, x.b_);
920 Fp2::square(v5, x.c_);
921 Fp2::mul_xi(z.b_, v5);
922 z.b_ += v4;
923 Fp2::sub(z.c_, v4, v5);
924 Fp2::square(v3, x.a_);
925 Fp2::sub(v4, x.a_, x.b_);
926 v4 += x.c_;
927 Fp2::add(v5, x.b_, x.b_);
928 Fp2::mul(v5, v5, x.c_);
929 Fp2::square(v4, v4);
930 Fp2::mul_xi(z.a_, v5);
931 z.a_ += v3;
932 z.c_ += v4;
933 z.c_ += v5;
934 z.c_ -= v3;
935 }
Here is the caller graph for this function:

◆ subC()

template<class T >
static void bn::Fp6T< T >::subC ( Fp6T< T > & z,
const Fp6T< T > & x,
const Fp6T< T > & y )
inlinestatic

Definition at line 890 of file bn.h.

891 {
892 Fp2::sub(z.a_, x.a_, y.a_);
893 Fp2::sub(z.b_, x.b_, y.b_);
894 Fp2::sub(z.c_, x.c_, y.c_);
895 }

Friends And Related Symbol Documentation

◆ operator<<

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

Definition at line 970 of file bn.h.

971 {
972 return os << "[" << x.a_ << ",\n " << x.b_ << ",\n " << x.c_ << "]";
973 }
os_t os

◆ operator>>

template<class T >
std::istream & operator>> ( std::istream & is,
Fp6T< T > & x )
friend

Definition at line 974 of file bn.h.

975 {
976 char c1, c2, c3, c4;
977 is >> c1 >> x.a_ >> c2 >> x.b_ >> c3 >> x.c_ >> c4;
978 if (c1 == '[' && c2 == ',' && c3 == ',' && c4 == ']') return is;
979 throw std::ios_base::failure("bad Fp6");
980 }

Member Data Documentation

◆ a_

template<class T >
Fp2 bn::Fp6T< T >::a_

Definition at line 842 of file bn.h.

◆ add

template<class T >
void(* bn::Fp6T< T >::add) (Fp6T &z, const Fp6T &x, const Fp6T &y)
static

Definition at line 982 of file bn.h.

◆ b_

template<class T >
Fp2 bn::Fp6T< T >::b_

Definition at line 842 of file bn.h.

◆ c_

template<class T >
Fp2 bn::Fp6T< T >::c_

Definition at line 842 of file bn.h.

◆ mul

template<class T >
void(* bn::Fp6T< T >::mul) (Fp6T &z, const Fp6T &x, const Fp6T &y)
static

Definition at line 984 of file bn.h.

◆ pointDblLineEval

template<class T >
void(* bn::Fp6T< T >::pointDblLineEval) (Fp6T &l, Fp2 *R, const Fp *P)
static

Definition at line 986 of file bn.h.

◆ pointDblLineEvalWithoutP

template<class T >
void(* bn::Fp6T< T >::pointDblLineEvalWithoutP) (Fp6T &l, Fp2 *R)
static

Definition at line 987 of file bn.h.

◆ sub

template<class T >
void(* bn::Fp6T< T >::sub) (Fp6T &z, const Fp6T &x, const Fp6T &y)
static

Definition at line 983 of file bn.h.


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