[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP/Reductions/ -> Classic.php (source)

   1  <?php
   2  
   3  /**
   4   * PHP Classic Modular Exponentiation Engine
   5   *
   6   * PHP version 5 and 7
   7   *
   8   * @author    Jim Wigginton <terrafrost@php.net>
   9   * @copyright 2017 Jim Wigginton
  10   * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
  11   * @link      http://pear.php.net/package/Math_BigInteger
  12   */
  13  
  14  namespace phpseclib3\Math\BigInteger\Engines\PHP\Reductions;
  15  
  16  use phpseclib3\Math\BigInteger\Engines\PHP\Base;
  17  
  18  /**
  19   * PHP Classic Modular Exponentiation Engine
  20   *
  21   * @author  Jim Wigginton <terrafrost@php.net>
  22   */
  23  abstract class Classic extends Base
  24  {
  25      /**
  26       * Regular Division
  27       *
  28       * @param array $x
  29       * @param array $n
  30       * @param string $class
  31       * @return array
  32       */
  33      protected static function reduce(array $x, array $n, $class)
  34      {
  35          $lhs = new $class();
  36          $lhs->value = $x;
  37          $rhs = new $class();
  38          $rhs->value = $n;
  39          list(, $temp) = $lhs->divide($rhs);
  40          return $temp->value;
  41      }
  42  }