pairinggroup¶
- class pairinggroup.PairingGroup(param_id, param_file=False, secparam=512, verbose=False, seed1=None, seed2=None)[source]¶
Bases:
object- GetBenchmark(option)[source]¶
retrieves benchmark results for any of these options: RealTime, CpuTime, Mul, Div, Add, Sub, Exp, Pair, Granular
- StartBenchmark(options)[source]¶
starts the benchmark with any of these options: RealTime, CpuTime, Mul, Div, Add, Sub, Exp, Pair, Granular
- deserialize(obj, compression=True)[source]¶
Deserialize a bytes serialized element into a pairing object.
- Parameters:
compression – must be used for objects serialized with the compression parameter set to True. Default is True for compatibility with previous versions of charm.
- hash(args, type=charm.core.math.pairing.ZR)[source]¶
hashes objects into ZR, G1 or G2 depending on the pairing curve
- messageSize()[source]¶
after filling complete bytes with every 8 bits, any remaining 1, 2, …, 7 more bits will occupy an additional byte, even if they do not form a complete byte
- random(_type=charm.core.math.pairing.ZR, count=1, seed=None)[source]¶
selects one or more random elements in ZR, G1, G2 and GT
- serialize(obj, compression=True)[source]¶
Serialize a pairing object into bytes.
- Parameters:
compression –
- serialize the compressed representation of the
curve element, taking about half the space but potentially incurring in non-negligible computation costs when deserializing. Default is True for compatibility with previous versions of charm.
>>> p = PairingGroup('SS512') >>> v1 = p.random(G1) >>> b1 = p.serialize(v1) >>> b1 == p.serialize(v1, compression=True) True >>> v1 == p.deserialize(b1) True >>> b1 = p.serialize(v1, compression=False) >>> v1 == p.deserialize(b1, compression=False) True