changeset 1067:aff12eb0e28c

Sequential multiplication test.
author Martin Geisler <mg@daimi.au.dk>
date Tue, 27 Jan 2009 15:52:23 +0100
parents 9f176022087d
children bdab6f30511a
files apps/seq-mul.py
diffstat 1 files changed, 52 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/apps/seq-mul.py	Tue Jan 27 15:52:23 2009 +0100
@@ -0,0 +1,52 @@
+#!/usr/bin/python
+
+# Copyright 2009 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/>.
+
+from optparse import OptionParser
+from twisted.internet import reactor
+
+from viff.field import GF
+from viff.runtime import create_runtime, Runtime
+from viff.config import load_config
+
+parser = OptionParser()
+parser.add_option("-c", "--count", type="int", default=100,
+                  help="number of multiplications")
+Runtime.add_options(parser)
+(options, args) = parser.parse_args()
+
+Zp = GF(1031)
+
+id, players = load_config(args[0])
+
+def protocol(rt):
+
+    def got_result(result):
+        print "Product:", result
+        rt.shutdown()
+
+    x = rt.prss_share_random(Zp)
+    for _ in xrange(options.count):
+        x = x * x
+    x = rt.open(x)
+    x.addCallback(got_result)
+
+pre_runtime = create_runtime(id, players, 1, options)
+pre_runtime.addCallback(protocol)
+
+reactor.run()