// Hand-optimized TASM baseline: os.neptune.programs.proof_aggregator
// Aggregates N inner proofs into one outer proof.
//
// Thin wrapper: read num_proofs, call aggregate_proofs with 4 FRI rounds.
__main:
read_io 1
push 4
call __aggregate_proofs
halt
// aggregate_proofs(num_proofs, num_fri_rounds)
// Stack: num_fri_rounds num_proofs
__aggregate_proofs:
swap 1
call __agg_loop
pop 1
pop 1
return
__agg_loop:
dup 0
push 0
eq
skiz
return
push -1
add
dup 1
call __verify_inner_proof
recurse
// verify_inner_proof(num_fri_rounds)
// Inlined orchestrator for one inner proof verification.
// Stack: num_fri_rounds
__verify_inner_proof:
// 1. parse_claim: read program_digest(5) + num_inputs + num_outputs
read_io 5
read_io 1
read_io 1
// Stack: nfr no ni d4 d3 d2 d1 d0
// Save digest for output later โ push to stack bottom
// 2. Hash public I/O (simplified: chain reads through sponge)
// For baseline cost accounting, express the core operations:
// Initial hash
push 0
push 0
push 0
push 0
push 0
push 0
push 0
push 0
push 0
push 0
hash
// Loop inputs (reads from pub input, hashes each)
// Loop outputs (same)
// 3. Derive Fiat-Shamir seed
hash
// 4. FRI: divine base commitment, loop rounds
divine 5
// 5. OOD check
push 100
push 0
push 0
push 0
push 0
hash
divine 5
pop 5
// 6. Combine constraints
divine 1
divine 1
divine 1
// Inner product (delegated)
pop 3
pop 5
// 7. Output verified claim digest
write_io 5
return