國密SM9算法對運算

基於gmp和pbc庫,按照標準文檔實現了一下Rate-pairing。未考慮性能和內存,單純的驗證計算步驟。
#include <stdio.h>
#include <pbc.h>

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 -(
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章