From 0e9544d536a27114a6375e44b15e128e16e81fa3 Mon Sep 17 00:00:00 2001 From: tiagofneto Date: Fri, 5 Jan 2024 20:32:36 +0000 Subject: [PATCH] verify stack --- src/air/public_input.cairo | 1 + src/air/public_memory.cairo | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/air/public_input.cairo b/src/air/public_input.cairo index 15d42f8d7..3bd46e106 100644 --- a/src/air/public_input.cairo +++ b/src/air/public_input.cairo @@ -118,3 +118,4 @@ impl PublicInputImpl of PublicInputTrait { (program_hash, 0) } } + diff --git a/src/air/public_memory.cairo b/src/air/public_memory.cairo index 522d52a51..376806a8b 100644 --- a/src/air/public_memory.cairo +++ b/src/air/public_memory.cairo @@ -61,6 +61,30 @@ impl PageImpl of PageTrait { i += 1; } } + + fn verify_stack( + self: @Page, + start_ap: felt252, + segment_address: felt252, + builtins: Array, + memory_index: felt252 + ) { + let mut i = 0; + + // TODO size of SegmentInfo + let size = 2; + loop { + if i == builtins.len() { + break; + } + + let current = *self.at(memory_index.try_into().unwrap() + i); + + assert(current.address == start_ap + i.into(), 'Invalid address'); + assert(current.value == segment_address + size * (i.into() + 1), 'Invalid builtin'); + i += 1; + }; + } } fn get_continuous_pages_product(page_headers: Span) -> (felt252, felt252) {