⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fp2.h

📁 The Stanford IBE library is a C implementation of the Boneh-Franklin identity-based encryption sche
💻 H
字号:
/* Operations in F_p^2 * header file * Ben Lynn *//*Copyright (C) 2001 Benjamin Lynn (blynn@cs.stanford.edu)See LICENSE for license*/#ifndef FP2_H#define FP2_H#include <stdio.h>#include <gmp.h>#ifdef __cplusplusextern "C" {#endif//for F_p^2 we use the representation a + sqrt(-nqr)bstruct fp2_s {    mpz_t a, b;};typedef struct fp2_s fp2_t[1];typedef struct fp2_s *fp2_ptr;//these assume the arguments are in {0,...,p-1}void zp_add(mpz_t x, mpz_t a, mpz_t b, mpz_t p);//x = a + b mod pvoid zp_neg(mpz_t x, mpz_t b, mpz_t p);//x = -b mod pvoid zp_sub(mpz_t x, mpz_t a, mpz_t b, mpz_t p);//x = a - b mod pvoid zp_mul(mpz_t x, mpz_t a, mpz_t b, mpz_t p);//x = a * b mod pvoid fp2_init(fp2_ptr x);//call before using x//allocates space for xvoid fp2_clear(fp2_ptr x);//deallocates space for xvoid fp2_set(fp2_ptr x, fp2_ptr y);//x = yvoid fp2_set_0(fp2_ptr x);//x = 0void fp2_set_1(fp2_ptr x);//x = 1void fp2_set_cbrt_unity(fp2_ptr x, mpz_t p);//x = nonunit cube root of unityvoid fp2_init_set(fp2_ptr x, fp2_ptr y);//for convenience//combines fp2_init, fp2_setvoid fp2_neg(fp2_ptr x, fp2_ptr a, mpz_t p);//x = -avoid fp2_add(fp2_ptr x, fp2_ptr a, fp2_ptr b, mpz_t p);//x = a + bvoid fp2_sub(fp2_ptr x, fp2_ptr a, fp2_ptr b, mpz_t p);//x = a - bvoid fp2_sub_ui(fp2_ptr x, fp2_ptr a, unsigned long b, mpz_t p);//x = a - bvoid fp2_sqr(fp2_ptr x, fp2_ptr a, mpz_t p);//x = a * avoid fp2_mul_mpz(fp2_ptr x, fp2_ptr a, mpz_ptr b, mpz_t p);//x = a * bvoid fp2_mul(fp2_ptr x, fp2_ptr a, fp2_ptr b, mpz_t p);//x = a * bvoid fp2_inv(fp2_ptr x, fp2_ptr b, mpz_t p);//x = 1 / bvoid fp2_div(fp2_ptr x, fp2_ptr a, fp2_ptr b, mpz_t p);//x = a / bvoid fp2_pow(fp2_ptr res, fp2_ptr x, mpz_t n, mpz_t p);//res = x^nint fp2_equal(fp2_ptr x, fp2_ptr y);//returns true if x equals y, false otherwiseint fp2_is_0(fp2_ptr x);//returns true if x equals 0, false otherwisesize_t fp2_out_str(FILE *stream, int base, fp2_ptr x);//output x on stream in base baseint fp2_set_str(fp2_t x, char *s, int base);//set value of x from s, a NULL-terminated C string, in base `base'//returns -1 on error#ifdef __cplusplus}#endif#endif //FP2_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -