Finite Fields
Module Contents
Classes
A type protocol for defining fields. |
|
Superclass for integers modulo a prime. Not intended to be used |
|
Superclass for defining finite fields. Not intended to be used |
Attributes
Module Details
F
- F
F = TypeVar("F", bound="Field")
Field
A type protocol for defining fields.
T
- T
T = TypeVar("T", bound="PrimeField")
PrimeField
Superclass for integers modulo a prime. Not intended to be used directly, but rather to be subclassed.
- class PrimeField
Bases:
int,Field- __slots__ = []
- PRIME :int
- __floordiv__
- __rfloordiv__
- __ifloordiv__
- __divmod__
- __rdivmod__
- __rpow__
- __and__
- __or__
- __xor__
- __rxor__
- __ixor__
- __rshift__
- __lshift__
- __irshift__
- __ilshift__
- classmethod from_be_bytes(buffer: ethereum.base_types.Bytes) → T
Converts a sequence of bytes into a element of the field. :param buffer: Bytes to decode.
- Returns
self – Unsigned integer decoded from buffer.
- Return type
T
- to_be_bytes32() → ethereum.base_types.Bytes32
Converts this arbitrarily sized unsigned integer into its big endian representation with exactly 32 bytes. :returns: big_endian – Big endian (most significant bits first) representation. :rtype: Bytes32
U
- U
U = TypeVar("U", bound="GaloisField")
GaloisField
Superclass for defining finite fields. Not intended to be used directly, but rather to be subclassed.
Fields are represented as F_p[x]/(x^n + …) where the MODULUS is a tuple of the non-leading coefficients of the defining polynomial. For example x^3 + 2x^2 + 3x + 4 is (2, 3, 4).
In practice the polynomial is likely to be be sparse and you should overload the __mul__() function to take advantage of this fact.
- class GaloisField
Bases:
tuple,Field- __slots__ = []
- PRIME :int
- MODULUS :Tuple[int, Ellipsis]
- FROBENIUS_COEFFICIENTS :Tuple[GaloisField, Ellipsis]
- scalar_mul(x: int) → U
Multiply a field element by a integer. This is faster than using from_int() and field multiplication.
- deg() → int
This is a support function for multiplicative_inverse().