[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Source view] [Print] [Project Stats]
Base BigInteger Engine PHP version 5 and 7
Author: | Jim Wigginton <[email protected]> |
Copyright: | 2017 Jim Wigginton |
License: | http://www.opensource.org/licenses/mit-license.html MIT License |
File Size: | 1283 lines (38 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
__construct($x = 0, $base = 10) X-Ref |
Default constructor param: int|numeric-string $x integer Base-10 number or base-$base number if $base set. param: int $base |
setModExpEngine($engine) X-Ref |
Sets engine type. Throws an exception if the type is invalid param: class-string<Engine> $engine |
toBytesHelper() X-Ref |
Converts a BigInteger to a byte string (eg. base-256). Negative numbers are saved as positive numbers, unless $twos_compliment is set to true, at which point, they're saved as two's compliment. return: string |
toHex($twos_compliment = false) X-Ref |
Converts a BigInteger to a hex string (eg. base-16). param: bool $twos_compliment return: string |
toBits($twos_compliment = false) X-Ref |
Converts a BigInteger to a bit string (eg. base-2). Negative numbers are saved as positive numbers, unless $twos_compliment is set to true, at which point, they're saved as two's compliment. param: bool $twos_compliment return: string |
modInverseHelper(Engine $n) X-Ref |
Calculates modular inverses. Say you have (30 mod 17 * x mod 17) mod 17 == 1. x can be found using modular inverses. {@internal See {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=21 HAC 14.64} for more information.} param: Engine $n return: static|false |
__sleep() X-Ref |
Serialize Will be called, automatically, when serialize() is called on a BigInteger object. return: array |
__wakeup() X-Ref |
Serialize Will be called, automatically, when unserialize() is called on a BigInteger object. return: void |
jsonSerialize() X-Ref |
JSON Serialize Will be called, automatically, when json_encode() is called on a BigInteger object. |
__toString() X-Ref |
Converts a BigInteger to a base-10 number. return: string |
__debugInfo() X-Ref |
__debugInfo() magic method Will be called, automatically, when print_r() or var_dump() are called return: array |
setPrecision($bits) X-Ref |
Set Precision Some bitwise operations give different results depending on the precision being used. Examples include left shift, not, and rotates. param: int $bits |
getPrecision() X-Ref |
Get Precision Returns the precision if it exists, -1 if it doesn't return: int |
setBitmask($bits) X-Ref |
Set Bitmask param: int $bits return: static |
bitwise_not() X-Ref |
Logical Not return: Engine|string |
base256_lshift(&$x, $shift) X-Ref |
Logical Left Shift Shifts binary strings $shift bits, essentially multiplying by 2**$shift. param: string $x param: int $shift return: void |
bitwise_leftRotate($shift) X-Ref |
Logical Left Rotate Instead of the top x bits being dropped they're appended to the shifted bit string. param: int $shift return: Engine |
bitwise_rightRotate($shift) X-Ref |
Logical Right Rotate Instead of the bottom x bits being dropped they're prepended to the shifted bit string. param: int $shift return: Engine |
minMaxBits($bits) X-Ref |
Returns the smallest and largest n-bit number param: int $bits return: array{min: static, max: static} |
getLength() X-Ref |
Return the size of a BigInteger in bits return: int |
getLengthInBytes() X-Ref |
Return the size of a BigInteger in bytes return: int |
powModOuter(Engine $e, Engine $n) X-Ref |
Performs some pre-processing for powMod param: Engine $e param: Engine $n return: static|false |
slidingWindow(Engine $x, Engine $e, Engine $n, $class) X-Ref |
Sliding Window k-ary Modular Exponentiation Based on {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=27 HAC 14.85} / {@link http://math.libtomcrypt.com/files/tommath.pdf#page=210 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. param: Engine $x param: Engine $e param: Engine $n param: class-string<T> $class return: T |
random($size) X-Ref |
Generates a random number of a certain size Bit length is equal to $size param: int $size return: Engine |
randomPrime($size) X-Ref |
Generates a random prime number of a certain size Bit length is equal to $size param: int $size return: Engine |
randomRangePrimeOuter(Engine $min, Engine $max) X-Ref |
Performs some pre-processing for randomRangePrime param: Engine $min param: Engine $max return: static|false |
randomRangeHelper(Engine $min, Engine $max) X-Ref |
Generate a random number between a range 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) param: Engine $min param: Engine $max return: Engine |
randomRangePrimeInner(Engine $x, Engine $min, Engine $max) X-Ref |
Performs some post-processing for randomRangePrime param: Engine $x param: Engine $min param: Engine $max return: static|false |
setupIsPrime() X-Ref |
Sets the $t parameter for primality testing return: int |
testPrimality($t) X-Ref |
Tests Primality Uses the {@link http://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test Miller-Rabin primality test}. See {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap4.pdf#page=8 HAC 4.24} for more info. param: int $t return: bool |
isPrime($t = false) X-Ref |
Checks a numer to see if it's prime 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. param: int|bool $t return: bool |
rootHelper($n) X-Ref |
Performs a few preliminary checks on root param: int $n return: Engine |
rootInner($n) X-Ref |
Calculates the nth root of a biginteger. Returns the nth root of a positive biginteger, where n defaults to 2 {@internal This function is based off of {@link http://mathforum.org/library/drmath/view/52605.html this page} and {@link http://stackoverflow.com/questions/11242920/calculating-nth-root-with-bcmath-in-php this stackoverflow question}.} param: int $n return: Engine |
root($n = 2) X-Ref |
Calculates the nth root of a biginteger. param: int $n return: Engine |
minHelper(array $nums) X-Ref |
Return the minimum BigInteger between an arbitrary number of BigIntegers. param: array $nums return: Engine |
maxHelper(array $nums) X-Ref |
Return the minimum BigInteger between an arbitrary number of BigIntegers. param: array $nums return: Engine |
createRecurringModuloFunction() X-Ref |
Create Recurring Modulo Function Sometimes it may be desirable to do repeated modulos with the same number outside of modular exponentiation return: callable |
extendedGCDHelper(Engine $n) X-Ref |
Calculates the greatest common divisor and Bezout's identity. param: Engine $n return: array{gcd: Engine, x: Engine, y: Engine} |
bitwise_split($split) X-Ref |
Bitwise Split Splits BigInteger's into chunks of $split bits param: int $split return: Engine[] |
bitwiseAndHelper(Engine $x) X-Ref |
Logical And param: Engine $x return: Engine |
bitwiseOrHelper(Engine $x) X-Ref |
Logical Or param: Engine $x return: Engine |
bitwiseXorHelper(Engine $x) X-Ref |
Logical Exclusive Or param: Engine $x return: Engine |
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |