qsafe-sdk

QSafe - the Ruby gem for the QSafe PQC API

Post-quantum cryptography SaaS API supporting ML-KEM (Kyber) and ML-DSA (Dilithium) algorithms. Provides keypair management and cryptographic operations (encrypt, decrypt, sign, verify).

Authentication

  • JWT Bearer Token — user-based auth, obtained from /auth/login or /auth/register
  • API Key (header) — programmatic access via X-API-Key header
  • API Key (query) — programmatic access via ?api_key= query parameter

Quick Start

  1. Register → POST /auth/register
  2. Login → POST /auth/login → copy data.token
  3. Generate keypair → POST /generate-keypair
  4. Encrypt / Sign with the keypair ID

This SDK is automatically generated by the OpenAPI Generator project:

  • API version: 1.0.0
  • Package version: 1.0.0
  • Generator version: 7.9.0
  • Build package: org.openapitools.codegen.languages.RubyClientCodegen

Installation

Build a gem

To build the Ruby code into a gem:

gem build qsafe-sdk.gemspec

Then either install the gem locally:

gem install ./qsafe-sdk-1.0.0.gem

(for development, run gem install --dev ./qsafe-sdk-1.0.0.gem to install the development dependencies)

or publish the gem to a gem hosting service, e.g. RubyGems.

Finally add this to the Gemfile:

gem 'qsafe-sdk', '~> 1.0.0'

Install from Git

If the Ruby gem is hosted at a git repository: https://github.com/qsafe/sdk-ruby, then add the following in the Gemfile:

gem 'qsafe-sdk', :git => 'https://github.com/qsafe/sdk-ruby.git'

Include the Ruby code directly

Include the Ruby code directly using -I as follows:

ruby -Ilib script.rb

Getting Started

Please follow the installation procedure and then run the following code:

# Load the gem
require 'qsafe-sdk'

# Setup authorization
QSafe.configure do |config|
  # Configure Bearer authorization (JWT): BearerAuth
  config.access_token = 'YOUR_BEARER_TOKEN'
  # Configure a proc to get access tokens in lieu of the static access_token configuration
  config.access_token_getter = -> { 'YOUR TOKEN GETTER PROC' } 
end

api_instance = QSafe::APIKeysApi.new
create_api_key_request = QSafe::CreateApiKeyRequest.new({name: 'Production API Key'}) # CreateApiKeyRequest | 

begin
  #Create API key (JWT only)
  result = api_instance.create_api_key(create_api_key_request)
  p result
rescue QSafe::ApiError => e
  puts "Exception when calling APIKeysApi->create_api_key: #{e}"
end

Documentation for API Endpoints

All URIs are relative to https://rushikesh66-pqc-api.hf.space

Class Method HTTP request Description
QSafe::APIKeysApi create_api_key POST /api-keys Create API key (JWT only)
QSafe::APIKeysApi get_api_key GET /api-keys/keyId Get API key details (JWT only)
QSafe::APIKeysApi get_api_key_usage GET /api-keys/keyId/usage Get API key usage stats (JWT only)
QSafe::APIKeysApi list_api_keys GET /api-keys List API keys (JWT only)
QSafe::APIKeysApi rotate_api_key POST /api-keys/keyId/rotate Rotate API key — generates new key value (JWT only)
QSafe::APIKeysApi update_api_key PATCH /api-keys/keyId Update API key (JWT only)
QSafe::AuthenticationApi change_password POST /auth/change-password Change password (JWT only)
QSafe::AuthenticationApi get_auth_info GET /auth/info Get current auth context (JWT or API key)
QSafe::AuthenticationApi login_user POST /auth/login Login and get JWT token
QSafe::AuthenticationApi register_user POST /auth/register Register a new user
QSafe::CryptographicOperationsApi decrypt_data POST /keypairs/keypairId/decrypt Decrypt data with a keypair's private key
QSafe::CryptographicOperationsApi encrypt_data POST /keypairs/keypairId/encrypt Encrypt data with a keypair's public key
QSafe::CryptographicOperationsApi sign_data POST /keypairs/keypairId/sign Sign data with a keypair's private key
QSafe::CryptographicOperationsApi verify_signature POST /keypairs/keypairId/verify Verify a signature
QSafe::DebugApi debug_redis_test GET /debug/redis-test Test Redis and internal services
QSafe::HealthApi get_health GET /health Health check
QSafe::KeypairsApi generate_keypair POST /generate-keypair Generate a new keypair
QSafe::KeypairsApi list_keypairs GET /keypairs List keypairs
QSafe::KeypairsApi revoke_keypair PATCH /keypairs/keypairId/revoke Revoke a keypair
QSafe::KeypairsApi update_keypair PATCH /keypairs/keypairId Update keypair metadata / tags
QSafe::UtilitiesApi get_rate_limit_status GET /rate-limit/status Get rate limit status for the current API key

Documentation for Models

Documentation for Authorization

Authentication schemes defined for the API:

BearerAuth

  • Type: Bearer authentication (JWT)

ApiKeyHeader

  • Type: API key
  • API key parameter name: X-API-Key
  • Location: HTTP header

ApiKeyQuery

  • Type: API key
  • API key parameter name: api_key
  • Location: URL query string