ves-stark
Python bindings for the VES STARK proof system. Generate and verify zero-knowledge compliance proofs for VES events.
Installation
Requirements
- Python >= 3.8
- Supported platforms: Linux (x64, arm64), macOS (x64, arm64), Windows (x64)
Usage
Generate a Compliance Proof
# Create a policy (AML threshold of 10,000)
=
# Compute the policy hash
=
# Create public inputs
=
# Generate proof (amount must be < threshold for aml.threshold)
=
Verify a Proof
=
=
# VerificationResult is also truthy/falsy
ves_stark.verify(...) now binds the supplied witness commitment into the public inputs before
verification, so local verification is witness-bound by default.
For payload-to-amount binding, derive a canonical binding artifact and verify against it directly:
=
=
API Reference
Classes
Policy
Represents a compliance policy.
# Create AML threshold policy (proves amount < threshold)
=
# Create order total cap policy (proves amount <= cap)
=
# Create agent authorization policy (proves amount <= maxTotal)
=
# Properties
# "aml.threshold", "order_total.cap", or "agent.authorization.v1"
# The threshold/cap/maxTotal value
CompliancePublicInputs
Public inputs for proof generation and verification.
=
# All fields are readable and writable
= 12346
ComplianceProof
Result of proof generation.
# bytes - raw proof data
# str - SHA-256 hash of proof
# int - generation time in ms
# int - size in bytes
# list[int] - 4-element commitment
# str - 64-char lowercase hex commitment
VerificationResult
Result of proof verification.
# bool - whether proof is valid
# int - verification time in ms
# str | None - error message if invalid
# str - verified policy ID
# int - verified policy limit
# Supports boolean conversion
Functions
prove(amount, public_inputs, policy)
Generate a STARK compliance proof.
=
Parameters:
amount(int): The amount to prove compliance forpublic_inputs(CompliancePublicInputs): Event metadata and policy infopolicy(Policy): The policy to prove compliance against
Returns: ComplianceProof
Raises:
ValueError: If inputs are invalidRuntimeError: If proof generation fails
verify(proof_bytes, public_inputs, witness_commitment)
Verify a STARK compliance proof.
=
Parameters:
proof_bytes(bytes): Raw proof bytes fromprove()public_inputs(CompliancePublicInputs): Must match proving inputs and includewitness_commitmentwhen using canonical bound verificationwitness_commitment(list[int]): 4-element list from proof
Returns: VerificationResult
Raises:
ValueError: If arguments are malformed
verify_agent_authorization(proof_bytes, public_inputs, witness_commitment, receipt)
Verify an agent.authorization.v1 proof against a canonical authorization receipt, deriving the
payload amount binding from receipt["amount"].
verify_with_amount_binding(proof_bytes, public_inputs, amount_binding)
Verify a proof against a canonical payload-derived amount binding.
verify_agent_authorization_with_amount_binding(proof_bytes, public_inputs, amount_binding, receipt)
Verify an agent.authorization.v1 proof against both a payload-derived amount binding and a
canonical authorization receipt. This is equivalent to verify_agent_authorization(...) when the
binding matches receipt["amount"], but keeps the artifact explicit.
create_payload_amount_binding(public_inputs, amount)
Create a canonical payload amount binding artifact for the supplied public inputs and extracted amount.
compute_policy_hash(policy_id, policy_params)
Compute the canonical policy hash.
=
Parameters:
policy_id(str): Policy identifierpolicy_params(dict): Policy parameters
Returns: str - 64-character lowercase hex hash
Policy Types
| Policy | ID | Constraint | Use Case |
|---|---|---|---|
| AML Threshold | aml.threshold |
amount < threshold | Anti-money laundering compliance |
| Order Total Cap | order_total.cap |
amount <= cap | Order value limits |
| Agent Authorization | agent.authorization.v1 |
amount <= maxTotal | Delegated commerce execution |
Building from Source
Requires maturin:
# Create & activate a virtualenv (required for `maturin develop`)
# Install maturin
# Build and install in development mode
# Build release wheel
Performance
Typical performance on modern hardware:
- Proof generation: 500-2000ms
- Proof verification: 50-200ms
- Proof size: ~100-200 KB
Example: Full Round-Trip
# Setup
=
=
=
# Prove
= 5000 # Must be < 10000
=
# Verify
=
assert , f
License
MIT