Base Engine.
author | Jim Wigginton terrafrost@php.net |
---|---|
package | Default |
__construct(integer|\phpseclib3\Math\BigInteger\Engines\numeric-string $x,integer $base = 10)
integer|\phpseclib3\Math\BigInteger\Engines\numeric-string
integer Base-10 number or base-$base number if $base set.
integer
__debugInfo(): array
Will be called, automatically, when print_r() or var_dump() are called
array
__sleep(): array
Will be called, automatically, when serialize() is called on a BigInteger object.
array
__toString(): string
string
__wakeup(): void
Will be called, automatically, when unserialize() is called on a BigInteger object.
base256_lshift(string &$x,integer $shift): void
Shifts binary strings $shift bits, essentially multiplying by 2**$shift.
string
integer
bitwise_leftRotate(integer $shift): \phpseclib3\Math\BigInteger\Engines\Engine
Instead of the top x bits being dropped they're appended to the shifted bit string.
integer
\phpseclib3\Math\BigInteger\Engines\Engine
bitwise_not(): \phpseclib3\Math\BigInteger\Engines\Engine|string
bitwise_rightRotate(integer $shift): \phpseclib3\Math\BigInteger\Engines\Engine
Instead of the bottom x bits being dropped they're prepended to the shifted bit string.
integer
\phpseclib3\Math\BigInteger\Engines\Engine
bitwise_split(integer $split): array<mixed,\phpseclib3\Math\BigInteger\Engines\Engine>
Splits BigInteger's into chunks of $split bits
integer
array<mixed,\phpseclib3\Math\BigInteger\Engines\Engine>
bitwiseAndHelper(\phpseclib3\Math\BigInteger\Engines\Engine $x): \phpseclib3\Math\BigInteger\Engines\Engine
bitwiseOrHelper(\phpseclib3\Math\BigInteger\Engines\Engine $x): \phpseclib3\Math\BigInteger\Engines\Engine
bitwiseXorHelper(\phpseclib3\Math\BigInteger\Engines\Engine $x): \phpseclib3\Math\BigInteger\Engines\Engine
createRecurringModuloFunction(): callable
Sometimes it may be desirable to do repeated modulos with the same number outside of modular exponentiation
callable
extendedGCDHelper(\phpseclib3\Math\BigInteger\Engines\Engine $n): \phpseclib3\Math\BigInteger\Engines\array{gcd:
\phpseclib3\Math\BigInteger\Engines\array{gcd:
Engine, x: Engine, y: Engine}
getLength(): integer
integer
getLengthInBytes(): integer
integer
getPrecision(): integer
Returns the precision if it exists, -1 if it doesn't
integer
isPrime(integer|boolean $t = false): boolean
Assuming the $t parameter is not set, this function has an error rate of 2**-80. The main motivation for the $t parameter is distributability. BigInteger::randomPrime() can be distributed across multiple pageloads on a website instead of just one.
integer|boolean
boolean
jsonSerialize()
maxHelper(array $nums): \phpseclib3\Math\BigInteger\Engines\Engine
minHelper(array $nums): \phpseclib3\Math\BigInteger\Engines\Engine
minMaxBits(integer $bits): \phpseclib3\Math\BigInteger\Engines\array{min:
integer
\phpseclib3\Math\BigInteger\Engines\array{min:
static, max: static}
modInverseHelper(\phpseclib3\Math\BigInteger\Engines\Engine $n): static|false
Say you have (30 mod 17 * x mod 17) mod 17 == 1. x can be found using modular inverses.
{@internal See HAC 14.64 for more information.}
static|false
powModOuter(\phpseclib3\Math\BigInteger\Engines\Engine $e,\phpseclib3\Math\BigInteger\Engines\Engine $n): static|false
static|false
random(integer $size): \phpseclib3\Math\BigInteger\Engines\Engine
Bit length is equal to $size
integer
\phpseclib3\Math\BigInteger\Engines\Engine
randomPrime(integer $size): \phpseclib3\Math\BigInteger\Engines\Engine
Bit length is equal to $size
integer
\phpseclib3\Math\BigInteger\Engines\Engine
randomRangeHelper(\phpseclib3\Math\BigInteger\Engines\Engine $min,\phpseclib3\Math\BigInteger\Engines\Engine $max): \phpseclib3\Math\BigInteger\Engines\Engine
Returns a random number between $min and $max where $min and $max can be defined using one of the two methods:
BigInteger::randomRange($min, $max) BigInteger::randomRange($max, $min)
\phpseclib3\Math\BigInteger\Engines\Engine
randomRangePrimeInner(\phpseclib3\Math\BigInteger\Engines\Engine $x,\phpseclib3\Math\BigInteger\Engines\Engine $min,\phpseclib3\Math\BigInteger\Engines\Engine $max): static|false
static|false
randomRangePrimeOuter(\phpseclib3\Math\BigInteger\Engines\Engine $min,\phpseclib3\Math\BigInteger\Engines\Engine $max): static|false
static|false
root(integer $n = 2): \phpseclib3\Math\BigInteger\Engines\Engine
rootHelper(integer $n): \phpseclib3\Math\BigInteger\Engines\Engine
rootInner(integer $n): \phpseclib3\Math\BigInteger\Engines\Engine
Returns the nth root of a positive biginteger, where n defaults to 2
{@internal This function is based off of this page and this stackoverflow question.}
integer
\phpseclib3\Math\BigInteger\Engines\Engine
setBitmask(integer $bits): static
see | \phpseclib3\Math\BigInteger\Engines\Engine::setPrecision() |
---|
integer
static
setModExpEngine(\phpseclib3\Math\BigInteger\Engines\class-string<Engine> $engine)
Throws an exception if the type is invalid
\phpseclib3\Math\BigInteger\Engines\class-string
setPrecision(integer $bits)
Some bitwise operations give different results depending on the precision being used. Examples include left shift, not, and rotates.
integer
setupIsPrime(): integer
integer
slidingWindow(\phpseclib3\Math\BigInteger\Engines\Engine $x,\phpseclib3\Math\BigInteger\Engines\Engine $e,\phpseclib3\Math\BigInteger\Engines\Engine $n,\phpseclib3\Math\BigInteger\Engines\class-string<T> $class): \phpseclib3\Math\BigInteger\Engines\T
Based on HAC 14.85 / MPM 7.7. In a departure from those algorithims, however, this function performs a modular reduction after every multiplication and squaring operation. As such, this function has the same preconditions that the reductions being used do.
template | T of Engine |
---|
\phpseclib3\Math\BigInteger\Engines\class-string
\phpseclib3\Math\BigInteger\Engines\T
testPrimality(integer $t): boolean
Uses the Miller-Rabin primality test. See HAC 4.24 for more info.
integer
boolean
toBits(boolean $twos_compliment = false): string
Negative numbers are saved as positive numbers, unless $twos_compliment is set to true, at which point, they're saved as two's compliment.
boolean
string
toBytesHelper(): string
Negative numbers are saved as positive numbers, unless $twos_compliment is set to true, at which point, they're saved as two's compliment.
string
toHex(boolean $twos_compliment = false): string
boolean
string
PRIMES
zero :\phpseclib3\Math\BigInteger\Engines\array<class-string<static>,
var | static> |
---|
\phpseclib3\Math\BigInteger\Engines\array,
one :\phpseclib3\Math\BigInteger\Engines\array<class-string<static>,
var | static> |
---|
\phpseclib3\Math\BigInteger\Engines\array,
two :\phpseclib3\Math\BigInteger\Engines\array<class-string<static>,
var | static> |
---|
\phpseclib3\Math\BigInteger\Engines\array,
modexpEngine :\phpseclib3\Math\BigInteger\Engines\array<class-string<static>,
var | class-string |
---|
\phpseclib3\Math\BigInteger\Engines\array,
isValidEngine :\phpseclib3\Math\BigInteger\Engines\array<class-string<static>,
var | bool> |
---|
\phpseclib3\Math\BigInteger\Engines\array,
value :\GMP|string|array|integer
var |
---|
\GMP|string|array|integer
is_negative :boolean
var |
---|
boolean
precision :integer
see | |
---|---|
var |
integer
bitmask :static|false
see | |
---|---|
var |
static|false
reduce :callable
var |
---|
callable
hex :string
see | |
---|---|
var |
string