public static function ParagonIE_Sodium_Core_X25519::crypto_scalarmult_curve25519_ref10_base in Automatic Updates 7
Same name and namespace in other branches
- 8 vendor/paragonie/sodium_compat/src/Core/X25519.php \ParagonIE_Sodium_Core_X25519::crypto_scalarmult_curve25519_ref10_base()
@internal You should not use this directly from another application
Parameters
string $n:
Return value
string
Throws
SodiumException
TypeError
1 call to ParagonIE_Sodium_Core_X25519::crypto_scalarmult_curve25519_ref10_base()
- ParagonIE_Sodium_Crypto::scalarmult_base in vendor/
paragonie/ sodium_compat/ src/ Crypto.php - ECDH over Curve25519, using the basepoint. Used to get a secret key from a public key.
File
- vendor/
paragonie/ sodium_compat/ src/ Core/ X25519.php, line 300
Class
- ParagonIE_Sodium_Core_X25519
- Class ParagonIE_Sodium_Core_X25519
Code
public static function crypto_scalarmult_curve25519_ref10_base($n) {
# for (i = 0;i < 32;++i) e[i] = n[i];
$e = '' . $n;
# e[0] &= 248;
$e[0] = self::intToChr(self::chrToInt($e[0]) & 248);
# e[31] &= 127;
# e[31] |= 64;
$e[31] = self::intToChr(self::chrToInt($e[31]) & 127 | 64);
$A = self::ge_scalarmult_base($e);
if (!$A->Y instanceof ParagonIE_Sodium_Core_Curve25519_Fe || !$A->Z instanceof ParagonIE_Sodium_Core_Curve25519_Fe) {
throw new TypeError('Null points encountered');
}
$pk = self::edwards_to_montgomery($A->Y, $A->Z);
return self::fe_tobytes($pk);
}