def sim(g, msg, pks, sk, p_id, v_id): a_list = [] r_list = [] h_list = [] for i in range(len(pks)): if i == v_id: a_list.append(None) r_list.append(None) h_list.append(None) else: a_i = Fr() a_i.set_by_CSPRNG() a_list.append(a_i) r_i = g * a_i r_list.append(r_i) h_i = Fr.set_hash_of(f"{msg}{r_i.getStr()}") h_list.append(h_i) a = Fr() a.set_by_CSPRNG() r = (g * a) + reduce( operator.add, [pks[i] * h_list[i].neg() for i in range(len(pks)) if i != v_id]) h = Fr.set_hash_of(f"{msg}{r.getStr()}") s = reduce( operator.add, [a_list[i] + a + (sk * h) for i in range(len(pks)) if i != v_id]) r_list[v_id] = r * sk return (r_list, s)
def sign(g, msg, pks, sk, p_id, v_id): a_list = [] r_list = [] h_list = [] for i in range(len(pks)): if i == p_id: a_list.append(None) r_list.append(None) h_list.append(None) else: a_i = Fr() a_i.set_by_CSPRNG() a_list.append(a_i) r_i = g * a_i r_list.append(r_i) h_i = Fr.set_hash_of(f"{msg}{r_i.getStr()}") h_list.append(h_i) a = Fr() a.set_by_CSPRNG() r_list[p_id] = (g * a) + reduce( operator.add, [pks[i] * h_list[i].neg() for i in range(len(pks)) if i != p_id]) h = Fr.set_hash_of(f"{msg}{r_list[p_id].getStr()}") s = reduce( operator.add, [a_list[i] + a + (sk * h) for i in range(len(pks)) if i != p_id]) r_list[v_id] = pks[v_id] * a_list[v_id] g_hat = G2.hashAndMapToG2(f'{msg}{r_list}{pks}') S = g_hat * s return (r_list, S)
def verify(g, msg, pks, sk, p_id, v_id, R, S): g_hat = G2.hashAndMapToG2(f'{msg}{R}{pks}') R[v_id] = R[v_id] * sk.inv() h_list = [] for i in range(len(pks)): h_i = Fr.set_hash_of(f"{msg}{R[i].getStr()}") h_list.append(h_i) prod = R[v_id] + (pks[v_id] * h_list[v_id]) for i in range(len(pks)): if i == v_id: continue else: prod += R[i] + (pks[i] * h_list[i]) assert pairing(g, S) == pairing(prod, g_hat)
def verify(g, msg, pks, sk, p_id, v_id, R, s): R[v_id] = R[v_id] * sk.inv() h_list = [Fr.set_hash_of(f"{msg}{R[i].getStr()}") for i in range(len(pks))] prod = reduce(operator.add, [R[i] + (pks[i] * h_list[i]) for i in range(len(pks))]) assert g * s == prod