JPBC部分API说明

本文深入探讨了双线性对参数生成器的概念,包括TypeA和TypeA1两种类型,详细解释了如何使用Java库jpbc和PBC生成椭圆曲线参数,适用于素数和合数双线性群。同时介绍了元素的不可变性设置和元素的导入导出方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Bilinear Pairing Parameters Generators

双线性对参数生成器

TypeA:

TypeA  参数是通过一个椭圆曲线建立起来的:y^{2}= x^{3}+x 在有限域Fp上建立的,其中q是素数q = 3 mod 4,G1 和 G2都是群上的点,椭圆曲线的阶r = q + 1。

TypeA的用例 r 是阶的位数,q是域的宽度,为素数双线性群。

import it.unisa.dia.gas.plaf.jpbc.pairing.a.TypeACurveGenerator;
import it.unisa.dia.gas.plaf.jpbc.pbc.curve.PBCTypeACurveGenerator;

int rBits = 160;
int qBits = 512;

// JPBC Type A pairing generator...
ParametersGenerator pg = new TypeACurveGenerator(rBits, qBits);
// PBC Type A pairing generator...
ParametersGenerator pbcPg = new PBCTypeACurveGenerator(rBits, qBits);

TypeA1:使用的椭圆曲线是一样的,但是在不同的有限域上,为合数双线性群。

import it.unisa.dia.gas.plaf.jpbc.pairing.a.TypeA1CurveGenerator;
import it.unisa.dia.gas.plaf.jpbc.pbc.curve.PBCTypeA1CurveGenerator;

// JPBC Type A1 pairing generator...
ParametersGenerator parametersGenerator = new TypeA1CurveGenerator(
    3,  // the number of primes
    517 // the bit length of each prime
);

// PBC Type A1 pairing generator. No parametrization in this case is possible.
// By default the generator uses two primes of 512 bit length each.
ParametersGenerator pbcPg = new PBCTypeA1CurveGenerator();
                

Make Immutable

使生成不可变的元素

/* Returns true if e is immutable, false otherwise. */

e.isImmutable();
                
/* Returns an immutable copy of e. */

Element immutable = e.getImmutable();
                

Import Export Elements

导入、导出元素

/* Converts e to bytes. The number of bytes can be determined
by calling e.getLengthInBytes(). */

byte[] bytes = e.toBytes();
                
/* To get back an Element from a byte array. */

int bytesRead = e.setFromBytes(bytes);
                
/* To get back an Element from a byte array starting from a given offset.

int bytesRead = e.setFromBytes(bytes, offset);
                
/* Sets e deterministically from a byte array.*/

e.setFromHash(bytes, 0, bytes.length);

 

 

评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值