Documentation

Integer extends Integer
in package

Binary Finite Fields

Tags
author

Jim Wigginton terrafrost@php.net

access

public

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
access

public

__toString()

__toString() magic method

public __toString() : mixed
Tags
access

public

add()

Adds two BinaryFieldIntegers.

public add(self $y) : static
Parameters
$y : self
Return values
static

compare()

Compares two numbers.

public compare(self $x) : int
Parameters
$x : self
Return values
int

divide()

Divides two PrimeFieldIntegers.

public divide(self $x) : static
Parameters
$x : self
Return values
static

equals()

Tests the equality of two numbers.

public equals(self $x) : bool
Parameters
$x : self
Return values
bool

getModulo()

Returns the modulo

public static getModulo(mixed $instanceID) : int
Parameters
$instanceID : mixed
Return values
int

modInverse()

Returns the modular inverse of a BinaryFieldInteger

public modInverse() : static
Return values
static

multiply()

Multiplies two BinaryFieldIntegers.

public multiply(self $y) : static
Parameters
$y : self
Return values
static

negate()

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
object

setModulo()

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
static

toBigInteger()

Converts an Integer to a BigInteger

public toBigInteger() : string
Return values
string

toBits()

Converts an Integer to a bit string (eg. base-2).

public toBits() : string
Return values
string

toBytes()

Converts an Integer to a byte string (eg. base-256).

public toBytes() : string
Return values
string

toHex()

Converts an Integer to a hex string (eg. base-16).

public toHex() : string
Return values
string

checkInstance()

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
int

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
link
https://en.wikipedia.org/wiki/Karatsuba_algorithm
Return values
string

subAdd2()

Adds two numbers

private static subAdd2(string $x, string $y) : string
Parameters
$x : string
$y : string
Return values
string

subAdd3()

Adds three numbers

private static subAdd3(string $x, string $y, mixed $z) : string
Parameters
$x : string
$y : string
$z : mixed
Return values
string
Loading…
On this page

Search results