Skip to main content
This article explains how to authenticate your API requests to the WaaS service using Cobo Auth.
If you are using Cobo’s WaaS SDKs, you can skip this topic because the SDKs already encapsulate the authentication mechanism for you.
To ensure secure access to your crypto assets, the WaaS 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 public key you generate in Generate an API key.
  • Biz-Api-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.

API key

The API key is used to identify the client making the API request. It is associated with a certain level of access to the API’s resources. Different API keys can be assigned with different permissions, allowing you to control what actions the client can perform.

Generate an API key

This section introduces how to generate an API key using the Ed25519 algorithm. You can use either OpenSSL or the Python library to generate an Ed25519 key pair. The public key will be used as an API key, and the private key will be used as an API secret to sign an API request.

Use OpenSSL

In a terminal window, run the following OpenSSL commands:
The private key is saved in the private.key.pem file, and the public key is saved in the public.key.pem file.

Use the Python library

  1. Install the ed25519 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 as follows:

Register the API key

After generating an API key, you need to register the key and configure related permissions on Cobo Portal. To learn how to register an API key, see Register an API key.

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 private key of your API key to sign the string as follows:
Now you’ve calculated an API signature.