3.0.ipv8.attestation.wallet.primitives.value ============================================ .. py:module:: 3.0.ipv8.attestation.wallet.primitives.value Classes ------- .. autoapisummary:: 3.0.ipv8.attestation.wallet.primitives.value.FP2Value Functions --------- .. autoapisummary:: 3.0.ipv8.attestation.wallet.primitives.value.format_polynomial Module Contents --------------- .. py:function:: format_polynomial(a: int, b: int, c: int) -> str Formats a polynomial cx^2 + bx + a into non-zero/non-one form. Ex. '0x^2 + 1x + 2' becomes 'x + 2' :param a: x^0 coefficient :param b: x^1 coefficient :param c: x^2 coefficient :returns: pretty format of polynomial .. py:class:: FP2Value(mod: int, a: int = 0, b: int = 0, c: int = 0, aC: int = 1, bC: int = 0, cC: int = 0) Defines a rational value (a + bx + cx^2)/(aC + bCx + cCx^2)(mod 1 + x + x^2, mod p). .. py:attribute:: mod .. py:method:: __str__() -> str Format this value as a string. .. py:method:: __add__(other: FP2Value) -> FP2Value Add this value to another value and return a new FP2Value. .. py:method:: __sub__(other: FP2Value) -> FP2Value Subtract another value from this value and return a new FP2Value. .. py:method:: __mul__(other: FP2Value) -> FP2Value Multiply this value with another value and return a new FP2Value. .. py:method:: __floordiv__(other: FP2Value) -> FP2Value Divide this value by another value and return a new FP2Value. .. py:method:: __eq__(other: object) -> bool Check equality with another value. .. py:method:: __hash__() -> int Equality is not trivial. We hash everything to 0 for the full equality check. .. py:method:: intpow(power: int) -> FP2Value Raise this value by a given power (int). :param power: the power to raise this value by :type power: int .. py:method:: normalize() -> FP2Value Normalize to aC = 1: this is the best human-readable form. Ex. '20/4' becomes '5' '4 + 4x/2 + 2x' becomes '2 + 2x/1 + x' .. py:method:: inverse() -> FP2Value Return the inverse of this value. .. py:method:: wp_nominator() -> FP2Value Return the '1' and 'x' coefficients as a new value. .. py:method:: wp_denom_inverse() -> FP2Value Return the '1^-1' and 'x^-1' coefficients modular inverse. .. py:method:: wp_compress() -> FP2Value Compress this FP2 value into an FP2Value only containing `a` and `b` values. This is an expensive operation.