public static function ParagonIE_Sodium_Core_Curve25519::ge_scalarmult_base in Automatic Updates 7
Same name and namespace in other branches
- 8 vendor/paragonie/sodium_compat/src/Core/Curve25519.php \ParagonIE_Sodium_Core_Curve25519::ge_scalarmult_base()
@internal You should not use this directly from another application
@psalm-suppress MixedAssignment @psalm-suppress MixedOperand
Parameters
string $a:
Return value
ParagonIE_Sodium_Core_Curve25519_Ge_P3
Throws
SodiumException
TypeError
3 calls to ParagonIE_Sodium_Core_Curve25519::ge_scalarmult_base()
- ParagonIE_Sodium_Core_Ed25519::sign_detached in vendor/
paragonie/ sodium_compat/ src/ Core/ Ed25519.php - @internal You should not use this directly from another application
- ParagonIE_Sodium_Core_Ed25519::sk_to_pk in vendor/
paragonie/ sodium_compat/ src/ Core/ Ed25519.php - @internal You should not use this directly from another application
- ParagonIE_Sodium_Core_X25519::crypto_scalarmult_curve25519_ref10_base in vendor/
paragonie/ sodium_compat/ src/ Core/ X25519.php - @internal You should not use this directly from another application
File
- vendor/
paragonie/ sodium_compat/ src/ Core/ Curve25519.php, line 1938
Class
- ParagonIE_Sodium_Core_Curve25519
- Class ParagonIE_Sodium_Core_Curve25519
Code
public static function ge_scalarmult_base($a) {
/** @var array<int, int> $e */
$e = array();
$r = new ParagonIE_Sodium_Core_Curve25519_Ge_P1p1();
for ($i = 0; $i < 32; ++$i) {
/** @var int $dbl */
$dbl = (int) $i << 1;
$e[$dbl] = (int) self::chrToInt($a[$i]) & 15;
$e[$dbl + 1] = (int) (self::chrToInt($a[$i]) >> 4) & 15;
}
/** @var int $carry */
$carry = 0;
for ($i = 0; $i < 63; ++$i) {
$e[$i] += $carry;
/** @var int $carry */
$carry = $e[$i] + 8;
/** @var int $carry */
$carry >>= 4;
$e[$i] -= $carry << 4;
}
/** @var array<int, int> $e */
$e[63] += (int) $carry;
$h = self::ge_p3_0();
for ($i = 1; $i < 64; $i += 2) {
$t = self::ge_select((int) floor($i / 2), (int) $e[$i]);
$r = self::ge_madd($r, $h, $t);
$h = self::ge_p1p1_to_p3($r);
}
$r = self::ge_p3_dbl($h);
$s = self::ge_p1p1_to_p2($r);
$r = self::ge_p2_dbl($s);
$s = self::ge_p1p1_to_p2($r);
$r = self::ge_p2_dbl($s);
$s = self::ge_p1p1_to_p2($r);
$r = self::ge_p2_dbl($s);
$h = self::ge_p1p1_to_p3($r);
for ($i = 0; $i < 64; $i += 2) {
$t = self::ge_select($i >> 1, (int) $e[$i]);
$r = self::ge_madd($r, $h, $t);
$h = self::ge_p1p1_to_p3($r);
}
return $h;
}