6个版本
0.3.0 | 2021年6月1日 |
---|---|
0.2.0 | 2020年7月17日 |
0.1.3 | 2020年7月13日 |
0.1.2 | 2020年6月12日 |
#1965 in 密码学
每月36次下载
用于10个crate(直接使用2个)
17KB
369 代码行
ff-cl-gen 
基于Rust库ff的有限域算术OpenCL代码生成器。
注意
- 肢长为32/64位,由您选择。
- 该库假定您素域的最高位未设置。这允许进行便宜化简。
用法
为Bls12-381 Fr元素生成OpenCL代码
use paired::bls12_381::Fr;
let src = ff_cl_gen::field::<Fr, Limb64>("Fr");
生成的接口(FIELD
被替换为Fr
)
#define FIELD_LIMB_BITS ... // 32/64
#define FIELD_limb ... // uint/ulong, based on FIELD_LIMB_BITS
#define FIELD_LIMBS ... // Number of limbs for this field
#define FIELD_P ... // Normal form of field modulus
#define FIELD_ONE ... // Montomery form of one
#define FIELD_ZERO ... // Montomery/normal form of zero
#define FIELD_BITS (FIELD_LIMBS * FIELD_LIMB_BITS)
typedef struct { FIELD_limb val[FIELD_LIMBS]; } FIELD;
bool FIELD_gte(FIELD a, FIELD b); // Greater than or equal
bool FIELD_eq(FIELD a, FIELD b); // Equal
FIELD FIELD_sub(FIELD a, FIELD b); // Modular subtraction
FIELD FIELD_add(FIELD a, FIELD b); // Modular addition
FIELD FIELD_mul(FIELD a, FIELD b); // Modular multiplication
FIELD FIELD_sqr(FIELD a); // Modular squaring
FIELD FIELD_double(FIELD a); // Modular doubling
FIELD FIELD_pow(FIELD base, uint exponent); // Modular power
FIELD FIELD_pow_lookup(global FIELD *bases, uint exponent); // Modular power with lookup table for bases
FIELD FIELD_mont(FIELD a); // To montgomery form
FIELD FIELD_unmont(FIELD a); // To regular form
bool FIELD_get_bit(FIELD l, uint i); // Get `i`th bit (From most significant digit)
uint FIELD_get_bits(FIELD l, uint skip, uint window); // Get `window` consecutive bits, (Starting from `skip`th bit from most significant digit)
许可证
根据您的选择,许可为以下之一
- Apache许可证2.0版(LICENSE-APACHE或https://apache.ac.cn/licenses/LICENSE-2.0)
- MIT许可证(LICENSE-MIT或http://opensource.org/licenses/MIT)
。
贡献
除非您明确声明,否则您有意提交以包含在作品中的任何贡献,根据Apache-2.0许可证定义,应作为上述双重许可,不附加任何额外条款或条件。
依赖关系
~1.1–1.7MB
~34K SLoC