Commit e45a6a1a authored by root's avatar root
Browse files

Bug fixes

parent c9062953
......@@ -806,7 +806,7 @@ def redeem(points):
exit()
com_list = reader_k.prepare_committed_record(
# [db_size, reader_k.l_store[0]["x"][db_size]]
# [db_size, reader_k.l_store[0]["x"][db_size]]
[db_size]
)
p = reader_k.read(sid, p, com_list)
......@@ -868,9 +868,7 @@ def profile(start, end, val):
)
for i in range(start, end + 1):
com_list = reader_k.prepare_committed_record(
[i]
)
com_list = reader_k.prepare_committed_record([i])
p = reader_k.read(sid, p, com_list)
updater.update(sid, p, empty_db_list)
......
......@@ -282,7 +282,7 @@ class FZK_RD:
(self.public_key, self.secret_key) = self.paillier_encryption.keygen(
self.keylength
)
(c,y) = SigmaProtocol.range_proof(
(c, y) = SigmaProtocol.range_proof(
(v_n - points), com_v_n, open_v_n, points, ped_g, ped_h, group
)
v_n_c = self.paillier_encryption.encrypt(
......@@ -448,9 +448,7 @@ class FZK_PR3:
s_ppe = 1
for instance_record in instance_pr:
witness_record = get_record_by_i(
instance_record["i"], witness_pr
)
witness_record = get_record_by_i(instance_record["i"], witness_pr)
random_v, random_opening_v = group.random(ZR), group.random(ZR)
y_list.append(
{
......@@ -520,9 +518,11 @@ class FZK_PR3:
"penco": paillier_ciphertext_open_v,
}
)
paillier_ciphertext_random_open_v = self.paillier_encryption.encrypt(
self.public_key,
integer(SHA256(bytes(str(random_opening_v), "utf-8"))),
paillier_ciphertext_random_open_v = (
self.paillier_encryption.encrypt(
self.public_key,
integer(SHA256(bytes(str(random_opening_v), "utf-8"))),
)
)
paillier_ciphertext_random_v = self.paillier_encryption.encrypt(
self.public_key, integer(SHA256(bytes(str(random_v), "utf-8")))
......@@ -540,12 +540,7 @@ class FZK_PR3:
if not (
(
get_record_by_i(witness_record["i"], t_list)["e"]
* (
get_record_by_i(witness_record["i"], y_list)[
"e"
]
)
** c
* (get_record_by_i(witness_record["i"], y_list)["e"]) ** c
)
== ((pair(ped_g, gt) ** s_v) * (pair(ped_h, gt) ** s_o_v))
):
......@@ -691,9 +686,7 @@ class FZK_PR3:
ped_h = par_c["h"]
for witness_record in witness_pr:
open_i = witness_record["openi"]
com_i = get_record_by_i(witness_record["i"], instance_pr)[
"comi"
]
com_i = get_record_by_i(witness_record["i"], instance_pr)["comi"]
SigmaProtocol.range_proof(
(witness_record["i"] - end) + 1000,
com_i,
......
......@@ -33,17 +33,20 @@ def get_record_by_index(index, list):
if item["index"] == index:
return item
def get_record_by_i(index, list):
for item in list:
if item["i"] == index:
return item
def generate_n_random_exponents(n):
exponents = []
for i in range(0, n):
exponents.append(pairing_group.random(ZR))
return exponents
def num_to_str(num, length):
str_num = str(num)
if len(str_num) < length:
......@@ -363,7 +366,12 @@ class SigmaProtocol:
),
)
hash_random_i, hash_random_vr, hash_random_copen_i, hash_random_copen_ri = (
(
hash_random_i,
hash_random_vr,
hash_random_copen_i,
hash_random_copen_ri,
) = (
integer(
SHA256(bytes(str(random_subwitness_record["i"]), "utf-8"))
),
......@@ -417,7 +425,13 @@ class SigmaProtocol:
s_o_j = ZKWitness()
random_opening_1, random_opening_2, random_opening_3, random_opening_4, random_opening_5 = (
(
random_opening_1,
random_opening_2,
random_opening_3,
random_opening_4,
random_opening_5,
) = (
random_integer_openings["d1"],
random_integer_openings["d2"],
random_integer_openings["d3"],
......@@ -1243,7 +1257,9 @@ class SigmaProtocol:
witness_integer_openings,
)
def verifier_step_1(self,):
def verifier_step_1(
self,
):
return pairing_group.random(ZR)
def verifier_step_2(
......@@ -1499,4 +1515,4 @@ class SigmaProtocol:
* ((ped_g ** ((10 ** 3) * z_s_3)))
):
print("Abort: (FZK_PR) D check failed.")
return c , y
\ No newline at end of file
return c, y
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment