<?php

$config = [
    "private_key_type" => OPENSSL_KEYTYPE_EC,
    "curve_name" => "prime256v1" // REQUIRED by ZATCA
];

$res = openssl_pkey_new($config);

// Export private key (store securely)
openssl_pkey_export($res, $privateKey);

// Get public key
$details = openssl_pkey_get_details($res);
$publicKey = $details['key'];

file_put_contents('keys/private.pem', $privateKey);
file_put_contents('keys/public.pem', $publicKey);

