class Integer extends Integer (View source)

Prime Finite Fields

Properties

protected BigInteger $value Holds the PrimeField's value
protected int $instanceID Keeps track of current instance
static protected BigInteger $modulo Holds the PrimeField's modulo
static protected callable $reduce Holds a pre-generated function to perform modulo reductions
static protected BigInteger $zero Zero

Methods

__construct($instanceID, BigInteger $num = null)

Default constructor

static 
setModulo($instanceID, BigInteger $modulo)

Set the modulo for a given instance

static 
setRecurringModuloFunction($instanceID, callable $function)

Set the modulo for a given instance

static int
getModulo($instanceID)

Returns the modulo

static 
checkInstance(Integer $x, Integer $y)

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

bool
equals(Integer $x)

Tests the equality of two numbers.

int
compare(Integer $x)

Compares two numbers.

add(Integer $x)

Adds two PrimeFieldIntegers.

subtract(Integer $x)

Subtracts two PrimeFieldIntegers.

multiply(Integer $x)

Multiplies two PrimeFieldIntegers.

divide(Integer $x)

Divides two PrimeFieldIntegers.

pow(BigInteger $x)

Performs power operation on a PrimeFieldInteger.

Integer|false
squareRoot()

Calculates the square root

bool
isOdd()

Is Odd?

object
negate()

Negate

string
toBytes()

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

string
toHex()

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

string
toBits()

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

int[]
getNAF(int $w = 1)

Returns the w-ary non-adjacent form (wNAF)

string
toBigInteger()

Converts an Integer to a BigInteger

__toString()

__toString() magic method

__debugInfo()

__debugInfo() magic method

Details

__construct($instanceID, BigInteger $num = null)

Default constructor

Parameters

$instanceID
BigInteger $num

static setModulo($instanceID, BigInteger $modulo)

Set the modulo for a given instance

Parameters

$instanceID
BigInteger $modulo

static setRecurringModuloFunction($instanceID, callable $function)

Set the modulo for a given instance

Parameters

$instanceID
callable $function

static int getModulo($instanceID)

Returns the modulo

Parameters

$instanceID

Return Value

int

static checkInstance(Integer $x, Integer $y)

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

Throws an exception if the incorrect class is being utilized

Parameters

Integer $x
Integer $y

bool equals(Integer $x)

Tests the equality of two numbers.

Parameters

Integer $x

Return Value

bool

int compare(Integer $x)

Compares two numbers.

Parameters

Integer $x

Return Value

int

Integer add(Integer $x)

Adds two PrimeFieldIntegers.

Parameters

Integer $x

Return Value

Integer

Integer subtract(Integer $x)

Subtracts two PrimeFieldIntegers.

Parameters

Integer $x

Return Value

Integer

Integer multiply(Integer $x)

Multiplies two PrimeFieldIntegers.

Parameters

Integer $x

Return Value

Integer

Integer divide(Integer $x)

Divides two PrimeFieldIntegers.

Parameters

Integer $x

Return Value

Integer

Integer pow(BigInteger $x)

Performs power operation on a PrimeFieldInteger.

Parameters

BigInteger $x

Return Value

Integer

Integer|false squareRoot()

Calculates the square root

Return Value

Integer|false

bool isOdd()

Is Odd?

Return Value

bool

object negate()

Negate

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 Value

object

string toBytes()

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

Return Value

string

string toHex()

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

Return Value

string

string toBits()

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

Return Value

string

int[] getNAF(int $w = 1)

Returns the w-ary non-adjacent form (wNAF)

Parameters

int $w optional

Return Value

int[]

string toBigInteger()

Converts an Integer to a BigInteger

Return Value

string

__toString()

__toString() magic method

__debugInfo()

__debugInfo() magic method