Skip to content

Commit

Permalink
test: make sure we fail on tapret commitment if no commitment was cre…
Browse files Browse the repository at this point in the history
…ated
  • Loading branch information
dr-orlovsky committed Oct 31, 2023
1 parent 29173ab commit 14b490b
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions dbc/src/tapret/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,40 @@ impl ConvolveCommit<mpc::Commitment, TapretProof, Lnpbp12> for Tx {
Err(TapretError::NoTaprootOutput)
}
}

#[cfg(test)]
mod test {
use std::str::FromStr;

use amplify::hex::FromHex;
use amplify::Bytes32;
use bc::InternalPk;
use commit_verify::mpc::Commitment;
use secp256k1::{ffi, XOnlyPublicKey};

use super::*;
use crate::tapret::TapretPathProof;

#[test]
fn no_commitment() {
let tx = Tx::from_str(
"020000000001027763e2a0ad25d45b63a19c33491b67c5037e72709121290bac5481a5d5d0c9330100000000ffffffff7763e2a0ad25d45b63a19c33491b67c5037e72709121290bac5481a5d5d0c9330400000000ffffffff02026e010000000000225120455dfcc062ef80609b007377f127e4abdb5cb0052158af1fab7aa628c34563f1d508000000000000225120a2788d4208ec6b4b600aef4c13075cf1d47bda0299ed1e6eedce4e7a90fb2a2c0141150df5377a34deded048dc01bff3d4f5f31d8a89fe2fbf1d0295993c1f899b3cefd1a63900ea6346b78edd476524c08ae094ff417bfa525b585ee66ebc26bb9e010141d959f21b498d90c2ff9f5b0bf3aee9158527501162eab2e3d56371714877a97df80caab15e366855aa56443b7d081c234a4ce4d6414815a874624cbe46b643370100000000"
).unwrap();

let internal_pk: XOnlyPublicKey = unsafe {
ffi::XOnlyPublicKey::from_array_unchecked(<[u8; 64]>::from_hex(
"cb5271aa59fc637e29d034ec75363ca241fda5d3939684603b469b185be7e50f18ec6fd539e7dc1fd5fb4cf046d2cef5028a5ca0cdb09a252683e6a6eb2ad61d",
).unwrap()).into()
};
let proof = TapretProof {
path_proof: TapretPathProof {
partner_node: None,
nonce: 0,
},
internal_pk: InternalPk::from(internal_pk),
};

let msg = Commitment::from(Bytes32::zero());
assert!(!ConvolveCommitProof::<_, Tx, _>::verify(&proof, &msg, &tx).unwrap())
}
}

0 comments on commit 14b490b

Please sign in to comment.