@@ -5,10 +5,10 @@ use bitcoin::{
55 key:: TapTweak ,
66 opcodes:: all:: OP_RETURN ,
77 sighash:: { Prevouts , SighashCache } ,
8- taproot:: TAPROOT_CONTROL_NODE_SIZE ,
9- Amount , OutPoint , ScriptBuf , TapNodeHash , TapSighashType , Transaction , TxOut , XOnlyPublicKey ,
8+ taproot:: { self , TAPROOT_CONTROL_NODE_SIZE } ,
9+ Amount , OutPoint , ScriptBuf , TapNodeHash , Transaction , TxOut , XOnlyPublicKey ,
1010} ;
11- use secp256k1:: { constants :: SCHNORR_SIGNATURE_SIZE , schnorr :: Signature , Message } ;
11+ use secp256k1:: Message ;
1212use strata_primitives:: {
1313 buf:: Buf32 ,
1414 l1:: { DepositInfo , OutputRef } ,
@@ -71,7 +71,7 @@ pub fn extract_deposit_info(tx: &Transaction, config: &DepositTxParams) -> Optio
7171 } )
7272}
7373
74- /// Validate that the transaction has been signed off by the N of N operators pubkey.
74+ /// Validate that the transaction has been signed off by the N-of- N operators pubkey.
7575fn validate_deposit_signature (
7676 tx : & Transaction ,
7777 tag_data : & DepositTag < ' _ > ,
@@ -92,11 +92,12 @@ fn validate_deposit_signature(
9292 return None ;
9393 }
9494 let sig_witness = & input. witness [ 0 ] ;
95- if sig_witness. len ( ) < SCHNORR_SIGNATURE_SIZE {
96- return None ;
97- }
98- let sig_bytes = & sig_witness[ ..SCHNORR_SIGNATURE_SIZE ] ;
99- let schnorr_sig = Signature :: from_slice ( sig_bytes) . ok ( ) ?;
95+
96+ // rust-bitcoin taproot::Signature handles both both 64-byte (SIGHASH_DEFAULT)
97+ // and 65-byte (explicit sighash) signatures.
98+ let taproot_sig = taproot:: Signature :: from_slice ( sig_witness) . ok ( ) ?;
99+ let schnorr_sig = taproot_sig. signature ;
100+ let sighash_type = taproot_sig. sighash_type ;
100101
101102 // Parse the internal pubkey and merkle root
102103 let internal_pubkey = dep_config. operators_pubkey ;
@@ -116,7 +117,8 @@ fn validate_deposit_signature(
116117 // Compute the sighash
117118 let prevout = Prevouts :: All ( & utxos) ;
118119 let sighash = SighashCache :: new ( tx)
119- . taproot_key_spend_signature_hash ( 0 , & prevout, TapSighashType :: All )
120+ // NOTE: preserving the original sighash_type.
121+ . taproot_key_spend_signature_hash ( 0 , & prevout, sighash_type)
120122 . unwrap ( ) ;
121123
122124 // Prepare the message for signature verification
0 commit comments