@@ -50,16 +50,13 @@ pub struct SignatureAndIndex {
50
50
}
51
51
52
52
impl Verifier for ThresholdMultiSignature {
53
- fn verify ( & self , simplified_tx : & [ u8 ] , _: u32 , redeemer : & [ u8 ] ) -> bool {
53
+ type Redeemer = Vec < SignatureAndIndex > ;
54
+
55
+ fn verify ( & self , simplified_tx : & [ u8 ] , _: u32 , sigs : & Vec < SignatureAndIndex > ) -> bool {
54
56
if self . has_duplicate_signatories ( ) {
55
57
return false ;
56
58
}
57
59
58
- let sigs = match Vec :: < SignatureAndIndex > :: decode ( & mut & redeemer[ ..] ) {
59
- Ok ( s) => s,
60
- Err ( _) => return false ,
61
- } ;
62
-
63
60
if sigs. len ( ) < self . threshold . into ( ) {
64
61
return false ;
65
62
}
@@ -121,13 +118,12 @@ mod test {
121
118
} )
122
119
. collect ( ) ;
123
120
124
- let redeemer: & [ u8 ] = & sigs. encode ( ) [ ..] ;
125
121
let threshold_multisig = ThresholdMultiSignature {
126
122
threshold,
127
123
signatories,
128
124
} ;
129
125
130
- assert ! ( threshold_multisig. verify( simplified_tx, 0 , redeemer ) ) ;
126
+ assert ! ( threshold_multisig. verify( simplified_tx, 0 , & sigs ) ) ;
131
127
}
132
128
133
129
#[ test]
@@ -148,13 +144,12 @@ mod test {
148
144
} )
149
145
. collect ( ) ;
150
146
151
- let redeemer: & [ u8 ] = & sigs. encode ( ) [ ..] ;
152
147
let threshold_multisig = ThresholdMultiSignature {
153
148
threshold,
154
149
signatories,
155
150
} ;
156
151
157
- assert ! ( !threshold_multisig. verify( simplified_tx, 0 , redeemer ) ) ;
152
+ assert ! ( !threshold_multisig. verify( simplified_tx, 0 , & sigs ) ) ;
158
153
}
159
154
160
155
#[ test]
@@ -174,13 +169,12 @@ mod test {
174
169
} )
175
170
. collect ( ) ;
176
171
177
- let redeemer: & [ u8 ] = & sigs. encode ( ) [ ..] ;
178
172
let threshold_multisig = ThresholdMultiSignature {
179
173
threshold,
180
174
signatories,
181
175
} ;
182
176
183
- assert ! ( threshold_multisig. verify( simplified_tx, 0 , redeemer ) ) ;
177
+ assert ! ( threshold_multisig. verify( simplified_tx, 0 , & sigs ) ) ;
184
178
}
185
179
186
180
#[ test]
@@ -203,13 +197,12 @@ mod test {
203
197
} ,
204
198
] ;
205
199
206
- let redeemer: & [ u8 ] = & sigs. encode ( ) [ ..] ;
207
200
let threshold_multisig = ThresholdMultiSignature {
208
201
threshold,
209
202
signatories,
210
203
} ;
211
204
212
- assert ! ( !threshold_multisig. verify( simplified_tx, 0 , redeemer ) ) ;
205
+ assert ! ( !threshold_multisig. verify( simplified_tx, 0 , & sigs ) ) ;
213
206
}
214
207
215
208
#[ test]
@@ -230,31 +223,12 @@ mod test {
230
223
index : i. try_into ( ) . unwrap ( ) ,
231
224
} )
232
225
. collect ( ) ;
233
- let redeemer: & [ u8 ] = & sigs. encode ( ) [ ..] ;
234
226
235
227
let threshold_multisig = ThresholdMultiSignature {
236
228
threshold,
237
229
signatories,
238
230
} ;
239
231
240
- assert ! ( !threshold_multisig. verify( simplified_tx, 0 , redeemer) ) ;
241
- }
242
-
243
- #[ test]
244
- fn threshold_multisig_bogus_redeemer_encoding_fails ( ) {
245
- use crate :: dynamic_typing:: testing:: Bogus ;
246
-
247
- let bogus = Bogus ;
248
-
249
- let threshold_multisig = ThresholdMultiSignature {
250
- threshold : 3 ,
251
- signatories : vec ! [ ] ,
252
- } ;
253
-
254
- assert ! ( !threshold_multisig. verify(
255
- b"bogus_message" . as_slice( ) ,
256
- 0 ,
257
- bogus. encode( ) . as_slice( )
258
- ) )
232
+ assert ! ( !threshold_multisig. verify( simplified_tx, 0 , & sigs) ) ;
259
233
}
260
234
}
0 commit comments