Integer

Extends\phpseclib3\Math\Common\FiniteField\Integer

Binary Finite Fields

author

Jim Wigginton terrafrost@php.net

package

Default

Methods

Default constructor

__construct( $instanceID, $num = '')

Arguments

$instanceID

$num

__debugInfo() magic method

__debugInfo()

__toString() magic method

__toString()

Adds two BinaryFieldIntegers.

add(self $y): static

Arguments

$y

self

Response

static

Tests a parameter to see if it's of the right instance

checkInstance(self $x,self $y)
static

Throws an exception if the incorrect class is being utilized

Arguments

$x

self

$y

self

Compares two numbers.

compare(self $x): integer

Arguments

$x

self

Response

integer

Returns the degree of the polynomial

deg(string $x): integer
static

Arguments

$x

string

Response

integer

Divides two PrimeFieldIntegers.

divide(self $x): static

Arguments

$x

self

Response

static

Tests the equality of two numbers.

equals(self $x): boolean

Arguments

$x

self

Response

boolean

Returns the modulo

getModulo( $instanceID): string
static

Arguments

$instanceID

Response

string

jsonSerialize

jsonSerialize()

Returns the modular inverse of a BinaryFieldInteger

modInverse(): static

Response

static

Multiplies two BinaryFieldIntegers.

multiply(self $y): static

Arguments

$y

self

Response

static

Negate

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

Response

object

Perform polynomial division

polynomialDivide( $x, $y): array<mixed,string>
static

Perform polynomial multiplation

polynomialMultiply( $x, $y): string
static

Uses karatsuba multiplication to reduce x-bit multiplications to a series of 32-bit multiplications

link

https://en.wikipedia.org/wiki/Karatsuba_algorithm

Arguments

$x

$y

Response

string

Perform polynomial multiplation in the traditional way

regularPolynomialMultiply( $x, $y): string
static

Set the modulo for a given instance

setModulo(integer $instanceID,string $modulo)
static

Arguments

$instanceID

integer

$modulo

string

Set the modulo for a given instance

setRecurringModuloFunction( $instanceID,callable $function)
static

Arguments

$instanceID

$function

callable

Adds two numbers

subAdd2(string $x,string $y): string
static

Arguments

$x

string

$y

string

Response

string

Adds three numbers

subAdd3(string $x,string $y, $z): string
static

Arguments

$x

string

$y

string

$z

Response

string

Perform polynomial multiplication on 2x 32-bit numbers, returning a 64-bit number

subMultiply(string $x,string $y): string
static
link

https://www.bearssl.org/constanttime.html#ghash-for-gcm

Arguments

$x

string

$y

string

Response

string

Subtracts two BinaryFieldIntegers.

subtract(self $x): static

Arguments

$x

self

Response

static

Converts an Integer to a BigInteger

toBigInteger(): string

Response

string

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

toBits(): string

Response

string

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

toBytes(): string

Response

string

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

toHex(): string
abstract

Response

string

Properties

Holds the BinaryField's value

value :string
var

Type(s)

string

Keeps track of current instance

instanceID :integer
var

Type(s)

integer

Holds the PrimeField's modulo

modulo :\phpseclib3\Math\BinaryField\array<int,
static
var

string>

Type(s)

\phpseclib3\Math\BinaryField\array

Holds a pre-generated function to perform modulo reductions

reduce :array<mixed,callable>
static
var

Type(s)

array<mixed,callable>