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

#include <bn.h>

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

Classes

struct  Dbl
 

Public Types

typedef T Fp
 

Public Member Functions

 Fp2T ()
 
 Fp2T (int x)
 
 Fp2T (const Fp &a, const Fp &b)
 
Fpget ()
 
const Fpget () const
 
bool isZero () const
 
void inverse ()
 
void clear ()
 
std::string toString (int base=10) const
 
bool operator== (const Fp2T &rhs) const
 
bool operator!= (const Fp2T &rhs) const
 
void set (const std::string &str)
 
void mul_x ()
 
- Public Member Functions inherited from mie::local::addsubmul< Fp2T< T >, mie::local::hasNegative< Fp2T< 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< Fp2T< T > >
MIE_FORCE_INLINE T operator- () const
 

Static Public Member Functions

static void addC (Fp2T &z, const Fp2T &x, const Fp2T &y)
 
static void addNC_C (Fp2T &z, const Fp2T &x, const Fp2T &y)
 
static void subNC_C (Fp2T &z, const Fp2T &x, const Fp2T &y)
 
static void subC (Fp2T &z, const Fp2T &x, const Fp2T &y)
 
static void neg (Fp2T &z, const Fp2T &x)
 
static void mulC (Fp2T &z, const Fp2T &x, const Fp2T &y)
 
static void divBy2C (Fp2T &z, const Fp2T &x)
 
static void divBy4 (Fp2T &z, const Fp2T &x)
 
static void mul_xiC (Fp2T &z, const Fp2T &x)
 
static void squareC (Fp2T &z, const Fp2T &x)
 
static void mul_Fp_0C (Fp2T &z, const Fp2T &x, const Fp &b)
 
static void mul_Fp_1 (Fp2T &z, const Fp &y_b)
 

Public Attributes

Fp a_
 
Fp b_
 

Static Public Attributes

static void(* add )(Fp2T &z, const Fp2T &x, const Fp2T &y)
 
static void(* addNC )(Fp2T &z, const Fp2T &x, const Fp2T &y)
 
static void(* sub )(Fp2T &z, const Fp2T &x, const Fp2T &y)
 
static void(* subNC )(Fp2T &z, const Fp2T &x, const Fp2T &y)
 
static void(* mul )(Fp2T &z, const Fp2T &x, const Fp2T &y)
 
static void(* square )(Fp2T &z, const Fp2T &x)
 
static void(* mul_xi )(Fp2T &z, const Fp2T &x)
 
static void(* mul_Fp_0 )(Fp2T &z, const Fp2T &x, const Fp &b)
 
static void(* divBy2 )(Fp2T &z, const Fp2T &x)
 

Friends

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

Detailed Description

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

Definition at line 347 of file bn.h.

Member Typedef Documentation

◆ Fp

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

Definition at line 349 of file bn.h.

Constructor & Destructor Documentation

◆ Fp2T() [1/3]

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

Definition at line 351 of file bn.h.

351{ }

◆ Fp2T() [2/3]

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

Definition at line 352 of file bn.h.

353 : a_(x)
354 , b_(0)
355 {
356 }
Fp a_
Definition bn.h:350
Fp b_
Definition bn.h:350

◆ Fp2T() [3/3]

template<class T >
bn::Fp2T< T >::Fp2T ( const Fp & a,
const Fp & b )
inline

Definition at line 357 of file bn.h.

358 : a_(a)
359 , b_(b)
360 {
361 }
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181

Member Function Documentation

◆ addC()

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

Definition at line 378 of file bn.h.

379 {
380 Fp::add(z.a_, x.a_, y.a_);
381 Fp::add(z.b_, x.b_, y.b_);
382 }
static void(* add)(Fp &out, const Fp &x, const Fp &y)
Definition zm2.h:83
uint64_t y
Definition sha3.cpp:34

◆ addNC_C()

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

Definition at line 383 of file bn.h.

384 {
385 Fp::addNC(z.a_, x.a_, y.a_);
386 Fp::addNC(z.b_, x.b_, y.b_);
387 }
static void(* addNC)(Fp &out, const Fp &x, const Fp &y)
Definition zm2.h:86

◆ clear()

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

Definition at line 515 of file bn.h.

516 {
517 a_.clear();
518 b_.clear();
519 }

◆ divBy2C()

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

Definition at line 428 of file bn.h.

429 {
430 Fp::divBy2(z.a_, x.a_);
431 Fp::divBy2(z.b_, x.b_);
432 }
static void divBy2(Fp &z, const Fp &x)
Definition zm2.h:216
Here is the call graph for this function:

◆ divBy4()

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

Definition at line 434 of file bn.h.

435 {
436 Fp::divBy4(z.a_, x.a_);
437 Fp::divBy4(z.b_, x.b_);
438 }
static void divBy4(Fp &z, const Fp &x)
Definition zm2.h:223
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get() [1/2]

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

Definition at line 362 of file bn.h.

362{ return &a_; }

◆ get() [2/2]

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

Definition at line 363 of file bn.h.

363{ return &a_; }

◆ inverse()

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

Definition at line 505 of file bn.h.

506 {
507 Fp t; Fp::mul(t, b_, b_);
508 Fp aa; Fp::mul(aa, a_, a_);
509 t += aa;
510 Fp::inv(t, t); // 7.5K@i7, 10Kclk@Opteron
511 a_ *= t;
512 Fp::neg(b_, b_);
513 b_ *= t;
514 }
static void(* mul)(Fp &out, const Fp &x, const Fp &y)
Definition zm2.h:93
static void inv(Fp &out, const Fp &x)
Definition zm2.h:165
static void(* neg)(Fp &out, const Fp &x)
Definition zm2.h:92
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isZero()

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

Definition at line 364 of file bn.h.

365 {
366 return a_.isZero() && b_.isZero();
367 }
Here is the caller graph for this function:

◆ mul_Fp_0C()

template<class T >
static void bn::Fp2T< T >::mul_Fp_0C ( Fp2T< T > & z,
const Fp2T< T > & x,
const Fp & b )
inlinestatic

Definition at line 549 of file bn.h.

550 {
551 Fp::mul(z.a_, x.a_, b);
552 Fp::mul(z.b_, x.b_, b);
553 }

◆ mul_Fp_1()

template<class T >
static void bn::Fp2T< T >::mul_Fp_1 ( Fp2T< T > & z,
const Fp & y_b )
inlinestatic

Definition at line 575 of file bn.h.

576 {
577 Fp t;
578 Fp::mul(t, z.b_, y_b);
579 Fp::mul(z.b_, z.a_, y_b);
580 Fp::neg(z.a_, t);
581 }
Here is the caller graph for this function:

◆ mul_x()

template<class T >
void bn::Fp2T< T >::mul_x ( )
inline

Definition at line 561 of file bn.h.

562 {
563 Fp t = b_;
564 b_ = a_;
565 Fp::neg(a_, t);
566 }

◆ mul_xiC()

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

Definition at line 470 of file bn.h.

471 {
472 assert(&z != &x);
473 Fp::sub(z.a_, x.a_, x.b_);
474 Fp::add(z.b_, x.a_, x.b_);
475 }
static void(* sub)(Fp &out, const Fp &x, const Fp &y)
Definition zm2.h:91

◆ mulC()

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

Definition at line 412 of file bn.h.

413 {
414 typename Fp::Dbl d[3];
415 Fp s, t;
416 Fp::addNC(s, x.a_, x.b_); // a + b
417 Fp::addNC(t, y.a_, y.b_); // c + d
418 Fp::Dbl::mul(d[0], s, t); // (a + b)(c + d)
419 Fp::Dbl::mul(d[1], x.a_, y.a_); // ac
420 Fp::Dbl::mul(d[2], x.b_, y.b_); // bd
421 Fp::Dbl::subNC(d[0], d[0], d[1]); // (a + b)(c + d) - ac
422 Fp::Dbl::subNC(d[0], d[0], d[2]); // (a + b)(c + d) - ac - bd
423 Fp::Dbl::mod(z.b_, d[0]); // set z[1]
424 Fp::Dbl::sub(d[1], d[1], d[2]); // ac - bd
425 Fp::Dbl::mod(z.a_, d[1]); // set z[0]
426 }
static void(* subNC)(Fp &out, const Fp &x, const Fp &y)
Definition zm2.h:87
CK_ULONG d
char * s

◆ neg()

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

Definition at line 400 of file bn.h.

401 {
402 Fp::neg(z.a_, x.a_);
403 Fp::neg(z.b_, x.b_);
404 }
Here is the caller graph for this function:

◆ operator!=()

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

Definition at line 540 of file bn.h.

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

◆ operator==()

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

Definition at line 536 of file bn.h.

537 {
538 return a_ == rhs.a_ && b_ == rhs.b_;
539 }
Here is the caller graph for this function:

◆ set()

template<class T >
void bn::Fp2T< T >::set ( const std::string & str)
inline

Definition at line 542 of file bn.h.

543 {
544 std::istringstream iss(str);
545 iss >> *this;
546 }

◆ squareC()

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

Definition at line 481 of file bn.h.

482 {
483#ifdef BN_SUPPORT_SNARK
484 Fp t, tt;
485 Fp::add(t, x.b_, x.b_); // 2b
486 t *= x.a_; // 2ab
487 Fp::sub(tt, x.a_, x.b_); // a - b
488 Fp::add(z.a_, x.a_, x.b_); // a + b
489 z.a_ *= tt; // (a - b)(a + b)
490 z.b_ = t;
491#else
492 Fp t, tt;
493 Fp::addNC(t, x.b_, x.b_); // 2b
494 t *= x.a_; // 2ab
495 Fp::sub(tt, x.a_, x.b_); // a - b
496 Fp::addNC(z.a_, x.a_, x.a_); // a + b
497 z.a_ *= tt; // (a - b)(a + b)
498 z.b_ = t;
499#endif
500 }

◆ subC()

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

Definition at line 395 of file bn.h.

396 {
397 Fp::sub(z.a_, x.a_, y.a_);
398 Fp::sub(z.b_, x.b_, y.b_);
399 }

◆ subNC_C()

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

Definition at line 389 of file bn.h.

390 {
391 Fp::subNC(z.a_, x.a_, y.a_);
392 Fp::subNC(z.b_, x.b_, y.b_);
393 }

◆ toString()

template<class T >
std::string bn::Fp2T< T >::toString ( int base = 10) const
inline

Definition at line 521 of file bn.h.

522 {
523 return ("[" + a_.toString(base) + "," + b_.toString(base) + "]");
524 }
std::string toString() const
Definition bn254_if.hpp:73
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 Fp2T< T > & x )
friend

Definition at line 525 of file bn.h.

526 {
527 return os << x.toString();
528 }
os_t os

◆ operator>>

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

Definition at line 529 of file bn.h.

530 {
531 char cl, cm, cr;
532 is >> cl >> x.a_ >> cm >> x.b_ >> cr;
533 if (cl == '[' && cm == ',' && cr == ']') return is;
534 throw std::ios_base::failure("bad Fp2");
535 }
static const Reg8 cl(Operand::CL)

Member Data Documentation

◆ a_

template<class T >
Fp bn::Fp2T< T >::a_

Definition at line 350 of file bn.h.

◆ add

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

Definition at line 368 of file bn.h.

◆ addNC

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

Definition at line 369 of file bn.h.

◆ b_

template<class T >
Fp bn::Fp2T< T >::b_

Definition at line 350 of file bn.h.

◆ divBy2

template<class T >
void(* bn::Fp2T< T >::divBy2) (Fp2T &z, const Fp2T &x)
static

Definition at line 376 of file bn.h.

◆ mul

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

Definition at line 372 of file bn.h.

◆ mul_Fp_0

template<class T >
void(* bn::Fp2T< T >::mul_Fp_0) (Fp2T &z, const Fp2T &x, const Fp &b)
static

Definition at line 375 of file bn.h.

◆ mul_xi

template<class T >
void(* bn::Fp2T< T >::mul_xi) (Fp2T &z, const Fp2T &x)
static

Definition at line 374 of file bn.h.

◆ square

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

Definition at line 373 of file bn.h.

◆ sub

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

Definition at line 370 of file bn.h.

◆ subNC

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

Definition at line 371 of file bn.h.


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