-
Notifications
You must be signed in to change notification settings - Fork 88
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/478) <!-- Reviewable:end -->
- Loading branch information
1 parent
4ed11e9
commit c617804
Showing
8 changed files
with
66 additions
and
59 deletions.
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
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,41 @@ | ||
use super::m31::BaseField; | ||
use super::qm31::SecureField; | ||
use super::ExtensionOf; | ||
use crate::core::backend::{Backend, CPUBackend, Col, Column}; | ||
use crate::core::utils::IteratorMutExt; | ||
|
||
pub const SECURE_EXTENSION_DEGREE: usize = | ||
<SecureField as ExtensionOf<BaseField>>::EXTENSION_DEGREE; | ||
|
||
/// An array of `SECURE_EXTENSION_DEGREE` base field columns, that represents a column of secure | ||
/// field elements. | ||
pub struct SecureColumn<B: Backend> { | ||
pub columns: [Col<B, BaseField>; SECURE_EXTENSION_DEGREE], | ||
} | ||
impl SecureColumn<CPUBackend> { | ||
pub fn at(&self, index: usize) -> SecureField { | ||
SecureField::from_m31_array(std::array::from_fn(|i| self.columns[i][index])) | ||
} | ||
|
||
pub fn set(&mut self, index: usize, value: SecureField) { | ||
self.columns | ||
.iter_mut() | ||
.map(|c| &mut c[index]) | ||
.assign(value.to_m31_array()); | ||
} | ||
} | ||
impl<B: Backend> SecureColumn<B> { | ||
pub fn zeros(len: usize) -> Self { | ||
Self { | ||
columns: std::array::from_fn(|_| Col::<B, BaseField>::zeros(len)), | ||
} | ||
} | ||
|
||
pub fn len(&self) -> usize { | ||
self.columns[0].len() | ||
} | ||
|
||
pub fn is_empty(&self) -> bool { | ||
self.columns[0].is_empty() | ||
} | ||
} |
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