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

#include <bn.h>

Collaboration diagram for bn::CompressT< T >:

Public Types

enum  { N = 4 }
 
typedef T Fp2
 
typedef Fp2::Fp Fp
 
typedef ParamT< Fp2Param
 
typedef Fp2::Dbl Fp2Dbl
 
typedef Fp6T< Fp2Fp6
 
typedef Fp12T< Fp6Fp12
 

Public Member Functions

 CompressT (Fp12 &z, const Fp12 &x)
 
 CompressT (Fp12 &z, const CompressT &c)
 
void decompress ()
 

Static Public Member Functions

static void squareC (CompressT &z)
 
static void square_nC (CompressT &z, int n)
 
static void fixed_power (Fp12 &z, const Fp12 &x)
 

Public Attributes

Fp12z_
 
Fp2g1_
 
Fp2g2_
 
Fp2g3_
 
Fp2g4_
 
Fp2g5_
 

Static Public Attributes

static void(* square_n )(CompressT &z, int n)
 

Friends

std::ostream & operator<< (std::ostream &os, const CompressT &x)
 

Detailed Description

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

Definition at line 2128 of file bn.h.

Member Typedef Documentation

◆ Fp

Definition at line 2130 of file bn.h.

◆ Fp12

Definition at line 2134 of file bn.h.

◆ Fp2

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

Definition at line 2129 of file bn.h.

◆ Fp2Dbl

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

Definition at line 2132 of file bn.h.

◆ Fp6

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

Definition at line 2133 of file bn.h.

◆ Param

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

Definition at line 2131 of file bn.h.

Member Enumeration Documentation

◆ anonymous enum

template<class T >
anonymous enum
Enumerator

Definition at line 2135 of file bn.h.

2135{ N = 4 };

Constructor & Destructor Documentation

◆ CompressT() [1/2]

template<class T >
bn::CompressT< T >::CompressT ( Fp12 & z,
const Fp12 & x )
inline

Definition at line 2145 of file bn.h.

2146 : z_(z)
2147 , g1_(z.getFp2()[4])
2148 , g2_(z.getFp2()[3])
2149 , g3_(z.getFp2()[2])
2150 , g4_(z.getFp2()[1])
2151 , g5_(z.getFp2()[5])
2152 {
2153 g2_ = x.getFp2()[3];
2154 g3_ = x.getFp2()[2];
2155 g4_ = x.getFp2()[1];
2156 g5_ = x.getFp2()[5];
2157 }
Fp2 & g2_
Definition bn.h:2139
Fp12 & z_
Definition bn.h:2137
Fp2 & g5_
Definition bn.h:2142
Fp2 & g1_
Definition bn.h:2138
Fp2 & g4_
Definition bn.h:2141
Fp2 & g3_
Definition bn.h:2140
Here is the call graph for this function:

◆ CompressT() [2/2]

template<class T >
bn::CompressT< T >::CompressT ( Fp12 & z,
const CompressT< T > & c )
inline

Definition at line 2158 of file bn.h.

2159 : z_(z)
2160 , g1_(z.getFp2()[4])
2161 , g2_(z.getFp2()[3])
2162 , g3_(z.getFp2()[2])
2163 , g4_(z.getFp2()[1])
2164 , g5_(z.getFp2()[5])
2165 {
2166 g2_ = c.g2_;
2167 g3_ = c.g3_;
2168 g4_ = c.g4_;
2169 g5_ = c.g5_;
2170 }

Member Function Documentation

◆ decompress()

template<class T >
void bn::CompressT< T >::decompress ( )
inline

Definition at line 2220 of file bn.h.

2221 {
2222 Fp2 nume, denomi;
2223 decompressBeforeInv(nume, denomi);
2224 denomi.inverse();
2225 g1_ = nume * denomi; // g1 is recoverd.
2226 decompressAfterInv();
2227 }
Here is the caller graph for this function:

◆ fixed_power()

template<class T >
static void bn::CompressT< T >::fixed_power ( Fp12 & z,
const Fp12 & x )
inlinestatic

Definition at line 2310 of file bn.h.

2311 {
2312#if 0
2313 z = power(x, Param::z.abs());
2314#else
2315 assert(&z != &x);
2316 Fp12 d62;
2317 Fp2 c55nume, c55denomi, c62nume, c62denomi;
2318 CompressT c55(z, x);
2319 CompressT::square_n(c55, 55); // 106k
2320 c55.decompressBeforeInv(c55nume, c55denomi);
2321 CompressT c62(d62, c55);
2322 CompressT::square_n(c62, 62 - 55); // 13.6k
2323 c62.decompressBeforeInv(c62nume, c62denomi);
2324 Fp2 acc;
2325 Fp2::mul(acc, c55denomi, c62denomi);
2326 acc.inverse();
2327 Fp2 t;
2328 Fp2::mul(t, acc, c62denomi);
2329 Fp2::mul(c55.g1_, c55nume, t);
2330 c55.decompressAfterInv(); // 1.1k
2331 Fp2::mul(t, acc, c55denomi);
2332 Fp2::mul(c62.g1_, c62nume, t);
2333 c62.decompressAfterInv();
2334 z *= x; // 6.5k
2335 z *= d62;
2336#endif
2337 }
void(* CompressT)(CompressT &, int)
Definition bn.h:2345
T power(const T &x, const S &y)
Definition zm.h:1389
static void(* square_n)(CompressT &z, int n)
Definition bn.h:2338
static void(* mul)(Fp2T &z, const Fp2T &x, const Fp2T &y)
Definition bn.h:372
static mie::Vsint z
Definition bn.h:181
Here is the caller graph for this function:

◆ square_nC()

template<class T >
static void bn::CompressT< T >::square_nC ( CompressT< T > & z,
int n )
inlinestatic

Definition at line 2299 of file bn.h.

2300 {
2301 for (int i = 0; i < n; i++) {
2302 squareC(z);
2303 }
2304 }
static void squareC(CompressT &z)
Definition bn.h:2232
Here is the call graph for this function:

◆ squareC()

template<class T >
static void bn::CompressT< T >::squareC ( CompressT< T > & z)
inlinestatic

Definition at line 2232 of file bn.h.

2233 {
2234 Fp2 t0, t1, t2;
2235 Fp2Dbl T0, T1, T2, T3;
2236 Fp2Dbl::square(T0, z.g4_);
2237 Fp2Dbl::square(T1, z.g5_);
2238 // # 7
2239 Fp2Dbl::mul_xi(T2, T1);
2240 // # 8
2241 T2 += T0;
2242 // # 9
2243 Fp2Dbl::mod(t2, T2);
2244 // # 1
2245 Fp2::add(t0, z.g4_, z.g5_);
2246 Fp2Dbl::square(T2, t0);
2247 // # 2
2248 T0 += T1;
2249// Fp2Dbl::addNC(T0, T0, T1); // QQQ : OK?
2250 T2 -= T0;
2251 // # 3
2252 Fp2Dbl::mod(t0, T2);
2253 Fp2::add(t1, z.g2_, z.g3_);
2254 Fp2Dbl::square(T3, t1);
2255 Fp2Dbl::square(T2, z.g2_);
2256 // # 4
2257 Fp2::mul_xi(t1, t0);
2258#if 1 // RRR
2259 Fp::_3z_add_2xC(z.g2_.a_, t1.a_);
2260 Fp::_3z_add_2xC(z.g2_.b_, t1.b_);
2261#else
2262 // # 5
2263 z.g2_ += t1;
2264 z.g2_ += z.g2_;
2265 // # 6
2266 z.g2_ += t1;
2267#endif
2268 Fp2::sub(t1, t2, z.g3_);
2269 t1 += t1;
2270 // # 11 !!!!
2271 Fp2Dbl::square(T1, z.g3_);
2272 // # 10 !!!!
2273 Fp2::add(z.g3_, t1, t2);
2274 // # 12
2275 Fp2Dbl::mul_xi(T0, T1);
2276 // # 13
2277 T0 += T2;
2278// Fp2Dbl::addNC(T0, T0, T2); // QQQ : OK?
2279 // # 14
2280 Fp2Dbl::mod(t0, T0);
2281 Fp2::sub(z.g4_, t0, z.g4_);
2282 z.g4_ += z.g4_;
2283 // # 15
2284 z.g4_ += t0;
2285 // # 16
2286 Fp2Dbl::addNC(T2, T2, T1);
2287 T3 -= T2;
2288 // # 17
2289 Fp2Dbl::mod(t0, T3);
2290#if 1 // RRR
2291 Fp::_3z_add_2xC(z.g5_.a_, t0.a_);
2292 Fp::_3z_add_2xC(z.g5_.b_, t0.b_);
2293#else
2294 z.g5_ += t0;
2295 z.g5_ += z.g5_;
2296 z.g5_ += t0; // # 18
2297#endif
2298 }
static void _3z_add_2xC(Fp &z, const Fp &x)
Definition zm2.h:98
Fp2::Dbl Fp2Dbl
Definition bn.h:2132
static void(* mod)(Fp2T &z, const Dbl &x)
Definition bn.h:660
static bin_op * addNC
Definition bn.h:652
static uni_op * mul_xi
Definition bn.h:662
static void(* square)(Dbl &z, const Fp2T &x)
Definition bn.h:659
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(* add)(Fp2T &z, const Fp2T &x, const Fp2T &y)
Definition bn.h:368
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 >
std::ostream & operator<< ( std::ostream & os,
const CompressT< T > & x )
friend

Definition at line 2172 of file bn.h.

2173 {
2174 os << "C[" << x.g2_ << ",\n" << x.g3_ << ",\n" << x.g4_ << ",\n" << x.g5_ << ",\n" << "]";
2175 return os;
2176 }
os_t os

Member Data Documentation

◆ g1_

template<class T >
Fp2& bn::CompressT< T >::g1_

Definition at line 2138 of file bn.h.

◆ g2_

template<class T >
Fp2& bn::CompressT< T >::g2_

Definition at line 2139 of file bn.h.

◆ g3_

template<class T >
Fp2& bn::CompressT< T >::g3_

Definition at line 2140 of file bn.h.

◆ g4_

template<class T >
Fp2& bn::CompressT< T >::g4_

Definition at line 2141 of file bn.h.

◆ g5_

template<class T >
Fp2& bn::CompressT< T >::g5_

Definition at line 2142 of file bn.h.

◆ square_n

template<class T >
void(* bn::CompressT< T >::square_n) (CompressT &z, int n)
static

Definition at line 2338 of file bn.h.

◆ z_

template<class T >
Fp12& bn::CompressT< T >::z_

Definition at line 2137 of file bn.h.


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