Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
bn Namespace Reference

Namespaces

namespace  components
 
namespace  ecop
 
namespace  util
 

Classes

struct  CompressT
 
struct  CurveParam
 
class  EcT
 
struct  Fp12T
 
struct  Fp2T
 
struct  Fp6T
 
struct  ParamT
 

Typedefs

typedef mie::Fp Fp
 
typedef Fp::Dbl FpDbl
 
typedef Fp2T< FpFp2
 
typedef Fp2::Dbl Fp2Dbl
 
typedef ParamT< Fp2Param
 
typedef Fp6T< Fp2Fp6
 
typedef Fp6::Dbl Fp6Dbl
 
typedef Fp12T< Fp6Fp12
 
typedef Fp12::Dbl Fp12Dbl
 
typedef CompressT< Fp2Compress
 
typedef EcT< Fp2Ec2
 
typedef EcT< FpEc1
 

Functions

template<class F , class G >
void mul_gamma_add (F &z, const F &x, const F &y)
 
template<class Fp >
void opt_atePairing (Fp12T< Fp6T< Fp2T< Fp > > > &f, const Fp2T< Fp > Q[2], const Fp P[2])
 
template<class Fp >
void opt_atePairingJac (Fp12T< Fp6T< Fp2T< Fp > > > &f, const Fp2T< Fp > _Q[3], const Fp _P[3])
 
void opt_atePairing (Fp12 &f, const Ec2 &Q, const Ec1 &P)
 

Variables

const CurveParam CurveFp254BNb = { -((1LL << 62) + (1LL << 55) + (1LL << 0)), 2, 1, 1 }
 
template<class Fp >
void(* Fp2T )(Fp2T< Fp > &out, const Fp2T< Fp > &x, const Fp2T< Fp > &y) = &(Fp2T<Fp>::addC)
 
template<class Fp2 >
void(* Fp6T )(Fp6T< Fp2 > &z, const Fp6T< Fp2 > &x, const Fp6T< Fp2 > &y) = &(Fp6T<Fp2>::addC)
 
template<class Fp6 >
void(* Fp12T )(Fp12T &x) = &(Fp12T<Fp6>::squareC)
 
template<class Fp2 >
void(* CompressT )(CompressT &, int) = &(CompressT<Fp2>::square_nC)
 

Typedef Documentation

◆ Compress

Definition at line 2961 of file bn.h.

◆ Ec1

typedef EcT<Fp> bn::Ec1

Definition at line 2964 of file bn.h.

◆ Ec2

typedef EcT<Fp2> bn::Ec2

Definition at line 2963 of file bn.h.

◆ Fp

typedef mie::Fp bn::Fp

Definition at line 2952 of file bn.h.

◆ Fp12

typedef Fp12T<Fp6> bn::Fp12

Definition at line 2959 of file bn.h.

◆ Fp12Dbl

Definition at line 2960 of file bn.h.

◆ Fp2

typedef Fp2T<Fp> bn::Fp2

Definition at line 2954 of file bn.h.

◆ Fp2Dbl

Definition at line 2955 of file bn.h.

◆ Fp6

typedef Fp6T<Fp2> bn::Fp6

Definition at line 2957 of file bn.h.

◆ Fp6Dbl

Definition at line 2958 of file bn.h.

◆ FpDbl

typedef Fp::Dbl bn::FpDbl

Definition at line 2953 of file bn.h.

◆ Param

typedef ParamT<Fp2> bn::Param

Definition at line 2956 of file bn.h.

Function Documentation

◆ mul_gamma_add()

template<class F , class G >
void bn::mul_gamma_add ( F & z,
const F & x,
const F & y )

Definition at line 333 of file bn.h.

334{
335 G::mul_xi(z.a_, x.c_);
336 z.a_ += y.a_;
337 G::add(z.b_, x.a_, y.b_);
338 G::add(z.c_, x.b_, y.c_);
339}
Here is the caller graph for this function:

◆ opt_atePairing() [1/2]

void bn::opt_atePairing ( Fp12 & f,
const Ec2 & Q,
const Ec1 & P )
inline

Definition at line 2966 of file bn.h.

2967{
2968 Q.normalize();
2969 P.normalize();
2970 if (Q.isZero() || P.isZero()) {
2971 f = 1;
2972 return;
2973 }
2974 opt_atePairing<Fp>(f, Q.p, P.p);
2975}
T p[3]
Definition bn.h:2817
bool isZero() const
Definition bn.h:2911
void normalize() const
Definition bn.h:2827
#define P
Definition dtoa.c:437
Here is the call graph for this function:

◆ opt_atePairing() [2/2]

template<class Fp >
void bn::opt_atePairing ( Fp12T< Fp6T< Fp2T< Fp > > > & f,
const Fp2T< Fp > Q[2],
const Fp P[2] )

Definition at line 2720 of file bn.h.

2721{
2722 typedef Fp2T<Fp> Fp2;
2723 typedef ParamT<Fp2> Param;
2724 typedef Fp6T<Fp2> Fp6;
2725 typedef Fp12T<Fp6> Fp12;
2726 Fp2 T[3];
2727 T[0] = Q[0];
2728 T[1] = Q[1];
2729 T[2] = Fp2(1);
2730 Fp2 Qneg[2];
2731 if (Param::useNAF) {
2732 Qneg[0] = Q[0];
2733 Fp2::neg(Qneg[1], Q[1]);
2734 }
2735 // at 1.
2736 Fp6 d;
2737 Fp6::pointDblLineEval(d, T, P);
2738 Fp6 e;
2739 assert(Param::siTbl[1] == 1);
2740 Fp6::pointAddLineEval(e, T, Q, P);
2741 Fp12::Dbl::mul_Fp2_024_Fp2_024(f, d, e);
2742 // loop from 2.
2743 Fp6 l;
2744 // 844kclk
2745 for (size_t i = 2; i < Param::siTbl.size(); i++) {
2746 // 3.6k x 63
2747 Fp6::pointDblLineEval(l, T, P);
2748 // 4.7k x 63
2749 Fp12::square(f);
2750 // 4.48k x 63
2751 Fp12::Dbl::mul_Fp2_024(f, l);
2752
2753 if (Param::siTbl[i] > 0) {
2754 // 9.8k x 3
2755 // 5.1k
2756 Fp6::pointAddLineEval(l, T, Q, P);
2757 Fp12::Dbl::mul_Fp2_024(f, l);
2758 }
2759 else if (Param::siTbl[i] < 0) {
2760 Fp6::pointAddLineEval(l, T, Qneg, P);
2761 Fp12::Dbl::mul_Fp2_024(f, l);
2762 }
2763 }
2764
2765 // addition step
2766 Fp2 Q1[2];
2767 ecop::FrobEndOnTwist_1(Q1, Q);
2768 Fp2 Q2[2];
2769#ifdef BN_SUPPORT_SNARK
2770 ecop::FrobEndOnTwist_2(Q2, Q);
2771 Fp2::neg(Q2[1], Q2[1]);
2772#else
2773 ecop::FrobEndOnTwist_8(Q2, Q);
2774 // @memo z < 0
2775 Fp6::neg(f.b_, f.b_);
2776 Fp2::neg(T[1], T[1]);
2777#endif
2778 Fp12 ft;
2779 Fp6::pointAddLineEval(d, T, Q1, P); // 5k
2780 Fp6::pointAddLineEval(e, T, Q2, P); // 5k
2781 Fp12::Dbl::mul_Fp2_024_Fp2_024(ft, d, e); // 2.7k
2782 Fp12::mul(f, f, ft); // 6.4k
2783 // final exponentiation
2784 f.final_exp();
2785}
void mul(const Fp12 &rhs)
Definition bn254_if.hpp:143
#define T(meth, val, expected)
Definition bn.h:348
Definition bn.h:837
CK_ULONG d
int l
Here is the call graph for this function:
Here is the caller graph for this function:

◆ opt_atePairingJac()

template<class Fp >
void bn::opt_atePairingJac ( Fp12T< Fp6T< Fp2T< Fp > > > & f,
const Fp2T< Fp > _Q[3],
const Fp _P[3] )

Definition at line 2795 of file bn.h.

2796{
2797 if (_Q[2] == 0 || _P[2] == 0) {
2798 f = 1;
2799 return;
2800 }
2801
2802 Fp2T<Fp> Q[3];
2803 Fp P[3];
2804 ecop::NormalizeJac(Q, _Q);
2805 ecop::NormalizeJac(P, _P);
2806 opt_atePairing(f, Q, P);
2807}
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ CompressT

template<class Fp2 >
void(* bn::CompressT) (CompressT &, int) ( CompressT & ,
int  ) = &(CompressT<Fp2>::square_nC)

Definition at line 2345 of file bn.h.

◆ CurveFp254BNb

const CurveParam bn::CurveFp254BNb = { -((1LL << 62) + (1LL << 55) + (1LL << 0)), 2, 1, 1 }

Definition at line 84 of file bn.h.

84{ -((1LL << 62) + (1LL << 55) + (1LL << 0)), 2, 1, 1 };

◆ Fp12T

template<class Fp6 >
void(* bn::Fp12T)(Fp12T &z, const Fp12T &x, const Fp12T &y) ( Fp12T & x) = &(Fp12T<Fp6>::squareC)

Definition at line 2119 of file bn.h.

◆ Fp2T

template<class Fp >
void(* bn::Fp2T)(Fp2T &, const Dbl &) ( Fp2T< Fp > & out,
const Fp2T< Fp > & x,
const Fp2T< Fp > & y ) = &(Fp2T<Fp>::addC)

Definition at line 775 of file bn.h.

◆ Fp6T

template<class Fp2 >
void(* bn::Fp6T)(Dbl &z, const Fp6T &x, const Fp6T &y) ( Fp6T< Fp2 > & z,
const Fp6T< Fp2 > & x,
const Fp6T< Fp2 > & y ) = &(Fp6T<Fp2>::addC)

Definition at line 1338 of file bn.h.