-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/starkware-libs/stwo/663) <!-- Reviewable:end -->
- Loading branch information
Showing
4 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -16,3 +16,4 @@ pub mod core; | |
pub mod examples; | ||
pub mod hash_functions; | ||
pub mod math; | ||
pub mod trace_generation; |
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,36 @@ | ||
use std::collections::HashMap; | ||
|
||
use downcast_rs::{impl_downcast, Downcast}; | ||
|
||
use crate::core::backend::Backend; | ||
use crate::core::fields::m31::BaseField; | ||
use crate::core::poly::circle::CircleEvaluation; | ||
use crate::core::poly::BitReversedOrder; | ||
use crate::core::ColumnVec; | ||
|
||
pub trait ComponentGen: Downcast {} | ||
impl_downcast!(ComponentGen); | ||
|
||
pub struct ComponentRegistry { | ||
_components: HashMap<String, Box<dyn ComponentGen>>, | ||
} | ||
|
||
// A trait to generate a a trace. | ||
// Generates the trace given a list of inputs collects inputs for subcomponents. | ||
pub trait TraceGenerator<B: Backend> { | ||
type ComponentInputs; | ||
|
||
/// Add inputs for the trace generation of the component. | ||
/// This function should be called from the caller components before calling `write_trace` of | ||
/// this component. | ||
fn add_inputs(&mut self, inputs: &Self::ComponentInputs); | ||
|
||
/// Allocates and returns the trace of the component and updates the | ||
/// subcomponents with the corresponding inputs. | ||
/// Should be called only after all the inputs are available. | ||
// TODO(ShaharS): change `component_id` to a struct that contains the id and the component name. | ||
fn write_trace( | ||
component_id: &str, | ||
registry: &mut ComponentRegistry, | ||
) -> ColumnVec<CircleEvaluation<B, BaseField, BitReversedOrder>>; | ||
} |