sgx storage client
Project description
SGX Storage Client
- Overview
- Features
- Security Notes
- Installation
- Components
- Usage Examples
- [Key & Passphrase Generation](#Key and passphrase Generation)
- [Sgx client initialization](#Sgx client initialization)
- Exchange Account Management
- Address Management
- Whitelist Management
- User Management
- Configurations
Overview
A secure Python client for Intel SGX enclave communication implementing DCAP remote attestation and AES-GCM encrypted sessions. Designed for managing sensitive configurations in trusted execution environments.
Features
- Secure Session Protocol - Ephemeral ECDH key exchange + AES-128-GCM encryption
- DCAP Remote Attestation - Verify enclave identity through DCAP QVS
- Complete Management API:
- Exchange account credentials storage
- Blockchain address whitelisting
- Multi-role user access control
- Network/currency configuration management
- Production-Ready Security:
- MRSIGNER-based enclave verification
- Anti-replay protection with session nonce
- CMAC-based key derivation (NIST SP 800-108)
- Hardware-rooted trust chain
Security Notes
- Ensure private keys are never stored unencrypted or logged.
- Always validate the enclave’s identity via DCAP unless explicitly testing.
- Use strong passphrases (≥ 16 characters or ≥ 12 mnemonic words).
- Consider hardware protection (e.g. TPM, HSM) for production deployment.
- Ensure TLS is used in transport when communicating with enclaves.
Installation
pip install sgx-storage-client
Components
-
SGX Client (
client.py):The core interface for communication with the SGX enclave.
-
Attestation Module (
attestation.py):Provides functionality for remote attestation, ensuring that the enclave is trusted.
-
Key Provider (
key_provider.py):Contains RawPrivateKeyProvider (or other providers) to manage private key operations securely based on external configuration. You can implement your own key provider by implementing the ECDHProvider methods.
-
Session Handler (
session.py):Manages secure session establishment, key exchange, and encrypted payload handling.
-
Key Generation (
keygen.py):Generates high‑entropy, Diceware‑style passphrases and other keys as needed for additional security.
Example usage
Key and passphrase Generation
The keygen.py module provides two main functionalities:
Deterministic Key Pair Generation
You can deterministically generate an EC key pair from a passphrase. This process uses:
- PBKDF2-HMAC-SHA512 to derive a 64-byte seed from the passphrase.
- HMAC-SHA512 to compute a scalar from a constant seed and the derived seed.
- The scalar is then used to build the EC private key on the SECP256R1 curve, and its associated public key is returned as concatenated bytes (X||Y).
Example:
from sgx.keygen import generate_key_pair_from_passphrase
# Generate the key pair deterministically from a passphrase
passphrase = "correct horse battery staple"
public_key_bytes, private_scalar = generate_key_pair_from_passphrase(passphrase)
Diceware‑Style Passphrase Generation
The generate_passphrase function creates high‑entropy passphrases by selecting random words from a supplied wordlist (https://www.eff.org/dice). You can customize options such as the number of words, delimiter, capitalization, and appending a random digit.
Example:
from sgx.keygen import generate_passphrase
#Generate a 7-word passphrase with title-cased words and a trailing digit
passphrase = generate_passphrase(num_words=7)
Sgx client initialization
Variables:
- MR_SIGNER – Enclave fingerprint (MRSIGNER).
- DCAP_URL – DCAP attestation service URL.
- PRIVATE_VALUE – Your private key as an integer.
- HOST – Enclave server host.
- PORT – Enclave server port.
- SP_ID – Service Provider ID (SPID).
from sgx.client import SgxClient
from sgx.attestaion import SGXAttestationVerifier
from sgx.ecdh_provider import RawPrivateKeyProvider
# Initialize the attestation verifier
verifier = SGXAttestationVerifier(
mr_signer="a1b2c3d4e5f6...", # Trusted enclave fingerprint
dcap_url="https://qvs.example.com/qvs/attestation/sgx/dcap/v1/report",
is_debug=False # Default is False, check that the enclave is not in debug mode
)
# Initialize the private key provider
key_provider = RawPrivateKeyProvider(private_value=int('6805925192601811...44757182820103'))
client = SgxClient(
host="enclave.example.com",
port=2241,
spid="11223344556677889900AABBCCDDEEFF", # 16-byte hex Service Provider ID
key_provider=key_provider, # Private key for enclave authentication
attestation_verifier=verifier, # Optional, use None to skip dcap verification
)
Exchange Account Management
client.get_accounts()
client.add_account(
name='main-account',
exchange='binance',
public_key='public-key',
key='sercret-key',
sorting_key=1,
additional_data={}
)
client.update_account(
account_id='1binance',
name='secondary-account',
public_key='public-key',
key='secret-key',
sorting_key=1,
additional_data={}
)
client.del_account('1binance')
Address Management
client.get_standalone_addresses()
client.add_standalone(
address='0xC8CD2BE653759aed7B0996315821AAe71e1FEAdF',
network='ETHEREUM',
alias='eth-address',
whitelist=True,
multisig=False,
currencies=['ETH', 'USDT'],
sorting_key=1
)
client.update_standalone(
address='0xC8CD2BE653759aed7B0996315821AAe71e1FEAdF',
network='ETHEREUM',
alias='eth-address-2',
whitelist=True,
multisig=False,
currencies=[],
sorting_key=1
)
client.del_standalone(address='0xC8CD2BE653759aed7B0996315821AAe71e1FEAdF', network='ETHEREUM')
Whitelist Management
client.get_whitelist()
client.add_whitelist(
address='0xC8CD2BE653759aed7B0996315821AAe71e1FEAdF',
network='ETHEREUM',
alias='trusted-address',
currencies=[],
sorting_key=1
)
client.update_whitelist(
address='0xC8CD2BE653759aed7B0996315821AAe71e1FEAdF',
network='ETHEREUM',
alias='trusted-address-2'
)
client.del_whitelist(
address='0xC8CD2BE653759aed7B0996315821AAe71e1FEAdF',
network='ETHEREUM',
)
User Management
client.get_users()
client.add_user(
user='test@gamil.com',
role='FULL_ACCESS',
sorting_key=2
)
client.update_user(user='test@gamil.com', role='READ_ONLY', sorting_key=2)
client.del_user('test@gamil.com')
client.reset_user_hotp('test@gamil.com')
configurations
client.get_network_coins()
client.get_status()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sgx_storage_client-0.0.4.tar.gz.
File metadata
- Download URL: sgx_storage_client-0.0.4.tar.gz
- Upload date:
- Size: 17.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69483cc09f1bfe1c568a6b6639a98844b6ddf12e3118956d56c696955bb96e50
|
|
| MD5 |
6011042f95ac142b9ab20d4cc792aa85
|
|
| BLAKE2b-256 |
1ed92df7fff547529d78ce97db5b82e83b8c87742244ea307d537f114306f440
|
File details
Details for the file sgx_storage_client-0.0.4-py3-none-any.whl.
File metadata
- Download URL: sgx_storage_client-0.0.4-py3-none-any.whl
- Upload date:
- Size: 17.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4234a8a181514e598eb3386ac8564499eba89e8ff0cfe8ef06673601bdaff910
|
|
| MD5 |
fab318b546c6f3e4230f9fbeea4ae1d3
|
|
| BLAKE2b-256 |
e366034c311371f8d654e3228d3caebd930731fedeb8ba93e227a896ea75f179
|