Trying to generate the secret key from the keypair and I get the exception:
SodiumException secretkey should be SODIUM_CRYPTO_SIGN_SECRETKEYBYTES bytes
See my code below
if(file_exists($keypair)) {
$keypair = file_get_contents($keypair, FALSE, NULL);
dd(Keypair::fromSecretKey($keypair));
}
After running this, I get that sodium exception.
SodiumException
secretkey should be SODIUM_CRYPTO_SIGN_SECRETKEYBYTES bytes
at vendor/tightenco/solana-php-sdk/src/Keypair.php:73
69▕ static public function fromSecretKey($secretKey): Keypair
70▕ {
71▕ $secretKey = Buffer::from($secretKey)->toString();
72▕
➜ 73▕ $publicKey = sodium_crypto_sign_publickey_from_secretkey($secretKey);
74▕
75▕ return new static(
76▕ $publicKey,
77▕ $secretKey
+1 vendor frames
2 app/Console/Commands/Initializer.php:81
Tighten\SolanaPhpSdk\Keypair::fromSecretKey()
+13 vendor frames
16 artisan:37
Illuminate\Foundation\Console\Kernel::handle()
Quite simple, just need to json_decode the keypair and pass an array to the
fromSecretKey
function: