From 932dc0ba55cc91602d660f3392bd3a5fc9e5d158 Mon Sep 17 00:00:00 2001 From: Sosthene00 Date: Tue, 30 Apr 2024 11:24:05 +0200 Subject: [PATCH] get_shared_point_from_transaction --- src/silentpayments.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/silentpayments.rs b/src/silentpayments.rs index 51c6c34..d4f815a 100644 --- a/src/silentpayments.rs +++ b/src/silentpayments.rs @@ -97,7 +97,15 @@ pub fn create_transaction_for_address_with_shared_secret( Ok((final_tx, AnkSharedSecret::new(shared_point, true))) } -// This need to go +pub fn get_shared_point_from_transaction(tx: &Transaction, sp_wallet: &SpWallet, tweak_data: PublicKey) -> Result<[u8;64]> { + let b_scan = sp_wallet.get_client().get_scan_key(); + let test = sp_client::bitcoin::secp256k1::ecdh::shared_secret_point(&tweak_data, &b_scan); + let ecdh_shared= sp_client::silentpayments::utils::receiving::calculate_shared_secret(tweak_data, b_scan)?; + let uncompressed = ecdh_shared.serialize_uncompressed(); + assert!(test == uncompressed[1..]); + Ok(test) +} + pub fn check_transaction( tx: &Transaction, sp_wallet: &mut SpWallet,