HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ubuntu-8gb-hel1-1 6.8.0-55-generic #57-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 12 23:42:21 UTC 2025 x86_64
User: www-data (33)
PHP: 8.1.32
Disabled: NONE
Upload Files
File: /var/www/agighana.org_backup/Curve25519.php
<?php

/**
 * Curve25519
 *
 * PHP version 5 and 7
 *
 * @author    Jim Wigginton <terrafrost@php.net>
 * @copyright 2019 Jim Wigginton
 * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
 * @link      http://pear.php.net/package/Math_BigInteger
 */
namespace Google\Site_Kit_Dependencies\phpseclib3\Crypt\EC\Curves;

use Google\Site_Kit_Dependencies\phpseclib3\Crypt\EC\BaseCurves\Montgomery;
use Google\Site_Kit_Dependencies\phpseclib3\Math\BigInteger;
class Curve25519 extends \Google\Site_Kit_Dependencies\phpseclib3\Crypt\EC\BaseCurves\Montgomery
{
    public function __construct()
    {
        // 2^255 - 19
        $this->setModulo(new \Google\Site_Kit_Dependencies\phpseclib3\Math\BigInteger('7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFED', 16));
        $this->a24 = $this->factory->newInteger(new \Google\Site_Kit_Dependencies\phpseclib3\Math\BigInteger('121666'));
        $this->p = [$this->factory->newInteger(new \Google\Site_Kit_Dependencies\phpseclib3\Math\BigInteger(9))];
        // 2^252 + 0x14def9dea2f79cd65812631a5cf5d3ed
        $this->setOrder(new \Google\Site_Kit_Dependencies\phpseclib3\Math\BigInteger('1000000000000000000000000000000014DEF9DEA2F79CD65812631A5CF5D3ED', 16));
        /*
        $this->setCoefficients(
            new BigInteger('486662'), // a
        );
        $this->setBasePoint(
            new BigInteger(9),
            new BigInteger('14781619447589544791020593568409986887264606134616475288964881837755586237401')
        );
        */
    }
    /**
     * Multiply a point on the curve by a scalar
     *
     * Modifies the scalar as described at https://tools.ietf.org/html/rfc7748#page-8
     *
     * @return array
     */
    public function multiplyPoint(array $p, \Google\Site_Kit_Dependencies\phpseclib3\Math\BigInteger $d)
    {
        //$r = strrev(sodium_crypto_scalarmult($d->toBytes(), strrev($p[0]->toBytes())));
        //return [$this->factory->newInteger(new BigInteger($r, 256))];
        $d = $d->toBytes();
        $d &= "\xf8" . \str_repeat("\xff", 30) . "";
        $d = \strrev($d);
        $d |= "@";
        $d = new \Google\Site_Kit_Dependencies\phpseclib3\Math\BigInteger($d, -256);
        return parent::multiplyPoint($p, $d);
    }
    /**
     * Creates a random scalar multiplier
     *
     * @return BigInteger
     */
    public function createRandomMultiplier()
    {
        return \Google\Site_Kit_Dependencies\phpseclib3\Math\BigInteger::random(256);
    }
    /**
     * Performs range check
     */
    public function rangeCheck(\Google\Site_Kit_Dependencies\phpseclib3\Math\BigInteger $x)
    {
        if ($x->getLength() > 256 || $x->isNegative()) {
            throw new \RangeException('x must be a positive integer less than 256 bytes in length');
        }
    }
}