viff

changeset 763:216660f40d01

Another method for sharing a bit over Zp and GF256. Like ComparisonToft05Mixin.convert_bit_share, this protocol is only passively secure, but unlike that method this protocol uses only two Shamir sharings, and two openings. The other method does O(n) xor's with Zp values which is more expensive.
author Martin Geisler <mg@daimi.au.dk>
date Tue, 20 May 2008 12:53:22 +0200
parents f65816507ae8
children 6377495664f8
files viff/runtime.py
diffstat 1 files changed, 25 insertions(+), 1 deletions(-) [+]
line diff
     1.1 --- a/viff/runtime.py	Fri May 16 11:26:24 2008 +0200
     1.2 +++ b/viff/runtime.py	Tue May 20 12:53:22 2008 +0200
     1.3 @@ -915,7 +915,31 @@
     1.4  
     1.5          # Use r_lsb to flip b as needed.
     1.6          return (b_p, b ^ r_lsb)
     1.7 -        
     1.8 +
     1.9 +    @increment_pc
    1.10 +    def prss_shamir_share_bit_double(self, field):
    1.11 +        """Shamir share a random bit over *field* and GF256."""
    1.12 +        n = self.num_players
    1.13 +        k = self.options.security_parameter
    1.14 +        prfs = self.players[self.id].prfs(2**k)
    1.15 +        prss_key = tuple(self.program_counter)
    1.16 +        inputters = range(1, self.num_players + 1)
    1.17 +
    1.18 +        ri = rand.randint(0, 2**k - 1)
    1.19 +        ri_p = self.shamir_share(inputters, field, ri)
    1.20 +        ri_lsb = self.shamir_share(inputters, GF256, ri & 1)
    1.21 +
    1.22 +        r_p = reduce(self.add, ri_p)
    1.23 +        r_lsb = reduce(self.add, ri_lsb)
    1.24 +
    1.25 +        b_p = self.prss_share_random(field, binary=True)
    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      @increment_pc
    1.35      def _shamir_share(self, number):