fedimint_lnv2_common/tweak.rs
1use bitcoin::key::Keypair;
2use bitcoin::secp256k1::{self, PublicKey};
3use fedimint_core::secp256k1::ecdh;
4use rand;
5
6pub fn generate(static_pk: PublicKey) -> ([u8; 32], PublicKey) {
7 let keypair = Keypair::new(secp256k1::SECP256K1, &mut rand::thread_rng());
8
9 let tweak = ecdh::SharedSecret::new(&static_pk, &keypair.secret_key());
10
11 (tweak.secret_bytes(), keypair.public_key())
12}