@@ -84,6 +84,21 @@ pub fn validate(
8484 } ;
8585 return Err ( err) ;
8686 }
87+ // The authorization and address checks below pair authorizations with
88+ // spent UTXOs positionally via `zip`, which silently ignores any trailing
89+ // inputs when there are fewer authorizations than inputs requiring one.
90+ // Require an exact count so that every input requiring authorization is
91+ // covered by a provided authorization.
92+ let n_authorizations_required: usize = filled_txs
93+ . iter ( )
94+ . map ( |t| t. spent_utxos_requiring_auth ( ) . len ( ) )
95+ . sum ( ) ;
96+ if body. authorizations . len ( ) != n_authorizations_required {
97+ return Err ( Error :: WrongNumberOfAuthorizations {
98+ expected : n_authorizations_required,
99+ received : body. authorizations . len ( ) ,
100+ } ) ;
101+ }
87102 let spent_utxos = filled_txs
88103 . iter ( )
89104 . flat_map ( |t| t. spent_utxos_requiring_auth ( ) . into_iter ( ) ) ;
@@ -168,6 +183,21 @@ pub fn prevalidate(
168183 } ;
169184 return Err ( err) ;
170185 }
186+ // The authorization and address checks below pair authorizations with
187+ // spent UTXOs positionally via `zip`, which silently ignores any trailing
188+ // inputs when there are fewer authorizations than inputs requiring one.
189+ // Require an exact count so that every input requiring authorization is
190+ // covered by a provided authorization.
191+ let n_authorizations_required: usize = filled_transactions
192+ . iter ( )
193+ . map ( |t| t. spent_utxos_requiring_auth ( ) . len ( ) )
194+ . sum ( ) ;
195+ if body. authorizations . len ( ) != n_authorizations_required {
196+ return Err ( Error :: WrongNumberOfAuthorizations {
197+ expected : n_authorizations_required,
198+ received : body. authorizations . len ( ) ,
199+ } ) ;
200+ }
171201 let spent_utxos = filled_transactions
172202 . iter ( )
173203 . flat_map ( |t| t. spent_utxos_requiring_auth ( ) . into_iter ( ) ) ;
0 commit comments