sodium_crypto_sign_seed_keypair constructs a public/secret keypair for the selected cryptographic scheme.
The examples explain the data format, expected results and the difference between this API and nearby cryptographic operations.
What It Does
The operation is intended for: sodium_crypto_sign_seed_keypair constructs a public/secret keypair for the selected cryptographic scheme.
The sodium extension must be enabled.
Syntax and Return Value
sodium_crypto_sign_seed_keypair(string $seed): string
| Parameter | Purpose |
|---|---|
| $seed (string) | Use the PHP signature above to determine the exact expected input type; validate untrusted inputs before calling. |
The declared return type is shown above. Errors can include false results or exceptions depending on this API: Secret signing keys must stay private; signatures authenticate bytes but not the signer identity unless the public key is trusted.
Example 1: Basic Operation
Ed25519 signing authenticates data, but does not conceal it; public-key trust must be established separately.
<?php
$seed = random_bytes(SODIUM_CRYPTO_SIGN_SEEDBYTES);
$pair = sodium_crypto_sign_seed_keypair($seed);
echo strlen($pair);
Example 2: A Different Use Case
Inspect the public signing key and confirm its size without revealing the private signing key.
<?php
// Check the alternative case.
$seed = random_bytes(SODIUM_CRYPTO_SIGN_SEEDBYTES);
$pair = sodium_crypto_sign_seed_keypair($seed);
var_dump(strlen($pair) === SODIUM_CRYPTO_SIGN_KEYPAIRBYTES);
Practical Example: Checking the Result
Inspect the public signing key and confirm its size without revealing the private signing key.
<?php
// Verify the expected behavior before using results.
$seed = random_bytes(SODIUM_CRYPTO_SIGN_SEEDBYTES);
$pair = sodium_crypto_sign_seed_keypair($seed);
echo bin2hex(sodium_crypto_sign_publickey($pair));
Important Behavior and Edge Cases
Secret signing keys must stay private; signatures authenticate bytes but not the signer identity unless the public key is trusted.
Signatures must be verified against an authentic public key. A valid signature is not proof that a public key belongs to a particular identity.
Comparison with Related Functions
| Approach | Key distinction |
|---|---|
| sodium_crypto_sign_seed_keypair | sodium_crypto_sign_seed_keypair constructs a public/secret keypair for the selected cryptographic scheme. |
| Related technique | sodium_crypto_auth authenticates between holders of one shared symmetric key. |
Common Beginner Mistakes
| Mistake | Correct approach |
|---|---|
| Confusing this operation with a neighboring cryptographic or security mechanism | sodium_crypto_auth authenticates between holders of one shared symmetric key. |
| Ignoring a security prerequisite or failure case | Secret signing keys must stay private; signatures authenticate bytes but not the signer identity unless the public key is trusted. |
Key Takeaways
- sodium_crypto_sign_seed_keypair constructs a public/secret keypair for the selected cryptographic scheme.
- Secret signing keys must stay private; signatures authenticate bytes but not the signer identity unless the public key is trusted.
- sodium_crypto_auth authenticates between holders of one shared symmetric key.
Apply this behavior to a real application only after confirming the required extension, configuration and failure handling on the deployment runtime.