-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
compilable: first STARKY circuit: ProgramInstructionsSTARK
- Loading branch information
Showing
4 changed files
with
97 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
//! This file is an encoding of all the "Program". It is "static" | ||
//! part of the proof generation process, in the sense that the "program" | ||
//! a.k.a. resting code is known prior to proof generation. This | ||
//! needs to be differentiated from actual running process trace, since | ||
//! that may be longer than "program" owing to actual execution of jumps. | ||
|
||
use plonky2::{ | ||
field::{ | ||
extension::{ | ||
Extendable, | ||
FieldExtension, | ||
}, | ||
packed::PackedField, | ||
}, | ||
iop::ext_target::ExtensionTarget, | ||
hash::hash_types::RichField, | ||
}; | ||
use starky::{constraint_consumer::ConstraintConsumer, evaluation_frame::StarkFrame, stark::Stark}; | ||
use core::marker::PhantomData; | ||
|
||
pub struct ProgramInstructions<T> { | ||
pub program_counter: T, | ||
pub instruction_data: T, | ||
} | ||
|
||
const NUMBER_OF_COLS: usize = 2; | ||
const PUBLIC_INPUTS: usize = 0; | ||
|
||
pub struct ProgramInstructionsStark<F, const D: usize> { | ||
pub _f: PhantomData<F>, | ||
} | ||
|
||
impl<F, const D: usize> Stark<F, D> for ProgramInstructionsStark<F, D> | ||
where | ||
F: RichField + Extendable<D>, | ||
{ | ||
const COLUMNS: usize = NUMBER_OF_COLS; | ||
const PUBLIC_INPUTS: usize = PUBLIC_INPUTS; | ||
|
||
type EvaluationFrame<FE, P, const D2: usize> = StarkFrame<P, P::Scalar, NUMBER_OF_COLS, PUBLIC_INPUTS> | ||
where | ||
FE: FieldExtension<D2, BaseField = F>, | ||
P: PackedField<Scalar = FE>; | ||
|
||
type EvaluationFrameTarget = StarkFrame< | ||
ExtensionTarget<D>, | ||
ExtensionTarget<D>, | ||
NUMBER_OF_COLS, | ||
PUBLIC_INPUTS, | ||
>; | ||
|
||
fn eval_packed_generic<FE, P, const D2: usize>( | ||
&self, | ||
vars: &Self::EvaluationFrame<FE, P, D2>, | ||
yield_constr: &mut ConstraintConsumer<P>, | ||
) where | ||
FE: FieldExtension<D2, BaseField = F>, | ||
P: PackedField<Scalar = FE>, | ||
{ | ||
|
||
} | ||
|
||
fn eval_ext_circuit( | ||
&self, | ||
builder: &mut plonky2::plonk::circuit_builder::CircuitBuilder<F, D>, | ||
vars: &Self::EvaluationFrameTarget, | ||
yield_constr: &mut starky::constraint_consumer::RecursiveConstraintConsumer<F, D>, | ||
) { | ||
|
||
} | ||
|
||
fn constraint_degree(&self) -> usize { | ||
3 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//! While macros shouln't really be used in a "toy" implementation, | ||
//! they can help a lot! But they are also cumbersome to use. In the | ||
//! sense that they are hard to read. | ||
//! | ||
//! Macros below are intended to be easy to read, comments are provided | ||
//! where necessary | ||
|
||
macro_rules! derive_get_number_of_columns { | ||
($structure: ident) => { | ||
impl<T> $structure<T> { | ||
pub const fn get_number_of_columns() -> usize { | ||
// `u8` is guaranteed to have a `size_of` of 1 | ||
std::mem::size_of::<$structure<u8>>(); | ||
} | ||
} | ||
}; | ||
} |