Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<sodium_crypto_box_publickeysodium_crypto_box_seal>
^Sodium FunctionsLast updated: Mon, 26 Oct 2026

sodium_crypto_box_publickey_from_secretkey

(PHP 7 >= 7.2.0, PHP 8)

sodium_crypto_box_publickey_from_secretkey — Calculate the public key from a secret key

Description

function sodium_crypto_box_publickey_from_secretkey(#[\SensitiveParameter] string $secret_key): string

Given a secret key, calculate the corresponding public key.

This only works with the type of keys intended for use with crypto_box() (which uses Elliptic Curve Diffie-Hellman over the Montgomery curve, Curve25519; abbreviated as X25519), not crypto_sign() (which uses Edwards Digital Signature Algorithm over the Edwards Curve with the corresponding parameters; abbreviated Ed25519).

Parameters

secret_key

X25519 secret key

Return Values

X25519 public key.


<sodium_crypto_box_publickeysodium_crypto_box_seal>
^Sodium FunctionsLast updated: Mon, 26 Oct 2026