qtrust-sdk
Q-Trust SDK — verifiable post-quantum cryptography migration provenance on Base L2. Register Cryptographic Bills of Materials (CBOM) on-chain, pin evidence to IPFS, issue/verify W3C Verifiable Credentials, score quantum risk, and evaluate compliance frameworks.
Install
cd sdk && pip install -e ".[dev]"
Quickstart
from qtrust import QTrustClient, CBOM, CBOMEntry
client = QTrustClient(
private_key="0x...",
rpc_url="https://sepolia.base.org",
asset_registry_address="0x...",
)
cbom = CBOM(
org_did="did:ethr:0x...",
generated_at=1700000000,
scanner_version="1.1.0",
assets=[CBOMEntry(asset_type="tls_cert", algorithm="RSA-2048", location="example.com:443")],
)
asset_id, cid = client.register_cbom(cbom)
IPFS pinning
Pinning is provider-pluggable. The first configured provider is primary; its
CID is returned by pin_json() / pin_file(). Additional providers pin
best-effort concurrently (ThreadPoolExecutor); CID mismatches are logged as
warnings. If the primary fails, the first successful fallback CID is returned
with a warning; if every provider fails, the error is raised.
from qtrust.ipfs import create_ipfs_client
ipfs = create_ipfs_client() # built from environment variables
cid = ipfs.pin_json('{"cbom": true}', name="qtrust-cbom")
Environment variables
| Variable | Purpose |
|---|---|
QTRUST_BASE_SEPOLIA_RPC |
RPC endpoint (default http://127.0.0.1:8545) |
QTRUST_CHAIN_ID |
Expected chain ID (default 84532) |
QTRUST_DEPLOYER_PRIVATE_KEY |
Signer key (omit for read-only mode) |
QTRUST_ASSET_REGISTRY_ADDRESS |
Deployed AssetRegistry |
QTRUST_VENDOR_REGISTRY_ADDRESS |
Deployed VendorRegistry |
QTRUST_MIGRATION_REGISTRY_ADDRESS |
Deployed MigrationRegistry |
QTRUST_AUDIT_REGISTRY_ADDRESS |
Deployed AuditRegistry |
QTRUST_GOVERNANCE_ADDRESS |
Deployed QTrustGovernance |
QTRUST_PINATA_API_KEY / QTRUST_PINATA_API_SECRET |
Pinata credentials (provider pinata) |
QTRUST_IPFS_PROVIDERS |
Comma-separated provider list; default pinata. Order = priority (first is primary). Supported: pinata, kubo, web3 |
QTRUST_IPFS_KUBO_API |
Kubo RPC endpoint (default http://127.0.0.1:5001) |
QTRUST_IPFS_KUBO_USER / QTRUST_IPFS_KUBO_PASS |
Optional basic auth for Kubo |
QTRUST_WEB3_STORAGE_TOKEN |
Bearer token for web3.storage (provider web3) |
Relay nonce management
Gasless registrations (CBOM, vendor attestations, migrations) are authorized
with EIP-712 signatures consumed by a relayer. Nonces are per-signer,
per-registry: each registry (AssetRegistry, VendorRegistry,
MigrationRegistry) maintains its own nonces[signer] mapping that increments
on-chain every time a signed submission is accepted.
Operational rules:
- Fetch immediately before signing. Always retrieve the signer's current
nonce right before signing via the relay service's read endpoints
(
GET /v1/relay/cbom-nonce/:didfor CBOM registration,GET /v1/relay/nonce/:didfor vendor attestations). The SDK equivalents areQTrustClient.sign_cbom_registration(...)/sign_attestation(...)withnonce=None, which fetch on-chain state for you. - Concurrent submissions from the same signer race. Two signed payloads
sharing one nonce cannot both land: whichever transaction confirms second
reverts with the registry's
InvalidNonce(signer, provided, expected)(orInvalidSignature()if the relayer pre-checks). This is expected replay protection, not a bug. - Retry pattern = refetch + resign. On a nonce/replay failure, do NOT reuse the old signature: refetch the current nonce, re-sign the payload with it, and resubmit.
Testing
cd sdk && python -m pytest tests -q
Tests run offline; network-dependent tests mock HTTP or skip when no local
anvil node is available (tests/e2e_anvil.py covers the live path).
Metadata
Release files for qtrust-sdk 2.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| qtrust_sdk-2.3.0.tar.gz | 56.1 kB | Without provenance | Details for qtrust_sdk-2.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| qtrust_sdk-2.3.0-py3-none-any.whl | Python 3 | none | any | Details for qtrust_sdk-2.3.0-py3-none-any.whl |
Total release size: 100.8 kB
Release files / qtrust_sdk-2.3.0.tar.gz
| Download URL | qtrust_sdk-2.3.0.tar.gz |
|---|---|
| Size | 56.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a290521036aa3a9fde48dd059d5f10e6a7e110cfa50a460843d0ddd16a546f7c
|
|
BLAKE2b-256 checksum How to use checksums |
0f6da7376ba80bb8c9e637afaa43ed3a525245b8a4fa8043ffee7ee1d5a2beb6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.6
|
Release files / qtrust_sdk-2.3.0-py3-none-any.whl
| Download URL | qtrust_sdk-2.3.0-py3-none-any.whl |
|---|---|
| Size | 44.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2c968fae8303c1ccecfd8a7306a842239186866fbb4a8f91a82ff03ebb197ddb
|
|
BLAKE2b-256 checksum How to use checksums |
5db3a34cf914ac9c83d600a2efc6d6534f31604eec4ad71d2ad7f3167c333f72
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.6
|
Security for qtrust-sdk 2.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.