pairinggroup

class pairinggroup.PairingGroup(param_id, param_file=False, secparam=512, verbose=False)[source]

Bases: object

EndBenchmark()[source]

ends an ongoing benchmark

GetBenchmark(option)[source]

retrieves benchmark results for any of these options: RealTime, CpuTime, Mul, Div, Add, Sub, Exp, Pair, Granular

GetGeneralBenchmarks()[source]

retrieves benchmark count for all group operations

GetGranularBenchmarks()[source]

retrieves group operation count per type: ZR, G1, G2, and GT

InitBenchmark()[source]

initiates the benchmark state

StartBenchmark(options)[source]

starts the benchmark with any of these options: RealTime, CpuTime, Mul, Div, Add, Sub, Exp, Pair, Granular

debug(data, prefix=None)[source]
decode(element)[source]
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.
encode(message)[source]
groupSetting()[source]
groupType()[source]
hash(args, type=0)[source]

hashes objects into ZR, G1 or G2 depending on the pairing curve

init(type, value=None)[source]

initializes an object with a specified type and value

ismember(obj)[source]

membership test for a pairing object

ismemberDict(obj)[source]

membership test for a dict of pairing objects

ismemberList(obj)[source]

membership test for a list of pairing objects

messageSize()[source]
order()[source]

returns the order of the group

pair_prod(lhs, rhs)[source]

takes two lists of G1 & G2 and computes a pairing product

paramgen(qbits, rbits)[source]
random(_type=0, count=1, seed=None)[source]

selects a random element 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
pairinggroup.extract_key(g)[source]

Given a group element, extract a symmetric key :param g: :return: