Integer
extends Integer
in package
Binary Finite Fields
Tags
Table of Contents
Properties
- $instanceID : int
- Keeps track of current instance
- $modulo : array<string|int, string>
- Holds the PrimeField's modulo
- $reduce : array<string|int, callable>
- Holds a pre-generated function to perform modulo reductions
- $value : string
- Holds the BinaryField's value
Methods
- __construct() : mixed
- Default constructor
- __debugInfo() : mixed
- __debugInfo() magic method
- __toString() : mixed
- __toString() magic method
- add() : static
- Adds two BinaryFieldIntegers.
- compare() : int
- Compares two numbers.
- divide() : static
- Divides two PrimeFieldIntegers.
- equals() : bool
- Tests the equality of two numbers.
- getModulo() : int
- Returns the modulo
- modInverse() : static
- Returns the modular inverse of a BinaryFieldInteger
- multiply() : static
- Multiplies two BinaryFieldIntegers.
- negate() : object
- Negate
- setModulo() : mixed
- Set the modulo for a given instance
- setRecurringModuloFunction() : mixed
- Set the modulo for a given instance
- subtract() : static
- Subtracts two BinaryFieldIntegers.
- toBigInteger() : string
- Converts an Integer to a BigInteger
- toBits() : string
- Converts an Integer to a bit string (eg. base-2).
- toBytes() : string
- Converts an Integer to a byte string (eg. base-256).
- toHex() : string
- Converts an Integer to a hex string (eg. base-16).
- checkInstance() : mixed
- Tests a parameter to see if it's of the right instance
- deg() : int
- Returns the degree of the polynomial
- polynomialDivide() : array<string|int, string>
- Perform polynomial division
- polynomialMultiply() : string
- Perform polynomial multiplation
- regularPolynomialMultiply() : string
- Perform polynomial multiplation in the traditional way
- subAdd2() : string
- Adds two numbers
- subAdd3() : string
- Adds three numbers
- subMultiply() : string
- Perform polynomial multiplication on 2x 32-bit numbers, returning a 64-bit number
Properties
$instanceID
Keeps track of current instance
protected
int
$instanceID
$modulo
Holds the PrimeField's modulo
protected
static array<string|int, string>
$modulo
$reduce
Holds a pre-generated function to perform modulo reductions
protected
static array<string|int, callable>
$reduce
$value
Holds the BinaryField's value
protected
string
$value
Methods
__construct()
Default constructor
public
__construct(mixed $instanceID[, mixed $num = '' ]) : mixed
Parameters
- $instanceID : mixed
- $num : mixed = ''
__debugInfo()
__debugInfo() magic method
public
__debugInfo() : mixed
Tags
__toString()
__toString() magic method
public
__toString() : mixed
Tags
add()
Adds two BinaryFieldIntegers.
public
add(self $y) : static
Parameters
- $y : self
Return values
staticcompare()
Compares two numbers.
public
compare(self $x) : int
Parameters
- $x : self
Return values
intdivide()
Divides two PrimeFieldIntegers.
public
divide(self $x) : static
Parameters
- $x : self
Return values
staticequals()
Tests the equality of two numbers.
public
equals(self $x) : bool
Parameters
- $x : self
Return values
boolgetModulo()
Returns the modulo
public
static getModulo(mixed $instanceID) : int
Parameters
- $instanceID : mixed
Return values
intmodInverse()
Returns the modular inverse of a BinaryFieldInteger
public
modInverse() : static
Return values
staticmultiply()
Multiplies two BinaryFieldIntegers.
public
multiply(self $y) : static
Parameters
- $y : self
Return values
staticnegate()
Negate
public
negate() : object
A negative number can be written as 0-12. With modulos, 0 is the same thing as the modulo so 0-12 is the same thing as modulo-12
Return values
objectsetModulo()
Set the modulo for a given instance
public
static setModulo(mixed $instanceID, mixed $modulo) : mixed
Parameters
- $instanceID : mixed
- $modulo : mixed
setRecurringModuloFunction()
Set the modulo for a given instance
public
static setRecurringModuloFunction(mixed $instanceID, callable $function) : mixed
Parameters
- $instanceID : mixed
- $function : callable
subtract()
Subtracts two BinaryFieldIntegers.
public
subtract(self $x) : static
Parameters
- $x : self
Return values
statictoBigInteger()
Converts an Integer to a BigInteger
public
toBigInteger() : string
Return values
stringtoBits()
Converts an Integer to a bit string (eg. base-2).
public
toBits() : string
Return values
stringtoBytes()
Converts an Integer to a byte string (eg. base-256).
public
toBytes() : string
Return values
stringtoHex()
Converts an Integer to a hex string (eg. base-16).
public
toHex() : string
Return values
stringcheckInstance()
Tests a parameter to see if it's of the right instance
private
static checkInstance(self $x, self $y) : mixed
Throws an exception if the incorrect class is being utilized
Parameters
- $x : self
- $y : self
deg()
Returns the degree of the polynomial
private
static deg(string $x) : int
Parameters
- $x : string
Return values
intpolynomialDivide()
Perform polynomial division
private
static polynomialDivide(mixed $x, mixed $y) : array<string|int, string>
Parameters
- $x : mixed
- $y : mixed
Tags
Return values
array<string|int, string>polynomialMultiply()
Perform polynomial multiplation
private
static polynomialMultiply(mixed $x, mixed $y) : string
Uses karatsuba multiplication to reduce x-bit multiplications to a series of 32-bit multiplications
Parameters
- $x : mixed
- $y : mixed
Tags
Return values
stringregularPolynomialMultiply()
Perform polynomial multiplation in the traditional way
private
static regularPolynomialMultiply(mixed $x, mixed $y) : string
Parameters
- $x : mixed
- $y : mixed
Tags
Return values
stringsubAdd2()
Adds two numbers
private
static subAdd2(string $x, string $y) : string
Parameters
- $x : string
- $y : string
Return values
stringsubAdd3()
Adds three numbers
private
static subAdd3(string $x, string $y, mixed $z) : string
Parameters
- $x : string
- $y : string
- $z : mixed
Return values
stringsubMultiply()
Perform polynomial multiplication on 2x 32-bit numbers, returning a 64-bit number
private
static subMultiply(string $x, string $y) : string
Parameters
- $x : string
- $y : string