Bilinear Pairing Parameters Generators
双线性对参数生成器
TypeA:
TypeA 参数是通过一个椭圆曲线建立起来的: 在有限域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);