-
Notifications
You must be signed in to change notification settings - Fork 409
Onion messages v1 #1503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Onion messages v1 #1503
Changes from all commits
4e5381a
33ff274
6017379
4c8dc2c
9051c38
bf007ea
b26fb85
eaff561
6500c99
39397d4
17ec697
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ use bitcoin::hash_types::WPubkeyHash; | |
|
||
use bitcoin::secp256k1::{SecretKey, PublicKey}; | ||
use bitcoin::secp256k1::{Secp256k1, ecdsa::Signature, Signing}; | ||
use bitcoin::secp256k1::ecdh::SharedSecret; | ||
use bitcoin::secp256k1::ecdsa::RecoverableSignature; | ||
use bitcoin::{secp256k1, Witness}; | ||
|
||
|
@@ -404,6 +405,12 @@ pub trait KeysInterface { | |
/// This method must return the same value each time it is called with a given `Recipient` | ||
/// parameter. | ||
fn get_node_secret(&self, recipient: Recipient) -> Result<SecretKey, ()>; | ||
/// Gets the ECDH shared secret of our [`node secret`] and `other_key`, multiplying by `tweak` if | ||
/// one is provided. Note that this tweak can be applied to `other_key` instead of our node | ||
/// secret, though this is less efficient. | ||
/// | ||
/// [`node secret`]: Self::get_node_secret | ||
fn ecdh(&self, recipient: Recipient, other_key: &PublicKey, tweak: Option<&[u8; 32]>) -> Result<SharedSecret, ()>; | ||
/// Get a script pubkey which we send funds to when claiming on-chain contestable outputs. | ||
/// | ||
/// This method should return a different value each time it is called, to avoid linking | ||
|
@@ -1133,6 +1140,14 @@ impl KeysInterface for KeysManager { | |
} | ||
} | ||
|
||
fn ecdh(&self, recipient: Recipient, other_key: &PublicKey, tweak: Option<&[u8; 32]>) -> Result<SharedSecret, ()> { | ||
let mut node_secret = self.get_node_secret(recipient)?; | ||
if let Some(tweak) = tweak { | ||
node_secret.mul_assign(tweak).map_err(|_| ())?; | ||
} | ||
Ok(SharedSecret::new(other_key, &node_secret)) | ||
} | ||
|
||
fn get_inbound_payment_key_material(&self) -> KeyMaterial { | ||
self.inbound_payment_key.clone() | ||
} | ||
|
@@ -1217,6 +1232,14 @@ impl KeysInterface for PhantomKeysManager { | |
} | ||
} | ||
|
||
fn ecdh(&self, recipient: Recipient, other_key: &PublicKey, tweak: Option<&[u8; 32]>) -> Result<SharedSecret, ()> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So actually I think you could have a feature combining route blinding + phantom node, where if you select one of the real node as the introduction node, any other node part of the phantom node should be able to decrypt the next I think it would increase the receiver confidentiality as a) if the onion sender doesn't have knowledge of the phantom set, she shouldn't be able to observe the "onion swap" between the phantoms and b) even if the onion sender does have knowledge of the phantom set, this should increase the receiver anonymity set by the topology of any real node. Just an idea for the future, I don't know if it holds. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool, noted this in the follow-up issue #1607 |
||
let mut node_secret = self.get_node_secret(recipient)?; | ||
if let Some(tweak) = tweak { | ||
node_secret.mul_assign(tweak).map_err(|_| ())?; | ||
} | ||
Ok(SharedSecret::new(other_key, &node_secret)) | ||
} | ||
|
||
fn get_inbound_payment_key_material(&self) -> KeyMaterial { | ||
self.inbound_payment_key.clone() | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.