@@ -26,9 +26,10 @@ use bitcoin::hashes::sha256::Hash as Sha256;
26
26
use bitcoin:: hashes:: sha256d:: Hash as Sha256dHash ;
27
27
use bitcoin:: hash_types:: WPubkeyHash ;
28
28
29
- use bitcoin:: secp256k1:: { PublicKey , Scalar , Secp256k1 , SecretKey , Signing } ;
29
+ use bitcoin:: secp256k1:: { KeyPair , PublicKey , Scalar , Secp256k1 , SecretKey , Signing } ;
30
30
use bitcoin:: secp256k1:: ecdh:: SharedSecret ;
31
31
use bitcoin:: secp256k1:: ecdsa:: { RecoverableSignature , Signature } ;
32
+ use bitcoin:: secp256k1:: schnorr;
32
33
use bitcoin:: { PackedLockTime , secp256k1, Sequence , Witness } ;
33
34
34
35
use crate :: util:: transaction_utils;
@@ -41,6 +42,7 @@ use crate::ln::{chan_utils, PaymentPreimage};
41
42
use crate :: ln:: chan_utils:: { HTLCOutputInCommitment , make_funding_redeemscript, ChannelPublicKeys , HolderCommitmentTransaction , ChannelTransactionParameters , CommitmentTransaction , ClosingTransaction } ;
42
43
use crate :: ln:: msgs:: { UnsignedChannelAnnouncement , UnsignedGossipMessage } ;
43
44
use crate :: ln:: script:: ShutdownScript ;
45
+ use crate :: offers:: merkle:: TaggedHash ;
44
46
45
47
use crate :: prelude:: * ;
46
48
use core:: convert:: TryInto ;
@@ -619,6 +621,15 @@ pub trait NodeSigner {
619
621
/// Errors if the [`Recipient`] variant is not supported by the implementation.
620
622
fn sign_invoice ( & self , hrp_bytes : & [ u8 ] , invoice_data : & [ u5 ] , recipient : Recipient ) -> Result < RecoverableSignature , ( ) > ;
621
623
624
+ /// Signs a BOLT 12 message.
625
+ ///
626
+ /// See [`SignFunction`] for details.
627
+ ///
628
+ /// [`SignFunction`]: crate::offers::merkle::SignFunction
629
+ fn sign_bolt12_message (
630
+ & self , message : & TaggedHash , metadata : & [ u8 ]
631
+ ) -> Result < schnorr:: Signature , ( ) > ;
632
+
622
633
/// Sign a gossip message.
623
634
///
624
635
/// Note that if this fails, LDK may panic and the message will not be broadcast to the network
@@ -1449,6 +1460,14 @@ impl NodeSigner for KeysManager {
1449
1460
Ok ( self . secp_ctx . sign_ecdsa_recoverable ( & hash_to_message ! ( & Sha256 :: hash( & preimage) ) , secret) )
1450
1461
}
1451
1462
1463
+ fn sign_bolt12_message (
1464
+ & self , message : & TaggedHash , _metadata : & [ u8 ]
1465
+ ) -> Result < schnorr:: Signature , ( ) > {
1466
+ let keys = KeyPair :: from_secret_key ( & self . secp_ctx , & self . node_secret ) ;
1467
+ let aux_rand = self . get_secure_random_bytes ( ) ;
1468
+ Ok ( self . secp_ctx . sign_schnorr_with_aux_rand ( & message. to_digest ( ) , & keys, & aux_rand) )
1469
+ }
1470
+
1452
1471
fn sign_gossip_message ( & self , msg : UnsignedGossipMessage ) -> Result < Signature , ( ) > {
1453
1472
let msg_hash = hash_to_message ! ( & Sha256dHash :: hash( & msg. encode( ) [ ..] ) [ ..] ) ;
1454
1473
Ok ( self . secp_ctx . sign_ecdsa ( & msg_hash, & self . node_secret ) )
@@ -1557,6 +1576,12 @@ impl NodeSigner for PhantomKeysManager {
1557
1576
Ok ( self . inner . secp_ctx . sign_ecdsa_recoverable ( & hash_to_message ! ( & Sha256 :: hash( & preimage) ) , secret) )
1558
1577
}
1559
1578
1579
+ fn sign_bolt12_message (
1580
+ & self , message : & TaggedHash , metadata : & [ u8 ]
1581
+ ) -> Result < schnorr:: Signature , ( ) > {
1582
+ self . inner . sign_bolt12_message ( message, metadata)
1583
+ }
1584
+
1560
1585
fn sign_gossip_message ( & self , msg : UnsignedGossipMessage ) -> Result < Signature , ( ) > {
1561
1586
self . inner . sign_gossip_message ( msg)
1562
1587
}
0 commit comments