You are here

public static function ParagonIE_Sodium_Compat::crypto_box_publickey_from_secretkey in Automatic Updates 7

Same name and namespace in other branches
  1. 8 vendor/paragonie/sodium_compat/src/Compat.php \ParagonIE_Sodium_Compat::crypto_box_publickey_from_secretkey()

Calculate the X25519 public key from a given X25519 secret key.

@psalm-suppress MixedArgument

Parameters

string $secretKey Any X25519 secret key:

Return value

string The corresponding X25519 public key

Throws

SodiumException

TypeError

2 calls to ParagonIE_Sodium_Compat::crypto_box_publickey_from_secretkey()
php72compat.php in vendor/paragonie/sodium_compat/lib/php72compat.php
sodium_compat.php in vendor/paragonie/sodium_compat/lib/sodium_compat.php

File

vendor/paragonie/sodium_compat/src/Compat.php, line 1303

Class

ParagonIE_Sodium_Compat

Code

public static function crypto_box_publickey_from_secretkey($secretKey) {

  /* Type checks: */
  ParagonIE_Sodium_Core_Util::declareScalarType($secretKey, 'string', 1);

  /* Input validation: */
  if (ParagonIE_Sodium_Core_Util::strlen($secretKey) !== self::CRYPTO_BOX_SECRETKEYBYTES) {
    throw new SodiumException('Argument 1 must be CRYPTO_BOX_SECRETKEYBYTES long.');
  }
  if (self::useNewSodiumAPI()) {
    return (string) sodium_crypto_box_publickey_from_secretkey($secretKey);
  }
  if (self::use_fallback('crypto_box_publickey_from_secretkey')) {
    return (string) call_user_func('\\Sodium\\crypto_box_publickey_from_secretkey', $secretKey);
  }
  if (PHP_INT_SIZE === 4) {
    return ParagonIE_Sodium_Crypto32::box_publickey_from_secretkey($secretKey);
  }
  return ParagonIE_Sodium_Crypto::box_publickey_from_secretkey($secretKey);
}