1+ use anyhow:: Context ;
12use blake2:: digest:: { Digest , FixedOutput } ;
23
34use serde:: { Deserialize , Serialize } ;
@@ -52,6 +53,9 @@ impl<D: Clone + Digest + FixedOutput + Send + Sync> ConcatenationProof<D> {
5253 & clerk. params ,
5354 & msgp,
5455 & sig_reg_list,
56+ )
57+ . with_context (
58+ || "Failed to aggregate unique signatures during selection for the k indices." ,
5559 ) ?;
5660
5761 unique_sigs. sort_unstable ( ) ;
@@ -90,7 +94,8 @@ impl<D: Clone + Digest + FixedOutput + Send + Sync> ConcatenationProof<D> {
9094 & self . signatures ,
9195 parameters,
9296 & msgp,
93- ) ?;
97+ )
98+ . with_context ( || "Preliminary verification of aggregate signatures failed." ) ?;
9499
95100 let leaves = self
96101 . signatures
@@ -99,7 +104,8 @@ impl<D: Clone + Digest + FixedOutput + Send + Sync> ConcatenationProof<D> {
99104 . collect :: < Vec < RegisteredParty > > ( ) ;
100105
101106 avk. get_merkle_tree_batch_commitment ( )
102- . verify_leaves_membership_from_batch_path ( & leaves, & self . batch_proof ) ?;
107+ . verify_leaves_membership_from_batch_path ( & leaves, & self . batch_proof )
108+ . with_context ( || "Batch proof is invalid in preliminary verification." ) ?;
103109
104110 Ok ( BasicVerifier :: collect_signatures_verification_keys (
105111 & self . signatures ,
@@ -119,9 +125,12 @@ impl<D: Clone + Digest + FixedOutput + Send + Sync> ConcatenationProof<D> {
119125 parameters : & Parameters ,
120126 ) -> StmResult < ( ) > {
121127 let msgp = avk. get_merkle_tree_batch_commitment ( ) . concatenate_with_message ( msg) ;
122- let ( sigs, vks) = self . preliminary_verify ( msg, avk, parameters) ?;
128+ let ( sigs, vks) = self
129+ . preliminary_verify ( msg, avk, parameters)
130+ . with_context ( || "Aggregate signature verification failed" ) ?;
123131
124- BlsSignature :: verify_aggregate ( msgp. as_slice ( ) , & vks, & sigs) ?;
132+ BlsSignature :: verify_aggregate ( msgp. as_slice ( ) , & vks, & sigs)
133+ . with_context ( || "Aggregate signature verification failed" ) ?;
125134 Ok ( ( ) )
126135 }
127136
0 commit comments