Skip to main content

proof_core/
limits.rs

1// Copyright 2026 Proof Engine Contributors
2// SPDX-License-Identifier: MIT OR Apache-2.0
3//! Enforced resource limits (not advisory). All configurable downward.
4
5/// All limits enforced in decoders, graph validation, and policy evaluation.
6#[derive(Debug, Clone, Copy)]
7// PE-SEC-001 ยท PE-FMT-006: enforced bounds, not advisories.
8pub struct Limits {
9    pub max_proof_size: usize,
10    pub max_field_size: usize,
11    pub max_depth: usize,
12    pub max_array_items: usize,
13    pub max_map_entries: usize,
14    pub max_evidence_items: usize,
15    pub max_nodes: usize,
16    pub max_edges: usize,
17    pub max_sig_size: usize,
18    pub max_policy_requirements: usize,
19    // V1.1: VerifyCtx input vector bounds (DoS prevention)
20    pub max_status_objects: usize,
21    pub max_trusted_issuers: usize,
22    pub max_revocation_authorities: usize,
23}
24
25impl Default for Limits {
26    fn default() -> Self {
27        Self {
28            max_proof_size: 1024 * 1024, // 1 MiB
29            max_field_size: 64 * 1024,   // 64 KiB per text/bytes field
30            max_depth: 16,
31            max_array_items: 256,
32            max_map_entries: 64,
33            max_evidence_items: 64,
34            max_nodes: 128,
35            max_edges: 256,
36            max_sig_size: 256,
37            max_policy_requirements: 32,
38            // V1.1: VerifyCtx input bounds
39            max_status_objects: 64,
40            max_trusted_issuers: 32,
41            max_revocation_authorities: 16,
42        }
43    }
44}