Bitcoin SpendableOutput::new

This commit is contained in:
Luke Parker
2023-03-19 23:22:51 -04:00
parent 60ca3a9599
commit 0aa6b561b7
3 changed files with 72 additions and 42 deletions

View File

@@ -1,8 +1,10 @@
use k256::{
elliptic_curve::sec1::{Tag, ToEncodedPoint},
ProjectivePoint,
Scalar, ProjectivePoint,
};
use frost::{curve::Secp256k1, ThresholdKeys};
use bitcoin::XOnlyPublicKey;
/// Get the x coordinate of a non-infinity, even point. Panics on invalid input.
@@ -27,3 +29,9 @@ pub fn make_even(mut key: ProjectivePoint) -> (ProjectivePoint, u64) {
}
(key, c)
}
/// Tweak keys to ensure they're usable with Bitcoin.
pub fn tweak_keys(keys: &ThresholdKeys<Secp256k1>) -> ThresholdKeys<Secp256k1> {
let (_, offset) = make_even(keys.group_key());
keys.offset(Scalar::from(offset))
}