Summery Summery

Extract the public key from a crypto_box keypair.

Syntax Syntax

ParagonIE_Sodium_Compat::crypto_box_publickey( string $keypair )

Parameters Parameters


(string) (Required) Keypair containing secret and public key

Return Return

(string) Your crypto_box public key

Source Source

File: wp-includes/sodium_compat/src/Compat.php

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

        /* Input validation: */
        if (ParagonIE_Sodium_Core_Util::strlen($keypair) !== self::CRYPTO_BOX_KEYPAIRBYTES) {
            throw new SodiumException('Argument 1 must be CRYPTO_BOX_KEYPAIRBYTES long.');

        if (self::useNewSodiumAPI()) {
            return (string) sodium_crypto_box_publickey($keypair);
        if (self::use_fallback('crypto_box_publickey')) {
            return (string) call_user_func('\\Sodium\\crypto_box_publickey', $keypair);
        if (PHP_INT_SIZE === 4) {
            return ParagonIE_Sodium_Crypto32::box_publickey($keypair);
        return ParagonIE_Sodium_Crypto::box_publickey($keypair);



Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.