# HG changeset patch
# User Martin Geisler <[EMAIL PROTECTED]>
# Date 1214740772 -7200
# Node ID 1020d7a99606dec7875ff0f25d3e3c3d3d001d15
# Parent  b10ab58865eb96c641fe028f201bce57b23933fe
Test program for Paillier runtime.

diff --git a/apps/paillier.py b/apps/paillier.py
new file mode 100755
--- /dev/null
+++ b/apps/paillier.py
@@ -0,0 +1,62 @@
+#!/usr/bin/python
+
+# Copyright 2008 VIFF Development Team.
+#
+# This file is part of VIFF, the Virtual Ideal Functionality Framework.
+#
+# VIFF is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License (LGPL) as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# VIFF is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
+# Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with VIFF. If not, see <http://www.gnu.org/licenses/>.
+
+import sys
+
+from twisted.internet import reactor
+
+from viff.field import GF
+from viff.runtime import create_runtime, Share
+from viff.paillier import PaillierRuntime
+from viff.config import load_config
+from viff.util import dprint, find_prime
+
+id, players = load_config(sys.argv[1])
+Zp = GF(find_prime(2**64))
+input = int(sys.argv[2])
+
+print "I am player %d and will input %s" % (id, input)
+
+
+def protocol(runtime):
+    print "-" * 64
+    print "Program started"
+    print
+
+    a, b = runtime.share([1, 2], Zp, input)
+
+    dprint("a%d: %s", runtime.id, a)
+    dprint("b%d: %s", runtime.id, b)
+
+    c = a * b
+    #a = runtime.open(a)
+    #b = runtime.open(b)
+    c = runtime.open(c)
+
+    #dprint("### opened a: %s ###", a)
+    #dprint("### opened b: %s ###", b)
+    dprint("### opened c: %s ###", c)
+
+    runtime.wait_for(a, b, c)
+
+pre_runtime = create_runtime(id, players, 1, runtime_class=PaillierRuntime)
+pre_runtime.addCallback(protocol)
+
+print "#### Starting reactor ###"
+reactor.run()
_______________________________________________
viff-patches mailing list
[email protected]
http://lists.viff.dk/listinfo.cgi/viff-patches-viff.dk

Reply via email to