Skip to main content
This article explains how to authenticate your API requests to the Cobo payments service. To ensure secure access to your crypto assets, the Cobo payments service requires you to use an EdDSA signature to sign each of your API requests, except for publicly accessible API operations. You need to provide your API key, a nonce, and an API signature as request headers:
  • Biz-Api-Key: The API key used for the request. For more details, refer to API key.
  • Biz-Api-Nonce: The nonce. A nonce is the current time in Unix timestamp format, measured in milliseconds.
  • Biz-Api-Signature: The API signature. To learn how to calculate an API signature, see Calculate an API Signature.
If you are using Cobo’s Payments API SDKs, you only need to provide your API secret because the SDKs handles the remaining steps for you.

API key and API secret

To enable secure and authenticated communication between clients and the Cobo payments service, a mechanism based on the API key and API secret is used. This mechanism relies on cryptographic key pairs to verify the identity of the client and the integrity of the requests.

API key

The API key is the public key in the cryptographic key pair. It is used to identify the client making the API request.

API secret

The API secret is the private key in the key pair. It is used to sign API requests, guaranteeing their authenticity and integrity. The API secret must always remain confidential and secure to prevent unauthorized access. The API key and API secret work as a pair to secure communication with the Cobo payments service:
  • The API key is included in API requests to identify the client to the Cobo payments service. It is required to be registered on Cobo Portal.
  • The API secret is used to generate a signature for each API request. The Cobo payments service validates the signature to confirm the request’s authenticity and prevent tampering.

Generate an API key and an API secret

This section introduces three ways to generate an API key and an API secret using the Ed25519 algorithm. You can also generate them using other tools that use the Ed25519 algorithm. The public key will be used as an API key, and the private key will be used as an API secret.

Use OpenSSL

In a terminal window, run the following OpenSSL commands to generate a key pair using the Ed25519 algorithm:
You will see the output similar to the following example:
Use the Private Key (Hex) as your API secret and the Public Key (Hex) as your API key.

Use the Python library

  1. Install the PyNaCl Python library. In a terminal window, run the following command:
  2. Generate a key pair. Import the function from the Python library to generate a key pair using the Ed25519 algorithm as follows:

Register the API key

After generating an API key, you need to register the key on Cobo Portal. To learn how to register an API key, see Send your first request.

Nonce

A nonce is the current time in Unix timestamp format, measured in milliseconds.

Calculate the API signature

The following steps introduce how to calculate an API signature.
  1. First, concatenate a string based on your request as follows: str_to_sign = {METHOD}|{PATH}|{TIMESTAMP}|{PARAMS}|{BODY}
  2. Use the hashlib library to perform SHA-256 hashing twice on the string as follows:
  3. Use the API secret to sign the string as follows:
Now you’ve calculated an API signature.