@stateset/ves-stark
Node.js bindings for the VES STARK proof system. Generate and verify zero-knowledge compliance proofs for VES events.
Installation
Requirements
- Node.js >= 14
- Supported platforms: Linux (x64, arm64), macOS (x64, arm64), Windows (x64)
Usage
Generate a Compliance Proof
const = require;
// Create policy parameters
const policyParams = ;
// Compute the policy hash
const policyHash = ;
// Create public inputs
const publicInputs = ;
// Generate proof (amount must be < threshold for aml.threshold)
const proof = ;
console.log;
console.log;
console.log;
console.log;
Verify a Proof
const = require;
const publicInputsBound = ;
// Use the hex form to avoid u64 round-trip issues in JavaScript.
const result = ;
if else
verify() and verifyHex() now bind 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:
const amountBinding = ;
const boundResult = ;
Agent Authorization Policy
const intentHash = '11'.;
const policyParams = ;
const policyHash = ;
const agentPublicInputs = ;
const proof = ;
If you also have the canonical authorization receipt, use verifyAgentAuthorizationHex(...) to
derive the payload amount binding from the receipt and verify the stronger receipt-bound
statement.
API Reference
prove(amount, publicInputs, policyType, policyLimit)
Generate a STARK compliance proof.
Parameters:
amount(bigint): The amount to prove compliance forpublicInputs(JsCompliancePublicInputs): Public inputs including event metadatapolicyType(string): Policy type -"aml.threshold","order_total.cap", or"agent.authorization.v1"policyLimit(bigint): The policy limit value
Returns: JsComplianceProof
proofBytes(Buffer): Raw proof bytesproofHash(string): SHA-256 hash of proofprovingTimeMs(number): Generation time in millisecondsproofSize(number): Size in byteswitnessCommitment(string[]): 4-element decimal commitment arraywitnessCommitmentHex(string): 64-character lowercase hex commitment (recommended)
verify(proofBytes, publicInputs, witnessCommitment)
Verify a STARK compliance proof.
Parameters:
proofBytes(Buffer): Raw proof bytes fromprove()publicInputs(JsCompliancePublicInputs): Must match proving inputs and includewitnessCommitmentwhen using canonical bound verificationwitnessCommitment(string[]): 4-element decimal array from proof
Returns: JsVerificationResult
valid(boolean): Whether proof is validverificationTimeMs(number): Verification time in millisecondserror(string | null): Error message if invalidpolicyId(string): Verified policy IDpolicyLimit(bigint): Verified policy limit
verifyHex(proofBytes, publicInputs, witnessCommitmentHex)
Verify a STARK compliance proof using the witness commitment hex string.
Parameters:
proofBytes(Buffer): Raw proof bytes fromprove()publicInputs(JsCompliancePublicInputs): Must match proving inputs and includewitnessCommitmentwhen using canonical bound verificationwitnessCommitmentHex(string): 64-character lowercase hex commitment (recommended)
Returns: JsVerificationResult
verifyAgentAuthorization(proofBytes, publicInputs, witnessCommitment, receipt)
Verify an agent.authorization.v1 proof against a canonical authorization receipt, deriving the
payload amount binding from receipt.amount.
verifyAgentAuthorizationHex(proofBytes, publicInputs, witnessCommitmentHex, receipt)
Verify an agent.authorization.v1 proof against a canonical authorization receipt using the hex
commitment form, deriving the payload amount binding from receipt.amount.
verifyWithAmountBinding(proofBytes, publicInputs, amountBinding)
Verify a proof against a canonical payload-derived amount binding.
verifyAgentAuthorizationWithAmountBinding(proofBytes, publicInputs, amountBinding, receipt)
Verify an agent.authorization.v1 proof against both a payload-derived amount binding and a
canonical authorization receipt. This is equivalent to the receipt-based helpers when the binding
matches receipt.amount, but keeps the artifact explicit.
computePolicyHash(policyId, policyParams)
Compute the canonical policy hash.
Parameters:
policyId(string): Policy identifier (e.g.,"aml.threshold")policyParams(object): Policy parameters
Returns: string - 64-character lowercase hex hash
createAmlThresholdParams(threshold)
Create policy parameters for AML threshold policy.
Parameters:
threshold(bigint): The threshold value
Returns: { threshold: bigint }
createOrderTotalCapParams(cap)
Create policy parameters for order total cap policy.
Parameters:
cap(bigint): The cap value
Returns: { cap: bigint }
createAgentAuthorizationParams(maxTotal, intentHash)
Create policy parameters for the delegated agent authorization policy.
Parameters:
maxTotal(bigint): The delegated maximum totalintentHash(string): 64-character commerce intent hash
Returns: { maxTotal: bigint, intentHash: string }
createPayloadAmountBinding(publicInputs, amount)
Create a canonical payload amount binding artifact for the supplied public inputs and extracted amount.
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 |
TypeScript Support
Full TypeScript definitions are included. Import types:
import {
prove,
verify,
computePolicyHash,
JsCompliancePublicInputs,
JsComplianceProof,
JsVerificationResult
} from '@stateset/ves-stark';
Building from Source
# Install dependencies
# Build release binary
# Build debug binary
Performance
Typical performance on modern hardware:
- Proof generation: 500-2000ms
- Proof verification: 50-200ms
- Proof size: ~100-200 KB
License
MIT