def init(self, kappa): group = PairingGroup(kappa) p, g1 = (group.order(), group.random(G1)) x1, x2, y1, y2 = [group.random(ZR) for i in range(4)] g2 = g1**(x1 / x2) z = g1**x1 u1 = g1**y1 u2 = g2**y2 setup.GetKeypairs()
def __init__(self, kappa): group = PairingGroup(kappa) p, g1 = (group.order(), group.random(G1)) x1, x2, y1, y2 = [group.random(ZR) for i in range(4)] g2 = g1**(x1 / x2) z = g1**x1 u1 = g1**y1 u2 = g2**y2 self.pk = PublicKeys(group, p, g1, g2, z, u1, u2) self.sk = PrivateKeys(x1, x2, y1, y2)
def init(): group = PairingGroup('SS512') g = group.random(G1) h = group.random(ZR) gh = g**h p = group.order() pp = [g, h, gh, p] sg = group.serialize(g) sh = group.serialize(h) sgh = group.serialize(gh) pp = [sg, sh, sgh, p] np.save("groupParameter", pp) return pp
def setup(n, group_name = 'MNT159', simulated = False): """ Performs the setup algorithm for IPE. This function samples the generators from the group, specified optionally by "group_name". This variable must be one of a few set of strings specified by Charm. Then, it invokes the C program ./gen_matrices, which samples random matrices and outputs them back to this function. The dimension n is supplied, and the prime is chosen as the order of the group. Additionally, /dev/urandom is sampled for a random seed which is passed to ./gen_matrices. Finally, the function constructs the matrices that form the secret key and publishes the pulbic marapeters and secret key (pp, sk). """ group = PairingGroup(group_name) g1 = group.random(G1) g2 = group.random(G2) assert g1.initPP(), "ERROR: Failed to init pre-computation table for g1." assert g2.initPP(), "ERROR: Failed to init pre-computation table for g2." proc = Popen( [ os.path.dirname(os.path.realpath(__file__)) + '/gen_matrices', str(n), str(group.order()), "1" if simulated else "0", "" ], stdout=PIPE ) detB_str = proc.stdout.readline().decode() B_str = proc.stdout.readline().decode() Bstar_str = proc.stdout.readline().decode() detB = int(detB_str) B = parse_matrix(B_str, group) Bstar = parse_matrix(Bstar_str, group) pp = () sk = (detB, B, Bstar, group, g1, g2) return (pp, sk)
def setup(n, group_name='MNT159', simulated=False): """ Performs the setup algorithm for IPE. This function samples the generators from the group, specified optionally by "group_name". This variable must be one of a few set of strings specified by Charm. Then, it invokes the C program ./gen_matrices, which samples random matrices and outputs them back to this function. The dimension n is supplied, and the prime is chosen as the order of the group. Additionally, /dev/urandom is sampled for a random seed which is passed to ./gen_matrices. Finally, the function constructs the matrices that form the secret key and publishes the public parameters and secret key (pp, sk). """ group = PairingGroup(group_name) g1 = group.random(G1) g2 = group.random(G2) assert g1.initPP(), "ERROR: Failed to init pre-computation table for g1." assert g2.initPP(), "ERROR: Failed to init pre-computation table for g2." proc = Popen([ os.path.dirname(os.path.realpath(__file__)) + '/gen_matrices', str(n), str(group.order()), "1" if simulated else "0", "" ], stdout=PIPE) detB_str = proc.stdout.readline().decode() B_str = proc.stdout.readline().decode() Bstar_str = proc.stdout.readline().decode() detB = int(detB_str) B = parse_matrix(B_str, group) Bstar = parse_matrix(Bstar_str, group) pp = () sk = (detB, B, Bstar, group, g1, g2) return (pp, sk)