1use bc::{ScriptPubkey, TxOut};
23use commit_verify::{mpc, ConvolveCommit, ConvolveCommitProof};
24
25use super::{TapretFirst, TapretKeyError, TapretProof};
26
27impl ConvolveCommitProof<mpc::Commitment, TxOut, TapretFirst> for TapretProof {
28 type Suppl = Self;
29
30 fn restore_original(&self, commitment: &TxOut) -> TxOut {
31 TxOut {
32 value: commitment.value,
33 script_pubkey: self.original_pubkey_script(),
34 }
35 }
36
37 fn extract_supplement(&self) -> &Self::Suppl { self }
38}
39
40impl ConvolveCommit<mpc::Commitment, TapretProof, TapretFirst> for TxOut {
41 type Commitment = TxOut;
42 type CommitError = TapretKeyError;
43
44 fn convolve_commit(
45 &self,
46 supplement: &TapretProof,
47 msg: &mpc::Commitment,
48 ) -> Result<(TxOut, TapretProof), Self::CommitError> {
49 let (output_key, _) =
50 supplement.internal_pk.convolve_commit(&supplement.path_proof, msg)?;
51
52 let script_pubkey = ScriptPubkey::p2tr_tweaked(output_key);
53
54 let commitment = TxOut {
55 value: self.value,
56 script_pubkey,
57 };
58
59 Ok((commitment, supplement.clone()))
60 }
61}