-
Notifications
You must be signed in to change notification settings - Fork 376
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove get_node_secret from NodeSigner
Secrets should not be exposed in-memory at the interface level as it would be impossible to implement it against a hardware security module/secure element.
- Loading branch information
Showing
20 changed files
with
571 additions
and
334 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ | |
|
||
pub mod test_logger; | ||
pub mod test_persister; | ||
pub mod test_node_signer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// This file is Copyright its original authors, visible in version control | ||
// history. | ||
// | ||
// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE | ||
// or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. | ||
// You may not use this file except in accordance with one or both of these | ||
// licenses. | ||
|
||
use bitcoin::secp256k1::{PublicKey, SecretKey, Secp256k1}; | ||
use bitcoin::secp256k1::ecdh::SharedSecret; | ||
|
||
use lightning::chain::keysinterface::{NodeSigner, Recipient}; | ||
|
||
pub struct TestNodeSigner { | ||
node_secret: SecretKey, | ||
} | ||
|
||
impl TestNodeSigner { | ||
pub fn new(node_secret: SecretKey) -> Self { | ||
Self { node_secret } | ||
} | ||
} | ||
|
||
impl NodeSigner for TestNodeSigner { | ||
fn get_inbound_payment_key_material(&self) -> lightning::chain::keysinterface::KeyMaterial { | ||
unreachable!() | ||
} | ||
|
||
fn get_node_id(&self, recipient: Recipient) -> Result<PublicKey, ()> { | ||
let node_secret = match recipient { | ||
Recipient::Node => Ok(&self.node_secret), | ||
Recipient::PhantomNode => Err(()) | ||
}?; | ||
Ok(PublicKey::from_secret_key(&Secp256k1::new(), node_secret)) | ||
} | ||
|
||
fn ecdh(&self, recipient: Recipient, other_key: &PublicKey, tweak: Option<&bitcoin::secp256k1::Scalar>) -> Result<SharedSecret, ()> { | ||
let mut node_secret = match recipient { | ||
Recipient::Node => Ok(self.node_secret.clone()), | ||
Recipient::PhantomNode => Err(()) | ||
}?; | ||
if let Some(tweak) = tweak { | ||
node_secret = node_secret.mul_tweak(tweak).map_err(|_| ())?; | ||
} | ||
Ok(SharedSecret::new(other_key, &node_secret)) | ||
} | ||
|
||
fn sign_invoice(&self, _: &[u8], _: &[bitcoin::bech32::u5], _: Recipient) -> Result<bitcoin::secp256k1::ecdsa::RecoverableSignature, ()> { | ||
unreachable!() | ||
} | ||
|
||
fn sign_gossip_message(&self, _: lightning::ln::msgs::UnsignedGossipMessage) -> Result<bitcoin::secp256k1::ecdsa::Signature, ()> { | ||
unreachable!() | ||
} | ||
} |
Oops, something went wrong.