1- use anyhow:: anyhow;
21use std:: collections:: HashMap ;
32use std:: fmt:: Display ;
43use std:: hash:: Hash ;
54
5+ use anyhow:: anyhow;
66use blake2:: digest:: { Digest , FixedOutput } ;
77use serde:: { Deserialize , Serialize } ;
88
9- use crate :: error:: StmAggregateSignatureError ;
9+ use crate :: error:: AggregateSignatureError ;
1010use crate :: merkle_tree:: MerkleBatchPath ;
1111use crate :: { AggregateVerificationKey , Parameters , StmResult } ;
1212
@@ -103,7 +103,7 @@ impl<D: Clone + Digest + FixedOutput + Send + Sync> AggregateSignature<D> {
103103 }
104104 #[ cfg( feature = "future_proof_system" ) ]
105105 AggregateSignature :: Future => Err ( anyhow ! (
106- StmAggregateSignatureError :: UnsupportedProofSystem ( self . into( ) )
106+ AggregateSignatureError :: UnsupportedProofSystem ( self . into( ) )
107107 ) ) ,
108108 }
109109 }
@@ -120,36 +120,26 @@ impl<D: Clone + Digest + FixedOutput + Send + Sync> AggregateSignature<D> {
120120 acc. entry ( sig. into ( ) ) . or_default ( ) . push ( sig. clone ( ) ) ;
121121 acc
122122 } ) ;
123- stm_signatures
124- . into_iter ( )
125- . try_for_each ( |( aggregate_signature_type, aggregate_signatures) | {
126- match aggregate_signature_type {
127- AggregateSignatureType :: Concatenation => {
128- let aggregate_signatures_length = aggregate_signatures. len ( ) ;
129- let concatenation_proofs = aggregate_signatures
130- . into_iter ( )
131- . filter_map ( |s| s. to_concatenation_proof ( ) . cloned ( ) )
132- . collect :: < Vec < _ > > ( ) ;
133- if concatenation_proofs. len ( ) != aggregate_signatures_length {
134- return Err ( anyhow ! ( StmAggregateSignatureError :: BatchInvalid ) ) ;
135- }
136-
137- ConcatenationProof :: batch_verify (
138- & concatenation_proofs,
139- msgs,
140- avks,
141- parameters,
142- )
143- }
144- #[ cfg( feature = "future_proof_system" ) ]
145- AggregateSignatureType :: Future => {
146- Err ( anyhow ! ( StmAggregateSignatureError :: UnsupportedProofSystem (
147- aggregate_signature_type
148- ) ) )
123+ stm_signatures. into_iter ( ) . try_for_each (
124+ |( aggregate_signature_type, aggregate_signatures) | match aggregate_signature_type {
125+ AggregateSignatureType :: Concatenation => {
126+ let aggregate_signatures_length = aggregate_signatures. len ( ) ;
127+ let concatenation_proofs = aggregate_signatures
128+ . into_iter ( )
129+ . filter_map ( |s| s. to_concatenation_proof ( ) . cloned ( ) )
130+ . collect :: < Vec < _ > > ( ) ;
131+ if concatenation_proofs. len ( ) != aggregate_signatures_length {
132+ return Err ( anyhow ! ( AggregateSignatureError :: BatchInvalid ) ) ;
149133 }
134+
135+ ConcatenationProof :: batch_verify ( & concatenation_proofs, msgs, avks, parameters)
150136 }
151- } )
152- . map_err ( |_| anyhow ! ( StmAggregateSignatureError :: BatchInvalid ) )
137+ #[ cfg( feature = "future_proof_system" ) ]
138+ AggregateSignatureType :: Future => Err ( anyhow ! (
139+ AggregateSignatureError :: UnsupportedProofSystem ( aggregate_signature_type)
140+ ) ) ,
141+ } ,
142+ )
153143 }
154144
155145 /// Convert an aggregate signature to bytes
@@ -173,11 +163,10 @@ impl<D: Clone + Digest + FixedOutput + Send + Sync> AggregateSignature<D> {
173163
174164 /// Extract an aggregate signature from a byte slice.
175165 pub fn from_bytes ( bytes : & [ u8 ] ) -> StmResult < Self > {
176- let proof_type_byte =
177- bytes. first ( ) . ok_or ( StmAggregateSignatureError :: SerializationError ) ?;
166+ let proof_type_byte = bytes. first ( ) . ok_or ( AggregateSignatureError :: SerializationError ) ?;
178167 let proof_bytes = & bytes[ 1 ..] ;
179168 let proof_type = AggregateSignatureType :: from_byte_encoding_prefix ( * proof_type_byte)
180- . ok_or ( StmAggregateSignatureError :: SerializationError ) ?;
169+ . ok_or ( AggregateSignatureError :: SerializationError ) ?;
181170 match proof_type {
182171 AggregateSignatureType :: Concatenation => Ok ( AggregateSignature :: Concatenation (
183172 ConcatenationProof :: from_bytes ( proof_bytes) ?,
0 commit comments