You are here

public static function ParagonIE_Sodium_Compat::crypto_sign_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_sign_secretkey()

Extract an Ed25519 secret key from an Ed25519 keypair.

@psalm-suppress MixedArgument

Parameters

string $keypair Keypair:

Return value

string Secret key

Throws

SodiumException

TypeError

2 calls to ParagonIE_Sodium_Compat::crypto_sign_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 2783

Class

ParagonIE_Sodium_Compat

Code

public static function crypto_sign_secretkey($keypair) {

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

  /* Input validation: */
  if (ParagonIE_Sodium_Core_Util::strlen($keypair) !== self::CRYPTO_SIGN_KEYPAIRBYTES) {
    throw new SodiumException('Argument 1 must be CRYPTO_SIGN_KEYPAIRBYTES long.');
  }
  if (self::useNewSodiumAPI()) {
    return sodium_crypto_sign_secretkey($keypair);
  }
  if (self::use_fallback('crypto_sign_secretkey')) {
    return (string) call_user_func('\\Sodium\\crypto_sign_secretkey', $keypair);
  }
  if (PHP_INT_SIZE === 4) {
    return ParagonIE_Sodium_Core32_Ed25519::secretkey($keypair);
  }
  return ParagonIE_Sodium_Core_Ed25519::secretkey($keypair);
}