viff

changeset 701:2acd3ae55565

Converted viff.field to ReST format for Sphinx.
author Martin Geisler <mg@daimi.au.dk>
date Tue, 22 Apr 2008 11:55:18 +0200
parents 4df225223500
children 5df62a47e9c5
files doc/field.txt doc/implementation.txt doc/index.txt viff/field.py
diffstat 4 files changed, 70 insertions(+), 23 deletions(-) [+]
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/doc/field.txt	Tue Apr 22 11:55:18 2008 +0200
     1.3 @@ -0,0 +1,42 @@
     1.4 +
     1.5 +Finite Fields Module
     1.6 +====================
     1.7 +
     1.8 +.. automodule:: viff.field
     1.9 +
    1.10 +.. autoclass:: viff.field.FieldElement
    1.11 +
    1.12 +.. autoclass:: viff.field.GF256
    1.13 +
    1.14 +   .. attribute:: GF256.modulus
    1.15 +
    1.16 +      Field modulus, always 256.
    1.17 +
    1.18 +   .. automethod:: GF256.__add__
    1.19 +
    1.20 +   .. method:: GF256.__sub__(other)
    1.21 +               GF256.__xor__(other)
    1.22 +
    1.23 +      Subtraction and exclusive-or. Since GF(2^8) has characteristic
    1.24 +      2, these two operations are identical to addition.
    1.25 +
    1.26 +   .. automethod:: GF256.__mul__
    1.27 +
    1.28 +   .. automethod:: GF256.__pow__
    1.29 +
    1.30 +   .. automethod:: GF256.__div__
    1.31 +
    1.32 +   .. automethod:: GF256.__neg__
    1.33 +
    1.34 +   .. automethod:: GF256.__invert__
    1.35 +
    1.36 +   .. automethod:: GF256.__str__
    1.37 +
    1.38 +   .. automethod:: GF256.__eq__
    1.39 +
    1.40 +   .. automethod:: GF256.__hash__
    1.41 +
    1.42 +   .. automethod:: GF256.__nonzero__
    1.43 +
    1.44 +
    1.45 +.. autofunction:: viff.field.GF
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/doc/implementation.txt	Tue Apr 22 11:55:18 2008 +0200
     2.3 @@ -0,0 +1,9 @@
     2.4 +
     2.5 +Implementation
     2.6 +==============
     2.7 +
     2.8 +VIFF consists of several modules which will be described next.
     2.9 +
    2.10 +.. toctree::
    2.11 +
    2.12 +   field
     3.1 --- a/doc/index.txt	Tue Apr 22 08:46:45 2008 +0200
     3.2 +++ b/doc/index.txt	Tue Apr 22 11:55:18 2008 +0200
     3.3 @@ -13,6 +13,7 @@
     3.4  
     3.5     overview
     3.6     install
     3.7 +   implementation
     3.8     glossary
     3.9  
    3.10  
     4.1 --- a/viff/field.py	Tue Apr 22 08:46:45 2008 +0200
     4.2 +++ b/viff/field.py	Tue Apr 22 11:55:18 2008 +0200
     4.3 @@ -18,8 +18,8 @@
     4.4  """Modeling of Galois (finite) fields.
     4.5  
     4.6  The GF function creates classes which implements Galois (finite)
     4.7 -fields of prime order whereas the GF256 class implements the the
     4.8 -GF(2^8) field with characteristic 2.
     4.9 +fields of prime order whereas the :class:`GF256` class implements the
    4.10 +the GF(2^8) field with characteristic 2.
    4.11  
    4.12  All fields work the same: instantiate an object from a field to get
    4.13  hold of an element of that field. Elements implement the normal
    4.14 @@ -47,7 +47,7 @@
    4.15  {12}
    4.16  
    4.17  Square roots can be found for elements based on GF fields with a Blum
    4.18 -prime modulus (see L{GF} for more information):
    4.19 +prime modulus (see :func:`GF` for more information):
    4.20  
    4.21  >>> x.sqrt()
    4.22  {3}
    4.23 @@ -62,10 +62,13 @@
    4.24      ...
    4.25  TypeError: unsupported operand type(s) for +: 'GFElement' and 'GFElement'
    4.26  
    4.27 -The reason for the slightly confusing error message is that C{x} and
    4.28 -C{z} are instances of two I{different} classes called C{GFElement}.
    4.29 +The reason for the slightly confusing error message is that ``x`` and
    4.30 +``z`` are instances of two *different* classes called ``GFElement``.
    4.31  """
    4.32  
    4.33 +__docformat__ = "restructuredtext"
    4.34 +
    4.35 +
    4.36  from gmpy import mpz
    4.37  
    4.38  
    4.39 @@ -75,15 +78,15 @@
    4.40  
    4.41  #: Logarithm table.
    4.42  #:
    4.43 -#: Maps a value M{x} to M{log3(x)}. See L{_generate_tables}.
    4.44 +#: Maps a value *x* to *log3(x)*. See `_generate_tables`.
    4.45  _log_table = {}
    4.46  #: Exponentiation table.
    4.47  #:
    4.48 -#: Maps a value M{y} to M{3^y}. See L{_generate_tables}.
    4.49 +#: Maps a value *y* to *3^y*. See `_generate_tables`.
    4.50  _exp_table = {}
    4.51  #: Inversion table.
    4.52  #:
    4.53 -#: Maps a value M{x} to M{x^-1}. See L{_generate_tables}.
    4.54 +#: Maps a value *x* to *x^-1*. See `_generate_tables`.
    4.55  _inv_table = {}
    4.56  
    4.57  
    4.58 @@ -91,10 +94,10 @@
    4.59      """Generate tables with logarithms, antilogarithms (exponentials)
    4.60      and inverses.
    4.61  
    4.62 -    This updates the L{_log_table}, L{_exp_table}, and L{_inv_table}
    4.63 -    fields. The generator used is 0x03.
    4.64 +    This updates the `_log_table`, `_exp_table`, and `_inv_table`
    4.65 +    fields. The generator used is ``0x03``.
    4.66  
    4.67 -    Code adapted from U{http://www.samiam.org/galois.html}.
    4.68 +    Code adapted from http://www.samiam.org/galois.html.
    4.69      """
    4.70      a = 1
    4.71      for c in range(255):
    4.72 @@ -164,7 +167,7 @@
    4.73      #: Subtract this and another GF256 element.
    4.74      #:
    4.75      #: Addition is its own inverse in GF(2^8) and so this is the same
    4.76 -    #: as L{__add__}.
    4.77 +    #: as `__add__`.
    4.78      __sub__ = __add__
    4.79      #: Subtract this and another GF256 element (reflected argument version).
    4.80      __rsub__ = __sub__
    4.81 @@ -209,22 +212,14 @@
    4.82          return result
    4.83  
    4.84      def __div__(self, other):
    4.85 -        """Division.
    4.86 -
    4.87 -        @param other: right-hand side.
    4.88 -        @type other: GF256 element
    4.89 -        """
    4.90 +        """Division."""
    4.91          return self * ~other
    4.92  
    4.93      __truediv__ = __div__
    4.94      __floordiv__ = __div__
    4.95  
    4.96      def __rdiv__(self, other):
    4.97 -        """Division (reflected argument version).
    4.98 -
    4.99 -        @param other: the left-hand side.
   4.100 -        @type other: integer
   4.101 -        """
   4.102 +        """Division (reflected argument version)."""
   4.103          return GF256(other) / self
   4.104  
   4.105      __rtruediv__ = __rdiv__
   4.106 @@ -237,7 +232,7 @@
   4.107      def __invert__(self):
   4.108          """Invertion.
   4.109  
   4.110 -        @raise ZeroDivisionError: if trying to inverse the zero
   4.111 +        Raises :exc:`ZeroDivisionError` if trying to inverse the zero
   4.112          element.
   4.113          """
   4.114          if self.value == 0: