/ components / alpha / A003-circuits.component.cspec
A003-circuits.component.cspec
  1  # A003-circuits.component.cspec
  2  
  3  metadata:
  4    id: A003
  5    name: circuits
  6    version: 1.0.0
  7    domain: alpha
  8    stability: high_change
  9    updated: 2026-01-07
 10    cascade_priority: 20
 11    roles:
 12      primary: [Dev]
 13      review: [Security]
 14    expertise:
 15      required: [zk_proofs, cryptography, rust]
 16      helpful: [snarkvm, aleo]
 17    context_tags: [circuits, transfer, mint, burn, lock, unlock]
 18  
 19  dependencies:
 20    upstream: [A002]
 21    downstream: []
 22  
 23  interface:
 24    types_ref: _registry/types.cspec
 25    types:
 26      XFER_PRIV: transfer_private, inputs:records, outputs:records, reveals:serial_nums_only
 27      XFER_MULTI: transfer_multisig, inputs:records, outputs:records, multisig:true
 28      XFER_DEPT: transfer_departmental, inputs:records, outputs:records, multisig:nested
 29      MINT: mint_public, caller:GOV, audited:yes
 30      LOCK: lock_for_sax, ax_to_pool, triggers:sax_mint
 31      UNLOCK: unlock_ax, sax_burn, releases:ax_from_pool
 32    functions:
 33      transfer_private: private_record_transfer
 34      transfer_multisig: shared_account_transfer
 35      transfer_departmental: departmental_transfer
 36      mint_public: governor_mint_operation
 37      burn_public: governor_burn_operation
 38      lock_for_sax: lock_ax_for_synthetic
 39      unlock_ax: unlock_ax_from_pool
 40    events:
 41      - transfer_completed
 42      - multisig_transfer_completed
 43      - departmental_transfer_completed
 44      - mint_completed
 45      - burn_completed
 46      - ax_locked
 47      - ax_unlocked
 48  
 49  spec:
 50    circuits:
 51      transfer_private:
 52        inputs:
 53          - input_record_0: Record<credits.alpha>, private
 54          - input_record_1: Record<credits.alpha>, private, optional
 55          - recipient: address, private
 56          - amount: u64, private
 57        outputs:
 58          - output_record_0: to_recipient
 59          - output_record_1: change_to_sender
 60        constraints:
 61          - ownership_verified: signature
 62          - not_spent: serial_number_check
 63          - balance: sum(inputs) >= amount
 64          - output_amounts: [recipient=amount, change=sum-amount-fee]
 65        zk_hides: [sender, recipient, amount]
 66        reveals: [serial_numbers]
 67  
 68      transfer_multisig:
 69        inputs:
 70          - input_records: [Record<credits.alpha>]
 71          - recipient: address
 72          - amount: u64
 73          - signer_group: [address; N]
 74          - threshold: u8
 75          - signatures: [signature; T]
 76        outputs:
 77          - output_record_0: to_recipient
 78          - output_record_1: change_to_group
 79        constraints:
 80          - group_ownership: hash(signer_group, threshold) == input_records[0].owner
 81          - valid_threshold: count(signatures) >= threshold
 82          - valid_signatures: verify_batch(signatures, signer_group)
 83        zk_hides: [recipient, amount, signer_group]
 84        reveals: [serial_numbers]
 85  
 86      transfer_departmental:
 87        inputs:
 88          - input_records: [Record<credits.alpha>]
 89          - recipient: address
 90          - amount: u64
 91          - departments: [[address; N]; D] # List of signer groups
 92          - thresholds: [u8; D]
 93          - signatures: [[signature; T]; D] # Signatures per department
 94        outputs:
 95          - output_record_0: to_recipient
 96          - output_record_1: change_to_org
 97        constraints:
 98          - org_ownership: hash(departments, thresholds) == input_records[0].owner
 99          - all_departments_satisfied: forall(d in departments) { valid_threshold(d) && valid_signatures(d) }
100        zk_hides: [recipient, amount, departments]
101        reveals: [serial_numbers]
102  
103      mint_public:
104        inputs:
105          - governor: address, public, must_be_in_GID
106          - recipient: address, public_or_private
107          - amount: u64, public
108        outputs:
109          - output_record: Record<credits.alpha>
110        constraints:
111          - governor_in_gid: on_chain_lookup
112          - valid_signature: governor
113          - positive_amount: amount > 0
114          - audit_entry: created
115  
116      burn_public:
117        inputs:
118          - governor: address, public
119          - from: address, public
120          - amount: u64, public
121        constraints:
122          - governor_in_gid: verified
123          - balance_sufficient: from.balance >= amount
124  
125      lock_for_sax:
126        inputs:
127          - user: address
128          - amount: u64
129        effects:
130          - ax_to: locked_ax_pool
131          - creates: lock_record{id, user, amount, block}
132          - triggers: cross_chain_attest -> delta_sax_mint
133  
134      unlock_ax:
135        inputs:
136          - lock_id: field
137          - amount: u64
138          - merkle_proof: from_delta
139        effects:
140          - verifies: delta_burn_attestation
141          - releases: ax_from_pool_to_user
142  
143    # === SCALABILITY: CIRCUIT V2 OPTIMIZATION ===
144    # Reference: ALPHA_Scalability_Architecture_v1.0.cspec
145    scalability:
146      status: planning
147      target_throughput: 500-1000_TPS  # 5-10x current 100-120 TPS
148      bottleneck: proof_generation  # NOT bandwidth (18.4 Mbps of 10 Gbps)
149  
150      circuit_v1:
151        constraints: 360000
152        proving_key_size: 4.5_GB
153        proof_time_tier1: 150ms  # H100
154        proof_time_tier3: 400ms  # RTX 4090
155        status: production
156  
157      circuit_v2:
158        constraints: 61500  # 83% reduction
159        proving_key_size: 800_MB
160        proof_time_tier1: 25ms  # H100
161        proof_time_tier3: 70ms  # RTX 4090
162        status: development
163        optimizations:
164          merkle_tree: poseidon_hash  # 96,000 → 9,600 constraints per input
165          signature: eddsa_poseidon   # 30,000 → 15,300 constraints
166          encryption: poseidon_sponge # 50,000 → 3,000 per record
167          balance: unchanged          # 10,000 constraints
168        breakdown:
169          input_decryption: 6000
170          nullifier_computation: 5000
171          output_encryption: 6000
172          balance_verification: 10000
173          merkle_verification: 19200
174          signature_verification: 15300
175  
176    # === PROOF AGGREGATION ===
177    aggregation:
178      status: planning
179      validator_efficiency: 333x  # verify 1 aggregate vs 1000 individual
180  
181      batch_proof:
182        transactions_per_batch: 50
183        circuit: BATCH_VERIFIER
184        constraints: 500000
185        proving_time_tier1: 200ms
186        proof_size: 2_KB
187        provers: tier_1_2_only
188  
189      block_proof:
190        batches_per_block: 20  # 1000 transactions
191        circuit: BLOCK_VERIFIER
192        constraints: 300000
193        proving_time_tier1: 150ms
194        proof_size: 2_KB
195        verification_time: 15ms
196  
197      timing_budget:
198        block_time: 10_seconds
199        transaction_collection: 3_seconds
200        batch_aggregation: 3_seconds_parallel
201        block_aggregation: 2_seconds
202        finalization: 2_seconds
203  
204      aggregator_rewards:
205        batch_premium: 20_percent
206        block_premium: 30_percent
207  
208    # === MIGRATION PATH ===
209    migration:
210      strategy: dual_version_support
211      v1_status: remains_valid_indefinitely
212      v2_activation: after_governance_approval
213      transition_period: 4_epochs
214  
215      governance:
216        circuit_upgrade_threshold: 90_percent  # ALPHA Governors
217        voting_period: 7_days
218        prerequisites:
219          - security_audit_complete
220          - testnet_30_days_minimum
221  
222      phases:
223        1_circuit_optimization:
224          duration: 12_weeks
225          deliverables:
226            - poseidon_hash_implementation
227            - poseidon_merkle_tree
228            - alpha_transfer_v2_circuit
229            - proving_key_generation
230        2_aggregation_infrastructure:
231          duration: 8_weeks
232          deliverables:
233            - batch_verifier_circuit
234            - block_verifier_circuit
235            - aggregator_selection_mechanism
236        3_protocol_upgrade:
237          duration: 6_weeks
238          deliverables:
239            - alpha_block_v2_structure
240            - aggregated_proof_verification
241            - nullifier_accumulator
242        4_mainnet_activation:
243          duration: 6_weeks
244          steps:
245            - governance_proposal_90_percent
246            - staged_activation_v2_optional
247            - full_activation_aggregation_required
248  
249  changelog:
250    - version: 1.1.0
251      date: 2026-01-19
252      type: enhancement
253      description: "Add scalability planning: circuit_v2 (83% constraint reduction), aggregation, migration"
254      breaking: false
255  
256    - version: 1.0.0
257      date: 2026-01-07
258      type: initial
259      description: "Migrated from alpha_chain.cspec"
260      breaking: false