|
| 1 | +//! This file is an encoding of all the "Program". It is "static" |
| 2 | +//! part of the proof generation process, in the sense that the "program" |
| 3 | +//! a.k.a. resting code is known prior to proof generation. This |
| 4 | +//! needs to be differentiated from actual running process trace, since |
| 5 | +//! that may be longer than "program" owing to actual execution of jumps. |
| 6 | +
|
| 7 | +use plonky2::{ |
| 8 | + field::{ |
| 9 | + extension::{ |
| 10 | + Extendable, |
| 11 | + FieldExtension, |
| 12 | + }, |
| 13 | + packed::PackedField, |
| 14 | + }, |
| 15 | + iop::ext_target::ExtensionTarget, |
| 16 | + hash::hash_types::RichField, |
| 17 | +}; |
| 18 | +use starky::{constraint_consumer::ConstraintConsumer, evaluation_frame::StarkFrame, stark::Stark}; |
| 19 | +use core::marker::PhantomData; |
| 20 | + |
| 21 | +pub struct ProgramInstructions<T> { |
| 22 | + pub program_counter: T, |
| 23 | + pub instruction_data: T, |
| 24 | +} |
| 25 | + |
| 26 | +const NUMBER_OF_COLS: usize = 2; |
| 27 | +const PUBLIC_INPUTS: usize = 0; |
| 28 | + |
| 29 | +pub struct ProgramInstructionsStark<F, const D: usize> { |
| 30 | + pub _f: PhantomData<F>, |
| 31 | +} |
| 32 | + |
| 33 | +impl<F, const D: usize> Stark<F, D> for ProgramInstructionsStark<F, D> |
| 34 | +where |
| 35 | + F: RichField + Extendable<D>, |
| 36 | +{ |
| 37 | + const COLUMNS: usize = NUMBER_OF_COLS; |
| 38 | + const PUBLIC_INPUTS: usize = PUBLIC_INPUTS; |
| 39 | + |
| 40 | + type EvaluationFrame<FE, P, const D2: usize> = StarkFrame<P, P::Scalar, NUMBER_OF_COLS, PUBLIC_INPUTS> |
| 41 | + where |
| 42 | + FE: FieldExtension<D2, BaseField = F>, |
| 43 | + P: PackedField<Scalar = FE>; |
| 44 | + |
| 45 | + type EvaluationFrameTarget = StarkFrame< |
| 46 | + ExtensionTarget<D>, |
| 47 | + ExtensionTarget<D>, |
| 48 | + NUMBER_OF_COLS, |
| 49 | + PUBLIC_INPUTS, |
| 50 | + >; |
| 51 | + |
| 52 | + fn eval_packed_generic<FE, P, const D2: usize>( |
| 53 | + &self, |
| 54 | + vars: &Self::EvaluationFrame<FE, P, D2>, |
| 55 | + yield_constr: &mut ConstraintConsumer<P>, |
| 56 | + ) where |
| 57 | + FE: FieldExtension<D2, BaseField = F>, |
| 58 | + P: PackedField<Scalar = FE>, |
| 59 | + { |
| 60 | + |
| 61 | + } |
| 62 | + |
| 63 | + fn eval_ext_circuit( |
| 64 | + &self, |
| 65 | + builder: &mut plonky2::plonk::circuit_builder::CircuitBuilder<F, D>, |
| 66 | + vars: &Self::EvaluationFrameTarget, |
| 67 | + yield_constr: &mut starky::constraint_consumer::RecursiveConstraintConsumer<F, D>, |
| 68 | + ) { |
| 69 | + |
| 70 | + } |
| 71 | + |
| 72 | + fn constraint_degree(&self) -> usize { |
| 73 | + 3 |
| 74 | + } |
| 75 | +} |
0 commit comments