Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merkle hash chip #98

Merged
merged 13 commits into from
Jun 29, 2021
Merged
Prev Previous commit
Next Next commit
Optimize transpose_option_array
str4d authored Jun 29, 2021

Verified

This commit was signed with the committer’s verified signature.
carlocab Carlo Cabrera
commit cbded2b8218fd1e395163ad549aa461e660c298b
14 changes: 6 additions & 8 deletions src/circuit/gadget/utilities.rs
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ use halo2::{
plonk::{Advice, Column, Error, Permutation},
};
use pasta_curves::arithmetic::FieldExt;
use std::convert::TryInto;
use std::array;

pub(crate) mod cond_swap;
pub(crate) mod enable_flag;
@@ -89,13 +89,11 @@ where
pub fn transpose_option_array<T: Copy + std::fmt::Debug, const LEN: usize>(
option_array: Option<[T; LEN]>,
) -> [Option<T>; LEN] {
let mut ret = [None; LEN];
if let Some(arr) = option_array {
arr.iter()
.map(|el| Some(*el))
.collect::<Vec<_>>()
.try_into()
.unwrap()
} else {
[None; LEN]
for (entry, value) in ret.iter_mut().zip(array::IntoIter::new(arr)) {
*entry = Some(value);
}
}
ret
}