ffrs.GF256#
- class ffrs.GF256#
Finite-field operations optimized for \(GF(2^8)\)
Methods
Instantiate type for operations over \(GF(p^n)/P\)
Addition: \(\text{lhs} + \text{rhs}\)
Division: \(\frac{\text{num}}{\text{den}}\)
Exponential function: \(a^{\text{value}}\)
Reciprocal: \(\frac{1}{\text{value}}\)
Logarithm: \(\log_a (\text{value})\)
Multiplication: \(\text{lhs} \times \text{rhs}\)
Multiply 8 values in a single operation
Add polynomials
Polynomial quotient and remainder
Evaluate polynomial at
xEvaluate polynomial at 8 points on a single operation
Polynomial remainder
Shifted polynomial remainder
Multiply polynomials
Subtract polynomials
Power: \(\text{base}^\text{exponent}\)
Subtraction: \(\text{lhs} - \text{rhs}\)
Attributes
GF256.field_elementsAlways 256
GF256.poly1Masked irreducible polynomial, excluding MSb
GF256.powerAlways 8
GF256.primeAlways 2
GF256.primitivePrimitive value used to generate the field
- __init__(self: ffrs.GF256, primitive: int = 2, poly1: int = 285) None#
Instantiate type for operations over \(GF(p^n)/P\)
- Parameters:
primitive – \(a\) – primitive value used to generate the field
polynomial – \(P\) – irreducible polynomial used to generate the field
- add(self: ffrs.GF256, lhs: int, rhs: int) int#
Addition: \(\text{lhs} + \text{rhs}\)
- div(self: ffrs.GF256, num: int, den: int) int#
Division: \(\frac{\text{num}}{\text{den}}\)
- exp(self: ffrs.GF256, value: int) int#
Exponential function: \(a^{\text{value}}\)
- inv(self: ffrs.GF256, value: int) int#
Reciprocal: \(\frac{1}{\text{value}}\)
- log(self: ffrs.GF256, value: int) int#
Logarithm: \(\log_a (\text{value})\)
- mul(self: ffrs.GF256, lhs: int, rhs: int) int#
Multiplication: \(\text{lhs} \times \text{rhs}\)
- mul8(self: ffrs.GF256, a: Buffer, b: Buffer) bytearray#
Multiply 8 values in a single operation
- poly_add(self: ffrs.GF256, p1: Buffer, p2: Buffer) bytearray#
Add polynomials
- poly_divmod(self: ffrs.GF256, p1: Buffer, p2: Buffer) tuple#
Polynomial quotient and remainder
- Returns:
(quotient, remainder)
- poly_eval(self: ffrs.GF256, poly: Buffer, x: int) int#
Evaluate polynomial at
x
- poly_eval8(self: ffrs.GF256, poly: Buffer, xs: Buffer) bytearray#
Evaluate polynomial at 8 points on a single operation
- poly_mod(self: ffrs.GF256, p1: Buffer, p2: Buffer) bytearray#
Polynomial remainder
- poly_mod_x_n(self: ffrs.GF256, p1: Buffer, p2: Buffer) bytearray#
Shifted polynomial remainder
\(P \times X^n \mod (X^n + p_2)\) where
n = len(p2)
- poly_mul(self: ffrs.GF256, p1: Buffer, p2: Buffer) bytearray#
Multiply polynomials
- poly_sub(self: ffrs.GF256, p1: Buffer, p2: Buffer) bytearray#
Subtract polynomials
- pow(self: ffrs.GF256, base: int, exponent: int) int#
Power: \(\text{base}^\text{exponent}\)
- sub(self: ffrs.GF256, lhs: int, rhs: int) int#
Subtraction: \(\text{lhs} - \text{rhs}\)