Merge branch '3.0'

This commit is contained in:
terrafrost 2023-03-02 03:49:40 -06:00
commit e77c881b54
2 changed files with 8 additions and 8 deletions

View File

@ -46,9 +46,9 @@ class PrimeField extends FiniteField
*/ */
public function __construct(BigInteger $modulo) public function __construct(BigInteger $modulo)
{ {
//if (!$modulo->isPrime()) { if (!$modulo->isPrime()) {
// throw new \phpseclib3\Exception\UnexpectedValueException('PrimeField requires a prime number be passed to the constructor'); throw new \phpseclib3\Exception\UnexpectedValueException('PrimeField requires a prime number be passed to the constructor');
//} }
$this->instanceID = self::$instanceCounter++; $this->instanceID = self::$instanceCounter++;
Integer::setModulo($this->instanceID, $modulo); Integer::setModulo($this->instanceID, $modulo);

View File

@ -249,13 +249,13 @@ class Integer extends Base
$r = $this->value->powMod($temp, static::$modulo[$this->instanceID]); $r = $this->value->powMod($temp, static::$modulo[$this->instanceID]);
while (!$t->equals($one)) { while (!$t->equals($one)) {
$i = clone $one; for ($i == clone $one; $i->compare($m) < 0; $i = $i->add($one)) {
if ($t->powMod($two->pow($i), static::$modulo[$this->instanceID])->equals($one)) {
while (!$t->powMod($two->pow($i), static::$modulo[$this->instanceID])->equals($one)) { break;
$i = $i->add($one); }
} }
if ($i->compare($m) >= 0) { if ($i->compare($m) == 0) {
return false; return false;
} }
$b = $c->powMod($two->pow($m->subtract($i)->subtract($one)), static::$modulo[$this->instanceID]); $b = $c->powMod($two->pow($m->subtract($i)->subtract($one)), static::$modulo[$this->instanceID]);