-
Notifications
You must be signed in to change notification settings - Fork 219
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
feat: support for stealth addresses in one-sided transactions #4310
feat: support for stealth addresses in one-sided transactions #4310
Conversation
… of one-sided transactions, with simple and stealth addresses Signed-off-by: Andrei Gubarev <[email protected]>
Signed-off-by: Andrei Gubarev <[email protected]>
…ealth_addresses_clean
…esses_clean # Conflicts: # base_layer/wallet/src/output_manager_service/service.rs
Signed-off-by: Andrei Gubarev <[email protected]>
…ealth_addresses_clean
Signed-off-by: Andrei Gubarev <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
let ks = PublicKey::from_secret_key(&c) + public_key; | ||
|
||
if &ks != provided_spending_public.as_ref() { | ||
return None; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think return here will give the correct behaviour.
If this case here is not correct, we should not drop all other correct UTXO and return back with none. This is in the middle of an iteration, I suspect you only want to continue here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, return None
is to skip, to return from filter_map
closure. This function is to only find and add certain outputs, it's not supposed to pass anything through.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was also thrown by this. I think the filter_map is too large and you should probably rather use a simple for loop
Signed-off-by: Andrei Gubarev <[email protected]>
changed DSH label for stealth addresses to `com.tari.stealth_address` Signed-off-by: Andrei Gubarev <[email protected]>
ff8cf24
to
31715a0
Compare
let ks = PublicKey::from_secret_key(&c) + public_key; | ||
|
||
if &ks != provided_spending_public.as_ref() { | ||
return None; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was also thrown by this. I think the filter_map is too large and you should probably rather use a simple for loop
// ---------------------------------------------------------------------------- | ||
// simple one-sided address | ||
[Opcode::PushPubKey(spending_key_public)] => { | ||
let keys = match self.resources.db.get_all_known_one_sided_payment_scripts() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling this db method for every output is not necessary, rather move it outside the loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed
Signed-off-by: Andrei Gubarev <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - just a couple of small comments
@@ -1888,97 +1891,159 @@ where | |||
Ok(()) | |||
} | |||
|
|||
/// Attempt to scan and then rewind all of the given transaction outputs into unblinded outputs based on known | |||
/// pubkeys | |||
fn scan_outputs_for_one_sided_payments( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fn scan_outputs_for_one_sided_payments( | |
/// Attempt to scan and then rewind all of the given transaction outputs into unblinded outputs based on known | |
/// pubkeys | |
fn scan_outputs_for_one_sided_payments( |
// ---------------------------------------------------------------------------- | ||
// simple one-sided address | ||
[Opcode::PushPubKey(spending_key_public)] => { | ||
let keys = match self.resources.db.get_all_known_one_sided_payment_scripts() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed
// NOTE: [RFC 203 on Stealth Addresses](https://rfc.tari.com/RFC-0203_StealthAddresses.html) | ||
[Opcode::PushPubKey(nonce), Opcode::Drop, Opcode::PushPubKey(scanned_pk)] => { | ||
// computing shared secret | ||
let c = RistrettoSecretKey::from_bytes( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let c = RistrettoSecretKey::from_bytes( | |
let stealth_key = PrivateKey::from_bytes( |
We should use the generic types as far as possible
Please add unit and cucumber tests (see |
This is planned in next PR, because for that we need both PRs (this is scanning, and other one is sending) to be merged. |
Your PR has already been merged @Cifko |
Signed-off-by: Andrei Gubarev <[email protected]>
# Conflicts: # base_layer/wallet/src/output_manager_service/service.rs
Signed-off-by: Andrei Gubarev <[email protected]>
Signed-off-by: Andrei Gubarev <[email protected]>
Signed-off-by: Andrei Gubarev <[email protected]>
…ealth_addresses_clean # Conflicts: # integration_tests/features/support/wallet_steps.js # integration_tests/features/support/world.js
@@ -32,6 +32,35 @@ Feature: Wallet Transactions | |||
Then all nodes are at height 30 | |||
Then I wait for wallet WALLET_C to have at least 1500000 uT | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@critical |
base_layer/wallet_ffi/src/lib.rs
Outdated
/// # Safety | ||
/// The `public_key_destroy()` must be called when finished with a `TariPublicKey` to prevent a memory leak | ||
#[no_mangle] | ||
pub unsafe extern "C" fn private_key_add( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think these are needed
Signed-off-by: Andrei Gubarev <[email protected]>
1daf76e
to
b5b20b5
Compare
Description
Added support of one-sided transactions with stealth addresses to the output scanner.
Motivation and Context
https://rfc.tari.com/RFC-0203_StealthAddresses.html
How Has This Been Tested?
manually, unit tests