1+ use core:: mem;
12use core:: ops:: Deref ;
2- use core:: { array, mem} ;
33
44use serde:: { Deserialize , Serialize } ;
55use std_shims:: Vec ;
@@ -12,37 +12,29 @@ use crate::core::vcs::hash::Hash;
1212use crate :: core:: vcs:: verifier:: MerkleDecommitment ;
1313use 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 ) ]
2016pub struct StarkProof < H : MerkleHasher > ( pub CommitmentSchemeProof < H > ) ;
2117
2218impl < 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.
0 commit comments