国密SM9算法对运算

基于gmp和pbc库,按照标准文档实现了一下Rate-pairing。未考虑性能和内存,单纯的验证计算步骤。
#include 
#include 

struct darray_s {
  void **item;
  int count;
  int max;
};

typedef struct darray_s darray_t[1];
typedef struct darray_s *darray_ptr;

typedef struct {
  // The coefficients are held in a darray which is resized as needed.
  // The last array entry represents the leading coefficient and should be
  // nonzero. An empty darray represents 0.
  darray_t coeff;
} *peptr;

// 摘自pbc库中F参数定义
struct f_param_s {
    mpz_t q; // Curve defined over F_q.
    mpz_t r; // The order of the curve.
    mpz_t b; // E: y^2 = x^3 + b
    mpz_t beta; //beta is a quadratic nonresidue in Fq
        //we use F_q^2 = F_q[sqrt(beta)]
    mpz_t alpha0, alpha1;
        //the polynomial x^6 + alpha0 + alpha1 sqrt(beta)
        //is irreducible over F_q^2[x], so
        //we can extend F_q^2 to F_q^12 using the
        //sixth root of -(

你可能感兴趣的:(加密算法)