From c21064192ea34dfd224057289c24c7d6074bf50a Mon Sep 17 00:00:00 2001 From: ethan Date: Wed, 1 Jul 2026 21:12:48 +0800 Subject: [PATCH] fix nonstandard witness --- goat/src/assert_scripts.rs | 2 +- goat/src/connectors/connector_c.rs | 11 +++++++---- goat/src/transactions/assert.rs | 5 +++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/goat/src/assert_scripts.rs b/goat/src/assert_scripts.rs index e06d56ef..f9383350 100644 --- a/goat/src/assert_scripts.rs +++ b/goat/src/assert_scripts.rs @@ -53,7 +53,7 @@ pub fn verify_prover_assert_script_768_wire( prover_wots_pubkey: &::PublicKey, ) -> Script { script! { - OP_DROP + OP_2DROP { Wots96::checksig_verify_and_clear_stack(prover_wots_pubkey) } OP_TRUE } diff --git a/goat/src/connectors/connector_c.rs b/goat/src/connectors/connector_c.rs index ecdb64c2..a788d50f 100644 --- a/goat/src/connectors/connector_c.rs +++ b/goat/src/connectors/connector_c.rs @@ -54,19 +54,22 @@ impl ConnectorC { &self, sk: &OperatorAssertSecretKey, proof: &[u8; 96], - extra_data: &[u8], + pi2: &[u8], + pi3: &[u8], ) -> Result>, Error> { let witness = Wots96::sign_to_raw_witness(sk, proof); let witness_script = script! { { witness.clone() } - { extra_data.to_vec() } + { pi2.to_vec() } + { pi3.to_vec() } }; let verification_script = witness_script.push_script(self.generate_taproot_leaf_1_script()); let exec_result = execute_script(verification_script); match exec_result.success { true => { let mut unlock_data = witness.to_vec(); - unlock_data.push(extra_data.to_vec()); + unlock_data.push(pi2.to_vec()); + unlock_data.push(pi3.to_vec()); Ok(unlock_data) } false => Err(Error::Other("Invalid WOTS secret-key for Connector-C.")), @@ -75,7 +78,7 @@ impl ConnectorC { pub fn extract_leaf_1_raw_witness(&self, txin: &TxIn) -> Result { let witness = txin.witness.to_vec(); - if witness.len() != PROVER_SIG_LEN + 3 { + if witness.len() != PROVER_SIG_LEN + 4 { return Err(Error::Other( "Invalid witness length for Connector-C leaf 1.", )); diff --git a/goat/src/transactions/assert.rs b/goat/src/transactions/assert.rs index e77c6360..3db9353e 100644 --- a/goat/src/transactions/assert.rs +++ b/goat/src/transactions/assert.rs @@ -123,11 +123,12 @@ impl OperatorAssertTransaction { wots_sk: &OperatorAssertSecretKey, connector_c: &ConnectorC, proof: &[u8; 96], - extra_data: &[u8], + pi2: &[u8], + pi3: &[u8], ) -> Result<(), Error> { let input_index = 0; let leaf_index = 1; - match connector_c.generate_leaf_1_unlock_data(wots_sk, proof, extra_data) { + match connector_c.generate_leaf_1_unlock_data(wots_sk, proof, pi2, pi3) { Ok(wit) => { populate_taproot_input_witness( self.tx_mut(),