changeset 749:65a61fc798bc

New method sharing a random bit over Zp and GF256.
author Martin Geisler <mg@daimi.au.dk>
date Tue, 13 May 2008 16:08:39 +0200
parents fac2d1f8dbe1
children b0bf45ad7dda
files viff/runtime.py
diffstat 1 files changed, 21 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/viff/runtime.py	Tue May 13 15:24:27 2008 +0200
+++ b/viff/runtime.py	Tue May 13 16:08:39 2008 +0200
@@ -39,7 +39,7 @@
 from collections import deque
 
 from viff import shamir
-from viff.prss import prss
+from viff.prss import prss, prss_lsb
 from viff.field import GF256, FieldElement
 from viff.matrix import Matrix, hyper
 from viff.util import wrapper, rand
@@ -898,6 +898,26 @@
         return result
 
     @increment_pc
+    def prss_share_bit_double(self, field):
+        """Share a random bit over *field* and GF256."""
+        n = self.num_players
+        k = self.options.security_parameter
+        prfs = self.players[self.id].prfs(2**k)
+        prss_key = tuple(self.program_counter)
+
+        b_p = self.prss_share_random(field, binary=True)
+        r_p, r_lsb = prss_lsb(n, self.id, field, prfs, prss_key)
+
+        b = self.open(b_p + r_p)
+        # Extract least significant bit and change field to GF256.
+        b.addCallback(lambda i: GF256(i.value & 1))
+        b.field = GF256
+
+        # Use r_lsb to flip b as needed.
+        return (b_p, b ^ r_lsb)
+        
+
+    @increment_pc
     def _shamir_share(self, number):
         """Share a FieldElement using Shamir sharing.