changeset 708:adbbc93b4622

Sphinx documentation for viff.config.
author Martin Geisler <mg@daimi.au.dk>
date Tue, 22 Apr 2008 14:32:26 +0200
parents a68d36c5cce5
children 0155489179f0 040e559b06a0
files doc/config.txt doc/implementation.txt viff/config.py
diffstat 3 files changed, 39 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/config.txt	Tue Apr 22 14:32:26 2008 +0200
@@ -0,0 +1,18 @@
+
+Config Module
+=============
+
+.. automodule:: viff.config
+
+   .. autoclass:: viff.config.Player
+      :members: prfs, dealer_prfs
+
+      .. attribute:: id
+                     host
+                     port
+
+         ID, hostname, and portnumber of the player.
+
+   .. autofunction:: viff.config.generate_configs
+
+   .. autofunction:: viff.config.load_config
--- a/doc/implementation.txt	Tue Apr 22 14:31:47 2008 +0200
+++ b/doc/implementation.txt	Tue Apr 22 14:32:26 2008 +0200
@@ -10,3 +10,4 @@
    shamir
    matrix
    prss
+   config
--- a/viff/config.py	Tue Apr 22 14:31:47 2008 +0200
+++ b/viff/config.py	Tue Apr 22 14:32:26 2008 +0200
@@ -22,13 +22,16 @@
 number. The player also needs to know something about itself, namely
 the keys used for pseudo-random secret sharing (PRSS).
 
-The L{Player} class encapsulates this information. Generating a player
-configuration is done using the L{generate_configs} function. The
-C{apps/generate_config_files.py} script uses that function to generate
-a player config and save it in a number of .ini files. Such a .ini
-file can be loaded with the L{load_config} function.
+The :class:`Player` class encapsulates this information. Generating a
+player configuration is done using the :func:`generate_configs`
+function. The :file:`generate_config_files.py` script uses that
+function to generate a player config and save it in a number of
+:file:`.ini` files. Such a :file:`.ini` file can be loaded with the
+:func:`load_config` function.
 """
 
+__docformat__ = "restructuredtext"
+
 from configobj import ConfigObj
 
 from viff.prss import generate_subsets, PRF
@@ -53,8 +56,8 @@
         of a pseudo-random secret sharing for sharing an element
         random to all players.
 
-        @return: mapping from player subsets to L{PRF} instances.
-        @returntype: L{dict} from L{frozenset} to L{PRF} instances.
+        Return a mapping from player subsets to :class:`viff.prss.PRF`
+        instances.
         """
         prfs = {}
         for subset, key in self.keys.iteritems():
@@ -68,8 +71,8 @@
         The pseudo-random functions are used when this player is the
         dealer in a pseudo-random secret sharing.
 
-        @return: mapping from player subsets to L{PRF} instances.
-        @returntype: L{dict} from L{frozenset} to L{PRF} instances.
+        Return a mapping from player subsets to :class:`viff.prss.PRF`
+        instances.
         """
         dealers = {}
         for dealer, keys in self.dealer_keys.iteritems():
@@ -95,8 +98,8 @@
     One of the players own the config file and for this player
     additional information on PRSS keys is available.
 
-    @return: owner ID and a mapping of player IDs to players.
-    @returntype: C{int}, C{dict} from C{int} to L{Player} instances.
+    Returns the owner ID and a mapping of player IDs to
+    :class:`Player` instances.
     """
 
     def s_unstr(str):
@@ -149,16 +152,14 @@
 def generate_configs(n, t, addresses=None, prefix=None):
     """Generate player configurations.
 
-    The configurations are returned as C{ConfigObj}s and can be saved
-    to disk if desired.
+    Generates *n* configuration objects with a threshold of *t*. The
+    *addresses* is an optional list of ``(host, port)`` pairs and
+    *prefix* is a filename prefix.
 
-    @param n: number of players.
-    @param t: threshold.
-    @param addresses: list of (host, port) pairs.
-    @param prefix: filename prefix.
+    The configurations are returned as :class:`ConfigObj` instances
+    and can be saved to disk if desired.
 
-    @return: mapping from player id to player configuration.
-    @returntype: C{dict} from C{int} to C{ConfigObj}.
+    Returns a mapping from player ID to player configuration.
     """
     players = frozenset(range(1, n+1))
     max_unqualified_subsets = generate_subsets(players, n-t)