/
home
/
techb158
/
immovalet.com
/
vendor
/
phpseclib
/
phpseclib
/
phpseclib
/
Crypt
/
EC
/
Curves
/
/home/techb158/immovalet.com/vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves
mkdir
upload
Name
Size
Mode
Actions
brainpoolP160r1.php
1083
0644
edit
dl
rm
brainpoolP160t1.php
1807
0644
edit
dl
rm
brainpoolP192r1.php
1131
0644
edit
dl
rm
brainpoolP192t1.php
1141
0644
edit
dl
rm
brainpoolP224r1.php
1179
0644
edit
dl
rm
brainpoolP224t1.php
1189
0644
edit
dl
rm
brainpoolP256r1.php
1227
0644
edit
dl
rm
brainpoolP256t1.php
1238
0644
edit
dl
rm
brainpoolP320r1.php
1540
0644
edit
dl
rm
brainpoolP320t1.php
1550
0644
edit
dl
rm
brainpoolP384r1.php
1630
0644
edit
dl
rm
brainpoolP384t1.php
1641
0644
edit
dl
rm
brainpoolP512r1.php
1823
0644
edit
dl
rm
brainpoolP512t1.php
1833
0644
edit
dl
rm
Curve448.php
2237
0644
edit
dl
rm
Curve25519.php
1962
0644
edit
dl
rm
Ed448.php
7831
0644
edit
dl
rm
Ed25519.php
10258
0644
edit
dl
rm
nistb233.php
394
0644
edit
dl
rm
nistb409.php
394
0644
edit
dl
rm
nistk163.php
394
0644
edit
dl
rm
nistk233.php
394
0644
edit
dl
rm
nistk283.php
395
0644
edit
dl
rm
nistk409.php
394
0644
edit
dl
rm
nistp192.php
394
0644
edit
dl
rm
nistp224.php
394
0644
edit
dl
rm
nistp256.php
394
0644
edit
dl
rm
nistp384.php
394
0644
edit
dl
rm
nistp521.php
394
0644
edit
dl
rm
nistt571.php
394
0644
edit
dl
rm
prime192v1.php
398
0644
edit
dl
rm
prime192v2.php
1121
0644
edit
dl
rm
prime192v3.php
1121
0644
edit
dl
rm
prime239v1.php
1193
0644
edit
dl
rm
prime239v2.php
1193
0644
edit
dl
rm
prime239v3.php
1193
0644
edit
dl
rm
prime256v1.php
398
0644
edit
dl
rm
secp112r1.php
999
0644
edit
dl
rm
secp112r2.php
1035
0644
edit
dl
rm
secp128r1.php
1023
0644
edit
dl
rm
secp128r2.php
1052
0644
edit
dl
rm
secp160k1.php
1595
0644
edit
dl
rm
secp160r1.php
1073
0644
edit
dl
rm
secp160r2.php
1102
0644
edit
dl
rm
secp192k1.php
1634
0644
edit
dl
rm
secp192r1.php
3081
0644
edit
dl
rm
secp224k1.php
1708
0644
edit
dl
rm
secp224r1.php
1168
0644
edit
dl
rm
secp256k1.php
1893
0644
edit
dl
rm
secp256r1.php
1216
0644
edit
dl
rm
secp384r1.php
1659
0644
edit
dl
rm
secp521r1.php
2057
0644
edit
dl
rm
sect113r1.php
890
0644
edit
dl
rm
sect113r2.php
890
0644
edit
dl
rm
sect131r1.php
916
0644
edit
dl
rm
sect131r2.php
916
0644
edit
dl
rm
sect163k1.php
956
0644
edit
dl
rm
sect163r1.php
956
0644
edit
dl
rm
sect163r2.php
957
0644
edit
dl
rm
sect193r1.php
992
0644
edit
dl
rm
sect193r2.php
992
0644
edit
dl
rm
sect233k1.php
1040
0644
edit
dl
rm
sect233r1.php
1042
0644
edit
dl
rm
sect239k1.php
1045
0644
edit
dl
rm
sect283k1.php
1110
0644
edit
dl
rm
sect283r1.php
1110
0644
edit
dl
rm
sect409k1.php
1301
0644
edit
dl
rm
sect409r1.php
1303
0644
edit
dl
rm
sect571k1.php
1577
0644
edit
dl
rm
sect571r1.php
1577
0644
edit
dl
rm
Edit:
/home/techb158/immovalet.com/vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/Ed448.php
(7831B)
<?php /** * Ed448 * * PHP version 5 and 7 * * @category Crypt * @package EC * @author Jim Wigginton <terrafrost@php.net> * @copyright 2017 Jim Wigginton * @license http://www.opensource.org/licenses/mit-license.html MIT License */ namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards; use phpseclib3\Math\BigInteger; use phpseclib3\Crypt\Hash; use phpseclib3\Crypt\Random; class Ed448 extends TwistedEdwards { const HASH = 'shake256-912'; const SIZE = 57; public function __construct() { // 2^448 - 2^224 - 1 $this->setModulo(new BigInteger( 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE' . 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', 16)); $this->setCoefficients( new BigInteger(1), // -39081 new BigInteger('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE' . 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF6756', 16) ); $this->setBasePoint( new BigInteger('4F1970C66BED0DED221D15A622BF36DA9E146570470F1767EA6DE324' . 'A3D3A46412AE1AF72AB66511433B80E18B00938E2626A82BC70CC05E', 16), new BigInteger('693F46716EB6BC248876203756C9C7624BEA73736CA3984087789C1E' . '05A0C2D73AD3FF1CE67C39C4FDBD132C4ED7C8AD9808795BF230FA14', 16) ); $this->setOrder(new BigInteger( '3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF' . '7CCA23E9C44EDB49AED63690216CC2728DC58F552378C292AB5844F3', 16)); } /** * Recover X from Y * * Implements steps 2-4 at https://tools.ietf.org/html/rfc8032#section-5.2.3 * * Used by EC\Keys\Common.php * * @param BigInteger $y * @param boolean $sign * @return object[] */ public function recoverX(BigInteger $y, $sign) { $y = $this->factory->newInteger($y); $y2 = $y->multiply($y); $u = $y2->subtract($this->one); $v = $this->d->multiply($y2)->subtract($this->one); $x2 = $u->divide($v); if ($x2->equals($this->zero)) { if ($sign) { throw new \RuntimeException('Unable to recover X coordinate (x2 = 0)'); } return clone $this->zero; } // find the square root $exp = $this->getModulo()->add(new BigInteger(1)); $exp = $exp->bitwise_rightShift(2); $x = $x2->pow($exp); if (!$x->multiply($x)->subtract($x2)->equals($this->zero)) { throw new \RuntimeException('Unable to recover X coordinate'); } if ($x->isOdd() != $sign) { $x = $x->negate(); } return [$x, $y]; } /** * Extract Secret Scalar * * Implements steps 1-3 at https://tools.ietf.org/html/rfc8032#section-5.2.5 * * Used by the various key handlers * * @param string $str * @return \phpseclib3\Math\PrimeField\Integer */ public function extractSecret($str) { if (strlen($str) != 57) { throw new \LengthException('Private Key should be 57-bytes long'); } // 1. Hash the 57-byte private key using SHAKE256(x, 114), storing the // digest in a 114-octet large buffer, denoted h. Only the lower 57 // bytes are used for generating the public key. $hash = new Hash('shake256-912'); $h = $hash->hash($str); $h = substr($h, 0, 57); // 2. Prune the buffer: The two least significant bits of the first // octet are cleared, all eight bits the last octet are cleared, and // the highest bit of the second to last octet is set. $h[0] = $h[0] & chr(0xFC); $h = strrev($h); $h[0] = "\0"; $h[1] = $h[1] | chr(0x80); // 3. Interpret the buffer as the little-endian integer, forming a // secret scalar s. $dA = new BigInteger($h, 256); $dA = $this->factory->newInteger($dA); $dA->secret = $str; return $dA; } /** * Encode a point as a string * * @param array $point * @return string */ public function encodePoint($point) { list($x, $y) = $point; $y = "\0" . $y->toBytes(); if ($x->isOdd()) { $y[0] = $y[0] | chr(0x80); } $y = strrev($y); return $y; } /** * Creates a random scalar multiplier * * @return \phpseclib3\Math\PrimeField\Integer */ public function createRandomMultiplier() { return $this->extractSecret(Random::string(57)); } /** * Converts an affine point to an extended homogeneous coordinate * * From https://tools.ietf.org/html/rfc8032#section-5.2.4 : * * A point (x,y) is represented in extended homogeneous coordinates (X, Y, Z, T), * with x = X/Z, y = Y/Z, x * y = T/Z. * * @return \phpseclib3\Math\PrimeField\Integer[] */ public function convertToInternal(array $p) { if (empty($p)) { return [clone $this->zero, clone $this->one, clone $this->one]; } if (isset($p[2])) { return $p; } $p[2] = clone $this->one; return $p; } /** * Doubles a point on a curve * * @return FiniteField[] */ public function doublePoint(array $p) { if (!isset($this->factory)) { throw new \RuntimeException('setModulo needs to be called before this method'); } if (!count($p)) { return []; } if (!isset($p[2])) { throw new \RuntimeException('Affine coordinates need to be manually converted to "Jacobi" coordinates or vice versa'); } // from https://tools.ietf.org/html/rfc8032#page-18 list($x1, $y1, $z1) = $p; $b = $x1->add($y1); $b = $b->multiply($b); $c = $x1->multiply($x1); $d = $y1->multiply($y1); $e = $c->add($d); $h = $z1->multiply($z1); $j = $e->subtract($this->two->multiply($h)); $x3 = $b->subtract($e)->multiply($j); $y3 = $c->subtract($d)->multiply($e); $z3 = $e->multiply($j); return [$x3, $y3, $z3]; } /** * Adds two points on the curve * * @return FiniteField[] */ public function addPoint(array $p, array $q) { if (!isset($this->factory)) { throw new \RuntimeException('setModulo needs to be called before this method'); } if (!count($p) || !count($q)) { if (count($q)) { return $q; } if (count($p)) { return $p; } return []; } if (!isset($p[2]) || !isset($q[2])) { throw new \RuntimeException('Affine coordinates need to be manually converted to "Jacobi" coordinates or vice versa'); } if ($p[0]->equals($q[0])) { return !$p[1]->equals($q[1]) ? [] : $this->doublePoint($p); } // from https://tools.ietf.org/html/rfc8032#page-17 list($x1, $y1, $z1) = $p; list($x2, $y2, $z2) = $q; $a = $z1->multiply($z2); $b = $a->multiply($a); $c = $x1->multiply($x2); $d = $y1->multiply($y2); $e = $this->d->multiply($c)->multiply($d); $f = $b->subtract($e); $g = $b->add($e); $h = $x1->add($y1)->multiply($x2->add($y2)); $x3 = $a->multiply($f)->multiply($h->subtract($c)->subtract($d)); $y3 = $a->multiply($g)->multiply($d->subtract($c)); $z3 = $f->multiply($g); return [$x3, $y3, $z3]; } }
Save
cmd:
run