diff --git a/src/air/public_input.cairo b/src/air/public_input.cairo index db824ffc1..fcb221439 100644 --- a/src/air/public_input.cairo +++ b/src/air/public_input.cairo @@ -86,7 +86,21 @@ impl PublicInputImpl of PublicInputTrait { let program_end_pc = initial_fp - 2; let program_len = program_end_pc - initial_pc; - memory.extract_range(initial_pc, program_len); + let program = memory.extract_range(initial_pc, program_len); + + assert( + *program[0] == 0x40780017fff7fff, 'Invalid program' + ); // Instruction: ap += N_BUILTINS. + assert(*program[1] == builtins.len().into(), 'Invalid program'); + assert(*program[2] == 0x1104800180018000, 'Invalid program'); // Instruction: call rel ?. + assert(*program[4] == 0x10780017fff7fff, 'Invalid program'); // Instruction: jmp rel 0. + assert(*program[5] == 0x0, 'Invalid program'); + + // TODO hash program + let program_hash = 0; + + // 2. Execution segment + // 2.1 Initial_fp, initial_pc (0, 0) } diff --git a/src/common.cairo b/src/common.cairo index cf165c02e..6eef1ade9 100644 --- a/src/common.cairo +++ b/src/common.cairo @@ -7,6 +7,7 @@ mod math; mod array_print; mod array_extend; mod consts; +mod hash; #[cfg(test)] mod tests; diff --git a/src/common/hash.cairo b/src/common/hash.cairo new file mode 100644 index 000000000..8981c23a7 --- /dev/null +++ b/src/common/hash.cairo @@ -0,0 +1,15 @@ +use pedersen::PedersenTrait; +use hash::HashStateTrait; + +fn hash_felts(s: Span) -> felt252 { + let mut hash_state = PedersenTrait::new(0); + let mut i = 0; + + loop { + if i == s.len() { + break hash_state.finalize(); + } + + hash_state.update(*s.at(i)); + } +}