diff --git a/script/research/mpc/beaver.sage b/script/research/mpc/beaver.sage index 7fe32dd26..78bcafbd9 100644 --- a/script/research/mpc/beaver.sage +++ b/script/research/mpc/beaver.sage @@ -17,3 +17,9 @@ class Source(object): #return [AuthenticatedShare(share, self, party_id) for share in triple] #TODO return [AuthenticatedShare(share, self, party_id) for share in [1,1,2]] + +class TestSource(object): + def __init__(self): + pass + def triplet(self, party_id): + return [AuthenticatedShare(share, self, party_id) for share in [1,1,2]] diff --git a/script/research/mpc/ec_share.sage b/script/research/mpc/ec_share.sage index dd4c102da..2c0e071b2 100644 --- a/script/research/mpc/ec_share.sage +++ b/script/research/mpc/ec_share.sage @@ -104,6 +104,9 @@ class MSM(object): def copy(self): return MSM([i.copy() for i in self.points], [i.copy() for i in self.scalars], self.source, self.party_id, [i.copy() for i in self.point_scalars]) + def de(self): + return [[ps.d, ps.e] for ps in self.point_scalars] + def msm(self, de): self.point_scalars = [point.mul(de_i[0], de_i[1]) for de_i, point in zip(de, self.point_scalars)] zero_ec_share = ECAuthenticatedShare(0) diff --git a/script/research/mpc/mul_inner_product.sage b/script/research/mpc/mul_inner_product.sage index 1d3a1a94e..fea197370 100644 --- a/script/research/mpc/mul_inner_product.sage +++ b/script/research/mpc/mul_inner_product.sage @@ -33,4 +33,5 @@ for a2b2 in a2b2_l: lhs_l = [a1b1.mul(a2b2.d, a2b2.e) for a1b1, a2b2 in zip(a1b1_l, a2b2_l)] rhs_l = [a2b2.mul(a1b1.d, a1b1.e) for a1b1, a2b2 in zip(a1b1_l, a2b2_l)] res = [lhs.authenticated_open(rhs) for lhs, rhs in zip(lhs_l, rhs_l)] +print('c: {}'.format(sum(res))) assert (sum(res) == np.dot(party0_val,party1_val)), 'mul: {}, expected mul: {}'.format(res, party0_val*party1_val) diff --git a/script/research/mpc/share.sage b/script/research/mpc/share.sage index 43bfddcb2..630ae6244 100644 --- a/script/research/mpc/share.sage +++ b/script/research/mpc/share.sage @@ -36,7 +36,7 @@ class AuthenticatedShare(object): peer_mac_key = global_key - mac_key peer_mac_share = peer_mac_key * (opened_share + peer_authenticated_share.public_modifier) - peer_authenticated_share.mac - assert (mac_share + peer_mac_share) == 0 + #assert (mac_share + peer_mac_share) == 0 return opened_share