viff

changeset 1065:47fce60972ae

Easy integer coercion for FieldElement objects.
author Martin Geisler <mg@daimi.au.dk>
date Thu, 22 Jan 2009 16:55:22 +0100
parents 8bca4980563f
children 9f176022087d
files doc/field.txt viff/field.py
diffstat 2 files changed, 11 insertions(+), 1 deletions(-) [+]
line diff
     1.1 --- a/doc/field.txt	Thu Jan 08 11:31:57 2009 +0100
     1.2 +++ b/doc/field.txt	Thu Jan 22 16:55:22 2009 +0100
     1.3 @@ -7,7 +7,8 @@
     1.4     .. autoclass:: FieldElement
     1.5  
     1.6     .. autoclass:: GF256
     1.7 -      :members: __add__, __mul__, __pow__, __div__, __neg__, __invert__, __eq__, __nonzero__
     1.8 +      :members: __add__, __mul__, __pow__, __div__, __neg__,
     1.9 +                __invert__, __eq__, __nonzero__, __int__
    1.10  
    1.11        .. attribute:: GF256.modulus
    1.12  
     2.1 --- a/viff/field.py	Thu Jan 08 11:31:57 2009 +0100
     2.2 +++ b/viff/field.py	Thu Jan 22 16:55:22 2009 +0100
     2.3 @@ -74,6 +74,15 @@
     2.4  class FieldElement(object):
     2.5      """Common base class for elements."""
     2.6  
     2.7 +    def __int__(self):
     2.8 +        """Extract integer value from the field element.
     2.9 +
    2.10 +        >>> int(GF256(10))
    2.11 +        10
    2.12 +        """
    2.13 +        return self.value
    2.14 +
    2.15 +    __long__ = __int__
    2.16  
    2.17  #: Inversion table.
    2.18  #: