### changeset 1045:3625745e618a

author Martin Geisler Wed, 10 Dec 2008 12:42:06 +0100 ce92e62e21a8 b283e3136f61 viff/prss.py viff/test/test_util.py 2 files changed, 21 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
```--- a/viff/prss.py	Wed Dec 10 12:35:12 2008 +0100
+++ b/viff/prss.py	Wed Dec 10 12:42:06 2008 +0100
@@ -51,6 +51,7 @@

from viff import shamir
from viff.field import GF256
+from viff.util import fake

def random_replicated_sharing(j, prfs, key):
"""Return a replicated sharing of a random number.
@@ -81,6 +82,7 @@
result += share * f_in_j
return result

+@fake(lambda n, j, field, prfs, key: field(7))
def prss(n, j, field, prfs, key):
"""Return a pseudo-random secret share for a random number.

@@ -108,6 +110,7 @@
rep_shares = random_replicated_sharing(j, prfs, key)
return convert_replicated_shamir(n, j, field, rep_shares)

+@fake(lambda n, j, field, prfs, key: (field(7), GF256(1)))
def prss_lsb(n, j, field, prfs, key):
"""Share a pseudo-random number and its least significant bit.

@@ -146,6 +149,7 @@
return (convert_replicated_shamir(n, j, field, rep_shares),
convert_replicated_shamir(n, j, GF256, lsb_shares))

+@fake(lambda n, t, j, field, prfs, key: field(0))
def prss_zero(n, t, j, field, prfs, key):
"""Return a pseudo-random secret zero-sharing of degree 2t.
```
```--- a/viff/test/test_util.py	Wed Dec 10 12:35:12 2008 +0100
+++ b/viff/test/test_util.py	Wed Dec 10 12:42:06 2008 +0100
@@ -20,8 +20,9 @@
import os

from viff.util import deep_wait
-from viff.field import GF
+from viff.field import GF, GF256
import viff.shamir

from twisted.trial.unittest import TestCase
from twisted.internet.defer import Deferred
@@ -35,7 +36,7 @@

# Modules which will be reloaded with and without VIFF_FAKE set in
# the environment.
-    _modules = [viff.shamir]

def setUp(self):
self.field = GF(1031)
@@ -62,6 +63,20 @@
shares = [(1, 1), (2, 10), (3, 1)]
self.assertEquals(recombine(shares), 1)

+        self.assertEquals(share, self.field(7))
+