-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
07a69ae
commit 585aa23
Showing
8 changed files
with
70 additions
and
60 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