@@ -41,8 +41,6 @@ pub type HashOut = hash_types::HashOut<F>;
4141
4242use std:: { collections:: HashMap , sync:: LazyLock } ;
4343
44- use itertools:: Itertools ;
45-
4644use crate :: {
4745 backends:: plonky2:: {
4846 emptypod:: STANDARD_EMPTY_POD_DATA , primitives:: merkletree:: MerkleClaimAndProof ,
@@ -80,7 +78,11 @@ pub struct VDSet {
8078}
8179
8280impl VDSet {
83- fn new_from_vds_hashes ( tree_depth : usize , vds_hashes : Vec < Hash > ) -> Result < Self > {
81+ fn new_from_vds_hashes ( tree_depth : usize , mut vds_hashes : Vec < Hash > ) -> Result < Self > {
82+ // before using the hash values, sort them, so that each set of
83+ // verifier_datas gets the same VDSet root
84+ vds_hashes. sort ( ) ;
85+
8486 let array = Array :: new (
8587 tree_depth,
8688 vds_hashes. iter ( ) . map ( |vd| Value :: from ( * vd) ) . collect ( ) ,
@@ -114,11 +116,8 @@ impl VDSet {
114116 . map ( crate :: backends:: plonky2:: recursion:: circuit:: hash_verifier_data)
115117 . collect :: < Vec < _ > > ( ) ;
116118
117- // before using the hash values, sort them, so that each set of
118- // verifier_datas gets the same VDSet root
119119 let vds_hashes: Vec < Hash > = vds_hashes
120- . iter ( )
121- . sorted_by_key ( |vd| RawValue ( vd. elements ) )
120+ . into_iter ( )
122121 . map ( |h| Hash ( h. elements ) )
123122 . collect :: < Vec < _ > > ( ) ;
124123
@@ -148,9 +147,8 @@ impl VDSet {
148147 }
149148 /// Returns true if the `verifier_data_hash` is in the set
150149 pub fn contains ( & self , verifier_data_hash : HashOut ) -> bool {
151- self . vds_hashes
152- . iter ( )
153- . any ( |vd_hash| * vd_hash == Hash ( verifier_data_hash. elements ) )
150+ self . proofs_map
151+ . contains_key ( & Hash ( verifier_data_hash. elements ) )
154152 }
155153}
156154
0 commit comments