Prerequisites
You can create asymmetric keys in any Nebius AI Cloud interface. To sign hashes, use the Nebius AI Cloud CLI. To verify signatures, use a local cryptographic tool such as OpenSSL.- Make sure that OpenSSL is installed on your local machine. In this guide, you use it to generate a local hash of a file and verify a returned signature with a public key locally.
- Install and configure the Nebius AI Cloud CLI.
- Make sure you are in a group that has at least the
editorrole within your tenant or project; for example, the defaulteditorsgroup. You can check this in the Administration → IAM section of the web console.
Steps
Create an asymmetric key
- Web console
- CLI
-
In the web console, go to
Cryptography → KMS.
-
Click
Create key.
-
On the key creation page:
- In the Name field, enter
my-asymmetric-key. - In the Type field, select Asymmetric key.
- In the Algorithm field, select ECC (P-256) to create a key that you can use for digital signature workflows.
- In the Name field, enter
- Click Create key.
KEY_ID environment variable:Get the public key
- Web console
- CLI
- In the web console, go to
Cryptography → KMS.
- Select Asymmetric keys and click the key you created.
- On the Key’s overview tab, next to Public key, click
.
- Create the
public_key.pemfile with the copied contents.
Sign a hash
-
Create the
hello.txtfile: -
Generate a SHA-256 hash of the file and encode it in Base64:
The command returns a Base64-encoded hash value that you need to provide for signing and saves it to the
HASH_B64environment variable. -
Send the hash value to KMS to sign it with your asymmetric key:
This command includes the following parameters:
--key-id: ID of the asymmetric key that you created.--hash: Base64-encoded hash value generated in the previous step.--format jsonpath='{.signature}': Returns only thesignaturevalue.
signature.b64file.
Verify the signature
Verify the signature to confirm that it was created with the matching private key and that the file was not changed after it was signed.-
Decode the saved signature in the
signature.b64file, convert it to binary form and save it to thesignature.binfile:OpenSSL uses the binary form of the signature for verification. Therefore, you need thesignature.binfile in the next step. -
Verify the signature with the public key:
This command includes the following parameters:
-sha256: Hash function that matchesecdsa_nist_p256_sha_256.-verify: Uses the public key file to check whether the signature was created with the matching private key.-signature: Specifies the signature file to use for verifying the signature.hello.txt: File that OpenSSL checks against the signature.