Skip to content

Commit 7af0999

Browse files
committed
Re-name TweakedPublicKey constructor
Keeping inline with the method on `UntweakedPublicKey` that outputs a `TweakedPublicKey` we can use the same name, for the same reasons. Use `dangerous_assume_tweaked` as the constructor name to highlight the fact that this constructor should probably not be being used.
1 parent 3c3cf03 commit 7af0999

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/util/schnorr.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ impl TapTweak for UntweakedPublicKey {
6565

6666

6767
impl TweakedPublicKey {
68-
/// Create a new [TweakedPublicKey] from a [PublicKey]. No tweak is applied.
69-
pub fn new(key: PublicKey) -> TweakedPublicKey {
68+
/// Creates a new [`TweakedPublicKey`] from a [`PublicKey`]. No tweak is applied, consider
69+
/// calling `tap_tweak` on an [`UntweakedPublicKey`] instead of using this constructor.
70+
pub fn dangerous_assume_tweaked(key: PublicKey) -> TweakedPublicKey {
7071
TweakedPublicKey(key)
7172
}
7273

src/util/taproot.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ impl TaprootSpendInfo {
268268
internal_key: internal_key,
269269
merkle_root: merkle_root,
270270
output_key_parity: parity,
271-
output_key: TweakedPublicKey::new(output_key),
271+
output_key: TweakedPublicKey::dangerous_assume_tweaked(output_key),
272272
script_map: BTreeMap::new(),
273273
}
274274
}
@@ -985,7 +985,7 @@ mod test {
985985

986986
fn _verify_tap_commitments(secp: &Secp256k1<VerifyOnly>, out_spk_hex: &str, script_hex : &str, control_block_hex: &str) {
987987
let out_pk = schnorr::PublicKey::from_str(&out_spk_hex[4..]).unwrap();
988-
let out_pk = TweakedPublicKey::new(out_pk);
988+
let out_pk = TweakedPublicKey::dangerous_assume_tweaked(out_pk);
989989
let script = Script::from_hex(script_hex).unwrap();
990990
let control_block = ControlBlock::from_slice(&Vec::<u8>::from_hex(control_block_hex).unwrap()).unwrap();
991991
assert_eq!(control_block_hex, control_block.serialize().to_hex());

0 commit comments

Comments
 (0)