File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -379,6 +379,13 @@ impl FromStr for DescriptorPublicKey {
379379 is_wildcard,
380380 } ) )
381381 } else {
382+ if key_part. len ( ) >= 2
383+ && !( & key_part[ 0 ..2 ] == "02" || & key_part[ 0 ..2 ] == "03" || & key_part[ 0 ..2 ] == "04" )
384+ {
385+ return Err ( DescriptorKeyParseError (
386+ "Only publickeys with prefixes 02/03/04 are allowed" ,
387+ ) ) ;
388+ }
382389 let key = bitcoin:: PublicKey :: from_str ( key_part)
383390 . map_err ( |_| DescriptorKeyParseError ( "Error while parsing simple public key" ) ) ?;
384391 Ok ( DescriptorPublicKey :: SinglePub ( DescriptorSinglePub {
@@ -2406,6 +2413,15 @@ mod tests {
24062413 "Multiple \' ]\' in Descriptor Public Key"
24072414 ) )
24082415 ) ;
2416+
2417+ // fuzz failure, hybrid keys
2418+ let desc = "0777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777" ;
2419+ assert_eq ! (
2420+ DescriptorPublicKey :: from_str( desc) ,
2421+ Err ( DescriptorKeyParseError (
2422+ "Only publickeys with prefixes 02/03/04 are allowed"
2423+ ) )
2424+ ) ;
24092425 }
24102426
24112427 #[ test]
You can’t perform that action at this time.
0 commit comments