This commit is contained in:
Daniil Gentili 2016-08-04 19:03:45 -04:00
parent 429695db43
commit 5c0dae2782
2 changed files with 4 additions and 4 deletions

View File

@ -19,7 +19,7 @@ function newcrc32($data)
/**
* Function to dump the hex version of a string.
* :param what: What to dump.
* @param $what What to dump.
*/
function hex_dump(...$what)
{

View File

@ -73,7 +73,7 @@ class PrimeModule
return true;
}
// taken from https://github.com/enricostara/telegram-mt-node/blob/master/lib/security/pq-finder.js
public function factorization($pq) {
public function getpq($pq) {
$zero = new \phpseclib\Math\BigInteger(0);
$one = new \phpseclib\Math\BigInteger(1);
$two = new \phpseclib\Math\BigInteger(2);
@ -121,7 +121,7 @@ class PrimeModule
$q = $pq->divide(prime)[0];
}
$_pq = ($q->compare($p) > 0) ? [$p, $q] : [$q, $p];
return _$pq;
return $_pq;
}
public function pollard_brent($n)
{
@ -179,7 +179,7 @@ class PrimeModule
{
$factors = [];
$n = new \phpseclib\Math\BigInteger(1724114033281923457);
var_dump($this->factorization($n));
var_dump($this->getpq($n));
$one = new \phpseclib\Math\BigInteger(1);
$two = new \phpseclib\Math\BigInteger(2);
$limit = $n->root()->add($one);