Skip to content

Commit 32b21c4

Browse files
committed
stop using unstable remove_try_from_fn_array
1 parent ff3ebaa commit 32b21c4

File tree

3 files changed

+23
-31
lines changed

3 files changed

+23
-31
lines changed

crates/stwo/src/core/proof.rs

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
use core::mem;
12
use core::ops::Deref;
2-
use core::{array, mem};
33

44
use serde::{Deserialize, Serialize};
55
use std_shims::Vec;
@@ -12,37 +12,29 @@ use crate::core::vcs::hash::Hash;
1212
use crate::core::vcs::verifier::MerkleDecommitment;
1313
use crate::core::vcs::MerkleHasher;
1414

15-
/// Error when the sampled values have an invalid structure.
16-
#[derive(Clone, Copy, Debug)]
17-
pub struct InvalidOodsSampleStructure;
18-
1915
#[derive(Clone, Debug, Serialize, Deserialize)]
2016
pub struct StarkProof<H: MerkleHasher>(pub CommitmentSchemeProof<H>);
2117

2218
impl<H: MerkleHasher> StarkProof<H> {
2319
/// Extracts the composition trace Out-Of-Domain-Sample evaluation from the mask.
24-
pub(crate) fn extract_composition_oods_eval(
25-
&self,
26-
) -> Result<SecureField, InvalidOodsSampleStructure> {
27-
// TODO(andrew): `[.., composition_mask, _quotients_mask]` when add quotients commitment.
20+
pub(crate) fn extract_composition_oods_eval(&self) -> Option<SecureField> {
21+
// TODO(andrew): `[.., composition_mask, _quotients_mask]` when add quotients
22+
// commitment.
2823
let [.., composition_mask] = &**self.sampled_values else {
29-
return Err(InvalidOodsSampleStructure);
24+
return None;
3025
};
31-
32-
let mut composition_cols = composition_mask.iter();
33-
34-
let coordinate_evals = array::try_from_fn(|_| {
35-
let col = &**composition_cols.next().ok_or(InvalidOodsSampleStructure)?;
36-
let [eval] = col.try_into().map_err(|_| InvalidOodsSampleStructure)?;
37-
Ok(eval)
38-
})?;
39-
40-
// Too many columns.
41-
if composition_cols.next().is_some() {
42-
return Err(InvalidOodsSampleStructure);
43-
}
44-
45-
Ok(SecureField::from_partial_evals(coordinate_evals))
26+
let coordinate_evals = composition_mask
27+
.iter()
28+
.map(|columns| {
29+
let &[eval] = &columns[..] else {
30+
return None;
31+
};
32+
Some(eval)
33+
})
34+
.collect::<Option<Vec<_>>>()?
35+
.try_into()
36+
.ok()?;
37+
Some(SecureField::from_partial_evals(coordinate_evals))
4638
}
4739

4840
/// Returns the estimate size (in bytes) of the proof.

crates/stwo/src/core/verifier.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,12 @@ pub fn verify<MC: MerkleChannel>(
5353
sample_points_by_column.into_iter().flatten().count()
5454
);
5555

56-
let composition_oods_eval = proof.extract_composition_oods_eval().map_err(|_| {
57-
VerificationError::InvalidStructure(std_shims::ToString::to_string(
58-
&"Unexpected sampled_values structure",
59-
))
60-
})?;
56+
let composition_oods_eval =
57+
proof
58+
.extract_composition_oods_eval()
59+
.ok_or(VerificationError::InvalidStructure(
60+
std_shims::ToString::to_string(&"Unexpected sampled_values structure"),
61+
))?;
6162

6263
if composition_oods_eval
6364
!= components.eval_composition_polynomial_at_point(

crates/stwo/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
feature(stdarch_x86_avx512)
55
)]
66
#![cfg_attr(not(feature = "std"), no_std)]
7-
#![feature(array_try_from_fn)]
87
#![cfg_attr(
98
feature = "prover",
109
feature(array_chunks, iter_array_chunks, portable_simd, slice_ptr_get)

0 commit comments

Comments
 (0)