You are here

public static function ParagonIE_Sodium_Compat::crypto_sign_ed25519_pk_to_curve25519 in Automatic Updates 7

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

Convert an Ed25519 public key to a Curve25519 public key

@psalm-suppress MixedArgument

Parameters

string $pk:

Return value

string

Throws

SodiumException

TypeError

2 calls to ParagonIE_Sodium_Compat::crypto_sign_ed25519_pk_to_curve25519()
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 2893

Class

ParagonIE_Sodium_Compat

Code

public static function crypto_sign_ed25519_pk_to_curve25519($pk) {

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

  /* Input validation: */
  if (ParagonIE_Sodium_Core_Util::strlen($pk) < self::CRYPTO_SIGN_PUBLICKEYBYTES) {
    throw new SodiumException('Argument 1 must be at least CRYPTO_SIGN_PUBLICKEYBYTES long.');
  }
  if (self::useNewSodiumAPI()) {
    if (is_callable('crypto_sign_ed25519_pk_to_curve25519')) {
      return (string) sodium_crypto_sign_ed25519_pk_to_curve25519($pk);
    }
  }
  if (self::use_fallback('crypto_sign_ed25519_pk_to_curve25519')) {
    return (string) call_user_func('\\Sodium\\crypto_sign_ed25519_pk_to_curve25519', $pk);
  }
  if (PHP_INT_SIZE === 4) {
    return ParagonIE_Sodium_Core32_Ed25519::pk_to_curve25519($pk);
  }
  return ParagonIE_Sodium_Core_Ed25519::pk_to_curve25519($pk);
}