viff

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 diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/doc/config.txt	Tue Apr 22 14:32:26 2008 +0200
     1.3 @@ -0,0 +1,18 @@
     1.4 +
     1.5 +Config Module
     1.6 +=============
     1.7 +
     1.8 +.. automodule:: viff.config
     1.9 +
    1.10 +   .. autoclass:: viff.config.Player
    1.11 +      :members: prfs, dealer_prfs
    1.12 +
    1.13 +      .. attribute:: id
    1.14 +                     host
    1.15 +                     port
    1.16 +
    1.17 +         ID, hostname, and portnumber of the player.
    1.18 +
    1.19 +   .. autofunction:: viff.config.generate_configs
    1.20 +
    1.21 +   .. autofunction:: viff.config.load_config
     2.1 --- a/doc/implementation.txt	Tue Apr 22 14:31:47 2008 +0200
     2.2 +++ b/doc/implementation.txt	Tue Apr 22 14:32:26 2008 +0200
     2.3 @@ -10,3 +10,4 @@
     2.4     shamir
     2.5     matrix
     2.6     prss
     2.7 +   config
     3.1 --- a/viff/config.py	Tue Apr 22 14:31:47 2008 +0200
     3.2 +++ b/viff/config.py	Tue Apr 22 14:32:26 2008 +0200
     3.3 @@ -22,13 +22,16 @@
     3.4  number. The player also needs to know something about itself, namely
     3.5  the keys used for pseudo-random secret sharing (PRSS).
     3.6  
     3.7 -The L{Player} class encapsulates this information. Generating a player
     3.8 -configuration is done using the L{generate_configs} function. The
     3.9 -C{apps/generate_config_files.py} script uses that function to generate
    3.10 -a player config and save it in a number of .ini files. Such a .ini
    3.11 -file can be loaded with the L{load_config} function.
    3.12 +The :class:`Player` class encapsulates this information. Generating a
    3.13 +player configuration is done using the :func:`generate_configs`
    3.14 +function. The :file:`generate_config_files.py` script uses that
    3.15 +function to generate a player config and save it in a number of
    3.16 +:file:`.ini` files. Such a :file:`.ini` file can be loaded with the
    3.17 +:func:`load_config` function.
    3.18  """
    3.19  
    3.20 +__docformat__ = "restructuredtext"
    3.21 +
    3.22  from configobj import ConfigObj
    3.23  
    3.24  from viff.prss import generate_subsets, PRF
    3.25 @@ -53,8 +56,8 @@
    3.26          of a pseudo-random secret sharing for sharing an element
    3.27          random to all players.
    3.28  
    3.29 -        @return: mapping from player subsets to L{PRF} instances.
    3.30 -        @returntype: L{dict} from L{frozenset} to L{PRF} instances.
    3.31 +        Return a mapping from player subsets to :class:`viff.prss.PRF`
    3.32 +        instances.
    3.33          """
    3.34          prfs = {}
    3.35          for subset, key in self.keys.iteritems():
    3.36 @@ -68,8 +71,8 @@
    3.37          The pseudo-random functions are used when this player is the
    3.38          dealer in a pseudo-random secret sharing.
    3.39  
    3.40 -        @return: mapping from player subsets to L{PRF} instances.
    3.41 -        @returntype: L{dict} from L{frozenset} to L{PRF} instances.
    3.42 +        Return a mapping from player subsets to :class:`viff.prss.PRF`
    3.43 +        instances.
    3.44          """
    3.45          dealers = {}
    3.46          for dealer, keys in self.dealer_keys.iteritems():
    3.47 @@ -95,8 +98,8 @@
    3.48      One of the players own the config file and for this player
    3.49      additional information on PRSS keys is available.
    3.50  
    3.51 -    @return: owner ID and a mapping of player IDs to players.
    3.52 -    @returntype: C{int}, C{dict} from C{int} to L{Player} instances.
    3.53 +    Returns the owner ID and a mapping of player IDs to
    3.54 +    :class:`Player` instances.
    3.55      """
    3.56  
    3.57      def s_unstr(str):
    3.58 @@ -149,16 +152,14 @@
    3.59  def generate_configs(n, t, addresses=None, prefix=None):
    3.60      """Generate player configurations.
    3.61  
    3.62 -    The configurations are returned as C{ConfigObj}s and can be saved
    3.63 -    to disk if desired.
    3.64 +    Generates *n* configuration objects with a threshold of *t*. The
    3.65 +    *addresses* is an optional list of ``(host, port)`` pairs and
    3.66 +    *prefix* is a filename prefix.
    3.67  
    3.68 -    @param n: number of players.
    3.69 -    @param t: threshold.
    3.70 -    @param addresses: list of (host, port) pairs.
    3.71 -    @param prefix: filename prefix.
    3.72 +    The configurations are returned as :class:`ConfigObj` instances
    3.73 +    and can be saved to disk if desired.
    3.74  
    3.75 -    @return: mapping from player id to player configuration.
    3.76 -    @returntype: C{dict} from C{int} to C{ConfigObj}.
    3.77 +    Returns a mapping from player ID to player configuration.
    3.78      """
    3.79      players = frozenset(range(1, n+1))
    3.80      max_unqualified_subsets = generate_subsets(players, n-t)