Skip to main content

Python SDK for Viper PQ Chain — post-quantum trust infrastructure, aligned with the viper-pq-1 launch architecture (ADR-053)

Project description

viper-pqchain — Python SDK

Python SDK for Viper PQ Chain — post-quantum trust infrastructure.

Requires Python 3.9+. Zero external dependencies (uses only urllib from the standard library).

Installation

pip install viper-pqchain

Or from source:

cd sdk/python
pip install -e .

Quick start

from viper_pqchain import ViperClient

client = ViperClient("http://localhost:9000")

# Chain status
status = client.get_status()
print(f"Height: {status.height}  chain: {status.chain_id}")

# Fetch an account
account = client.get_account("01" * 32)
print(f"Balance: {account.balance} venom  nonce: {account.nonce}")

# Fetch a block
block = client.get_block(1)
print(f"Block 1 proposer: {block.header.proposer_address}")

# List validators
validators = client.get_validators()
for v in validators:
    print(f"  {v.address}  status={v.status}  stake={v.stake} venom")

Fee estimation

from viper_pqchain import ViperClient

client = ViperClient("http://localhost:9000")
calc = client.get_fee_calculator()

est = calc.estimate("vault_create", payload_bytes=256)
print(f"Estimated fee: {est.total_venom} venom")
print(f"  base:      {est.breakdown.base_fee_venom}")
print(f"  bytes:     {est.breakdown.byte_fee_venom}")
print(f"  sigverify: {est.breakdown.sigverify_fee_venom}")
print(f"  execution: {est.breakdown.execution_fee_venom}")

Building unsigned transactions

from viper_pqchain.tx import build_vault_create, build_vault_transfer, build_attestation_create
from viper_pqchain.types import VaultCreateParams, VaultTransferParams, AttestationCreateParams
import json

# Vault creation
tx = build_vault_create(
    VaultCreateParams(
        sender="01" * 32,
        nonce=0,
        alg_id="ml-dsa-65",
        public_key="<hex-encoded-ml-dsa-65-public-key>",
    ),
    fee_budget_venom=20_000,
)
print(json.dumps(tx, indent=2))

# Token transfer
tx = build_vault_transfer(
    VaultTransferParams(
        sender="01" * 32,
        nonce=1,
        recipient="02" * 32,
        amount_venom=10**18,  # 1 VPR
    ),
    fee_budget_venom=15_500,
)

# Attestation
tx = build_attestation_create(
    AttestationCreateParams(
        sender="01" * 32,
        nonce=2,
        subject="03" * 32,
        schema_id="aa" * 32,
        payload_hex="deadbeef",
    ),
    fee_budget_venom=18_512,
)

Signing workflow

ML-DSA (FIPS 204) has no mature Python implementation as of 2026. Signing must be performed externally:

# 1. Build the unsigned tx JSON (as above) and save it
python my_script.py > unsigned_tx.json

# 2. Sign with the pqcd CLI
pqcd sign-tx --tx-json unsigned_tx.json --key-file my_key.pem > signed_tx.hex

# 3. Submit
from viper_pqchain import ViperClient

client = ViperClient("http://localhost:9000")
cbor_hex = open("signed_tx.hex").read().strip()
result = client.submit_tx(cbor_hex)
print(result.status, result.tx_hash)

VPR / venom conversion

from viper_pqchain.utils import venom_to_vpr, vpr_to_venom

print(venom_to_vpr(10**18))          # "1.000000000000000000"
print(vpr_to_venom("1.5"))           # 1500000000000000000

Error handling

from viper_pqchain import ViperClient, ViperError

client = ViperClient("http://localhost:9000")
try:
    account = client.get_account("00" * 32)
except ViperError as e:
    print(e.status_code, e.code, str(e))

API reference

Method Endpoint Returns
get_status() GET /v1/status ChainStatus
get_block(height) GET /v1/blocks/:height Block
get_block_by_hash(hash) GET /v1/blocks/:hash Block
get_transaction(tx_hash) GET /v1/txs/:hash Transaction
submit_tx(cbor_hex) POST /v1/txs SubmitTxResponse
get_account(address) GET /v1/accounts/:address Account
get_attestation(id) GET /v1/attestations/:id Attestation
get_account_attestations(address) GET /v1/accounts/:address/attestations list[Attestation]
get_validators() GET /v1/validators list[Validator]
get_validator(address) GET /v1/validators/:address Validator
get_governance_parameters() GET /v1/governance/parameters GovernanceParameters
get_fee_calculator() fetches params, returns calculator FeeCalculator

Running tests

cd sdk/python
python -m pytest tests/ -v

26 tests, 0 failures.

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

viper_pqchain-0.2.0.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

viper_pqchain-0.2.0-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file viper_pqchain-0.2.0.tar.gz.

File metadata

  • Download URL: viper_pqchain-0.2.0.tar.gz
  • Upload date:
  • Size: 18.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for viper_pqchain-0.2.0.tar.gz
Algorithm Hash digest
SHA256 fcf4116f28d83874f76818575a88dc1513730731d03e54b6e29641f056e850e8
MD5 7698f53587984dfe7db0202ae25e6b84
BLAKE2b-256 966aef5a72993ba7524746fb4d96ef3201c44266ee81cea53ee65aedda7de942

See more details on using hashes here.

File details

Details for the file viper_pqchain-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: viper_pqchain-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for viper_pqchain-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0425372313264e8129e7b7b0b1987ba47829c0d9d586b1a495577e844908ce7d
MD5 35873afb216da24ccfb061b40c5103c0
BLAKE2b-256 55c5338a849b03c027c7927f28ba2157c0e9a9e1d30b1162424fb3c21a585d55

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page