Generate Keys

POST /v1/keys/generate Generate a post-quantum cryptographic key pair. The key pair is generated server-side and returned to the client. Authentication: Secret key required (qs_sec_*)
When using the SDK, key generation happens locally on the client and never touches the server. This endpoint is for direct API usage where client-side generation is not available.

Request

{
  "algorithm": "ml-dsa-65",
  "chain": "ethereum",
  "format": "hex"
}

Parameters

FieldTypeRequiredDescription
algorithmstringYesPQC algorithm to use
chainstringYesTarget blockchain
formatstringNoKey encoding format. Default: hex

Algorithm Enum

ValueNIST StandardSecurity LevelKey Size
ml-dsa-44FIPS 2042 (128-bit)~1.3 KB
ml-dsa-65FIPS 2043 (192-bit)~1.9 KB
ml-dsa-87FIPS 2045 (256-bit)~2.6 KB
slh-dsa-128sFIPS 2051 (128-bit)~32 B

Chain Enum

ValueDescription
ethereumEthereum and EVM-compatible chains
bitcoinBitcoin mainnet
solanaSolana
polygonPolygon PoS
avalancheAvalanche C-Chain

Format Enum

ValueDescription
hexHex-encoded string (default)
base64Base64-encoded string
rawRaw bytes (binary response)

Response 201 Created

{
  "data": {
    "id": "key_abc123def456",
    "algorithm": "ml-dsa-65",
    "chain": "ethereum",
    "publicKey": "0x7a2b3c4d5e6f...",
    "privateKey": "0x1a2b3c4d5e6f...",
    "format": "hex",
    "createdAt": "2026-01-15T10:30:00Z"
  },
  "meta": {
    "requestId": "req_xyz789",
    "timestamp": "2026-01-15T10:30:00Z"
  }
}

Response Fields

FieldTypeDescription
idstringUnique key pair identifier
algorithmstringAlgorithm used
chainstringTarget chain
publicKeystringPublic key in requested format
privateKeystringPrivate key in requested format
formatstringEncoding format
createdAtstringISO 8601 timestamp
The privateKey is returned only once in this response. QuantumSafe does not store it. If you lose the private key, you cannot recover it.

Errors

CodeDescription
AUTH_001Missing API key
AUTH_003Publishable key used (Secret key required)
PQC_001Unsupported algorithm
GEN_001Invalid algorithm/chain combination
GEN_002Internal generation error
RATE_001Rate limit exceeded

Example

curl -X POST https://api.qsafe.dev/v1/keys/generate \
  -H "Authorization: Bearer qs_sec_live_sk_abc123..." \
  -H "Content-Type: application/json" \
  -d '{
    "algorithm": "ml-dsa-65",
    "chain": "ethereum",
    "format": "hex"
  }'