mirror of
https://github.com/phpseclib/phpseclib.git
synced 2025-02-05 21:38:27 +00:00
BigInteger: code cleanup
generateCustomReduction() is called by slidingWindow() and createRecurringModuloFunction(). i suspect this code was an early attempt to implement what'd later become createRecurringModuloFunction()
This commit is contained in:
parent
291eec0ce5
commit
e5e21c114f
@ -514,8 +514,6 @@ class BCMath extends Engine
|
||||
*/
|
||||
protected function normalize(BCMath $result)
|
||||
{
|
||||
unset($result->reduce);
|
||||
|
||||
$result->precision = $this->precision;
|
||||
$result->bitmask = $this->bitmask;
|
||||
|
||||
|
@ -59,11 +59,6 @@ abstract class EvalBarrett extends Base
|
||||
*/
|
||||
protected static function generateCustomReduction(BCMath $m, $class)
|
||||
{
|
||||
if (isset($n->reduce)) {
|
||||
self::$custom_reduction = $n->reduce;
|
||||
return $n->reduce;
|
||||
}
|
||||
|
||||
$m_length = strlen($m);
|
||||
|
||||
if ($m_length < 5) {
|
||||
|
@ -1081,20 +1081,18 @@ abstract class Engine
|
||||
static::$modexpEngine;
|
||||
if (method_exists($fqengine, 'generateCustomReduction')) {
|
||||
$func = $fqengine::generateCustomReduction($this, static::class);
|
||||
$this->reduce = eval('return function(' . static::class . ' $x) use ($func, $class) {
|
||||
return eval('return function(' . static::class . ' $x) use ($func, $class) {
|
||||
$r = new $class();
|
||||
$r->value = $func($x->value);
|
||||
return $r;
|
||||
};');
|
||||
return clone $this->reduce;
|
||||
}
|
||||
$n = $this->value;
|
||||
$this->reduce = eval('return function(' . static::class . ' $x) use ($n, $fqengine, $class) {
|
||||
return eval('return function(' . static::class . ' $x) use ($n, $fqengine, $class) {
|
||||
$r = new $class();
|
||||
$r->value = $fqengine::reduce($x->value, $n, $class);
|
||||
return $r;
|
||||
};');
|
||||
return clone $this->reduce;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -512,8 +512,6 @@ class GMP extends Engine
|
||||
*/
|
||||
protected function normalize(GMP $result)
|
||||
{
|
||||
unset($result->reduce);
|
||||
|
||||
$result->precision = $this->precision;
|
||||
$result->bitmask = $this->bitmask;
|
||||
|
||||
@ -683,10 +681,9 @@ class GMP extends Engine
|
||||
public function createRecurringModuloFunction()
|
||||
{
|
||||
$temp = $this->value;
|
||||
$this->reduce = function(GMP $x) use ($temp) {
|
||||
return function(GMP $x) use ($temp) {
|
||||
return new GMP($x->value % $temp);
|
||||
};
|
||||
return $this->reduce;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -731,8 +731,6 @@ abstract class PHP extends Engine
|
||||
*/
|
||||
protected function normalize(PHP $result)
|
||||
{
|
||||
unset($result->reduce);
|
||||
|
||||
$result->precision = $this->precision;
|
||||
$result->bitmask = $this->bitmask;
|
||||
|
||||
|
@ -60,11 +60,6 @@ abstract class EvalBarrett extends Base
|
||||
*/
|
||||
protected static function generateCustomReduction(PHP $m, $class)
|
||||
{
|
||||
if (isset($n->reduce)) {
|
||||
self::$custom_reduction = $n->reduce;
|
||||
return $n->reduce;
|
||||
}
|
||||
|
||||
$m_length = count($m->value);
|
||||
|
||||
if ($m_length < 5) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user