This commit is contained in:
danogentili 2016-07-18 22:18:26 +02:00
parent fe2078f566
commit c0789a3bbf
2 changed files with 76 additions and 2 deletions

View File

@ -275,8 +275,8 @@ class Session
$pq_bytes = $ResPQ['pq'];
$pq = bytes_to_long($pq_bytes);
var_dump($this->PrimeModule->pollard_brent(2118588165281151121));
var_dump($this->PrimeModule->primefactors(2118588165281151121));die;
//$this->PrimeModule->primefactors(1724114033281923457)
var_dump($this->PrimeModule->primefactors(378221), $this->PrimeModule->primefactors(15));die;
list($p, $q) = $this->PrimeModule->primefactors($pq);
if ($p > $q) {
list($p, $q) = [$q, $p];

View File

@ -174,5 +174,79 @@ class PrimeModule {
{
return floor(abs(($a * $b)) / $this->gcd($a, $b));
}
/*
function pqPrimeLeemon ($what) {
$minBits = 64;
$minLen = ceil($minBits / $bpe) + 1;
$it = 0
$a = new Array(minLen)
$b = new Array(minLen)
$c = new Array(minLen)
$g = new Array(minLen)
$z = new Array(minLen)
$x = new Array(minLen)
$y = new Array(minLen)
for ($i = 0; $i < 3; $i++) {
$q = (nextRandomInt(128) & 15) + 17
copyInt_(x, nextRandomInt(1000000000) + 1)
copy_(y, x)
lim = 1 << (i + 18)
for (j = 1; j < lim; j++) {
++it
copy_(a, x)
copy_(b, x)
copyInt_(c, q)
while (!isZero(b)) {
if (b[0] & 1) {
add_(c, a)
if (greater(c, what)) {
sub_(c, what)
}
}
add_(a, a)
if (greater(a, what)) {
sub_(a, what)
}
rightShift_(b, 1)
}
copy_(x, c)
if (greater(x, y)) {
copy_(z, x)
sub_(z, y)
} else {
copy_(z, y)
sub_(z, x)
}
eGCD_(z, what, g, a, b)
if (!equalsInt(g, 1)) {
break
}
if ((j & (j - 1)) == 0) {
copy_(y, x)
}
}
if (greater(g, one)) {
break
}
}
divide_(what, g, x, y)
if (greater(g, x)) {
P = x
Q = g
} else {
P = g
Q = x
}
// console.log(dT(), 'done', bigInt2str(what, 10), bigInt2str(P, 10), bigInt2str(Q, 10))
return [bytesFromLeemonBigInt(P), bytesFromLeemonBigInt(Q), it]
}*/
}