viff

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 diff
     1.1 --- a/viff/runtime.py	Tue May 13 15:24:27 2008 +0200
     1.2 +++ b/viff/runtime.py	Tue May 13 16:08:39 2008 +0200
     1.3 @@ -39,7 +39,7 @@
     1.4  from collections import deque
     1.5  
     1.6  from viff import shamir
     1.7 -from viff.prss import prss
     1.8 +from viff.prss import prss, prss_lsb
     1.9  from viff.field import GF256, FieldElement
    1.10  from viff.matrix import Matrix, hyper
    1.11  from viff.util import wrapper, rand
    1.12 @@ -898,6 +898,26 @@
    1.13          return result
    1.14  
    1.15      @increment_pc
    1.16 +    def prss_share_bit_double(self, field):
    1.17 +        """Share a random bit over *field* and GF256."""
    1.18 +        n = self.num_players
    1.19 +        k = self.options.security_parameter
    1.20 +        prfs = self.players[self.id].prfs(2**k)
    1.21 +        prss_key = tuple(self.program_counter)
    1.22 +
    1.23 +        b_p = self.prss_share_random(field, binary=True)
    1.24 +        r_p, r_lsb = prss_lsb(n, self.id, field, prfs, prss_key)
    1.25 +
    1.26 +        b = self.open(b_p + r_p)
    1.27 +        # Extract least significant bit and change field to GF256.
    1.28 +        b.addCallback(lambda i: GF256(i.value & 1))
    1.29 +        b.field = GF256
    1.30 +
    1.31 +        # Use r_lsb to flip b as needed.
    1.32 +        return (b_p, b ^ r_lsb)
    1.33 +        
    1.34 +
    1.35 +    @increment_pc
    1.36      def _shamir_share(self, number):
    1.37          """Share a FieldElement using Shamir sharing.
    1.38