Skip to content
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

Integrate Orchard into Unified Address types #5569

Conversation

str4d
Copy link
Contributor

@str4d str4d commented Feb 19, 2022

This PR enables z_getnewaccount to produce accounts that support Orchard-containing UAs, but does not add support for generating those UAs.

Closes #5255.
Closes #5394.

@str4d str4d added A-wallet Area: Wallet A-orchard Area: Orchard protocol labels Feb 19, 2022
@str4d str4d changed the base branch from master to feature/wallet_orchard February 19, 2022 15:31
@str4d str4d force-pushed the feature/wallet_orchard-ua_integration branch 2 times, most recently from 8c3cb7d to 1fa9482 Compare February 21, 2022 15:15
Co-authored-by: Jack Grigg <jack@z.cash>
@str4d str4d force-pushed the feature/wallet_orchard-ua_integration branch from 1a41c57 to 454db83 Compare February 21, 2022 17:09
@str4d
Copy link
Contributor Author

str4d commented Feb 21, 2022

Force-pushed to add a few missing pieces to the "add Orchard to UAs" and "add Orchard to UFVKs" commits.

@str4d str4d force-pushed the feature/wallet_orchard-ua_integration branch from 454db83 to e9810d7 Compare February 21, 2022 17:34
CDataStream ss(data, SER_NETWORK, PROTOCOL_VERSION);
auto key = libzcash::OrchardFullViewingKey::Read(ss);
EXPECT_EQ(key, orchardKey);
}
// Enable the following after Orchard keys are supported.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this still be disabled? If it should, add a reference to the relevant issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is checking that constructing a UFVK from the same seed as the test vectors gives the same receivers, but the final overall check cannot be enabled without us having a way to construct a UFVK manually with an unknown component, because the test vectors chose to include an unknown component that by definition we cannot derive. Adding that API is out of scope for this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should modify the test vectors to also generate the UA that contains only the known receiver types.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not do this check only for the UAs without unknown components?

src/gtest/test_keys.cpp Outdated Show resolved Hide resolved
src/keystore.cpp Outdated Show resolved Hide resolved
@str4d str4d changed the title Integrate Orchard into Unified Addresses Integrate Orchard into Unified Address types Feb 21, 2022
@str4d str4d marked this pull request as ready for review February 21, 2022 18:20
@@ -576,7 +576,8 @@ std::optional<libzcash::ZcashdUnifiedSpendingKey>
throw std::runtime_error("CWallet::GenerateUnifiedSpendingKeyForAccount(): Failed to add Sapling change address to the wallet.");
};

// TODO ORCHARD: Add Orchard component to the wallet
// Add Orchard spending key to the wallet
orchardWallet.AddSpendingKey(usk.value().GetOrchardKey());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify, this change means that z_getnewaccount will start storing the Orchard component in memory, but this PR is not exposing this fact in z_getnewaccount or allowing Orchard-containing UAs to be derived. Those changes will be made in a subsequent PR.

Copy link
Contributor

@nuttycom nuttycom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flushing comments.

src/keystore.cpp Show resolved Hide resolved
src/keystore.cpp Show resolved Hide resolved
Copy link
Contributor

@nuttycom nuttycom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flushing more comments.

src/rust/include/rust/orchard/keys.h Show resolved Hide resolved
src/rust/src/orchard_keys_ffi.rs Outdated Show resolved Hide resolved
src/keystore.cpp Show resolved Hide resolved
auto ufvkpair = wallet.GenerateNewUnifiedSpendingKey();
auto ufvk = ufvkpair.first;
auto account = ufvkpair.second;
uaResult = wallet.GenerateUnifiedAddress(account, {ReceiverType::P2PKH, ReceiverType::Sapling});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this test Orchard yet?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not yet; that will be in a successor PR that @str4d is working on.

@r3ld3v r3ld3v added this to the Core Sprint 2022-04 milestone Feb 22, 2022
@nuttycom nuttycom marked this pull request as draft February 22, 2022 16:04
nuttycom and others added 5 commits February 22, 2022 21:08
Co-authored-by: Jack Grigg <jack@z.cash>
Co-authored-by: Jack Grigg <jack@z.cash>
Orchard spending keys now live exclusively on the Rust side, and will be
serialized there as part of the Orchard wallet serialization.
The only place we were using the returned Unified Spending Key was in a
test, where we immediately converted it to a UFVK.

Co-authored-by: Kris Nuttycombe <kris@nutty.land>
@str4d str4d force-pushed the feature/wallet_orchard-ua_integration branch from e9810d7 to d099e46 Compare February 22, 2022 21:11
@str4d
Copy link
Contributor Author

str4d commented Feb 22, 2022

Force-pushed to fix review comments, and add a missing handling of the Orchard component of a type conversion that was causing tests to fail. I'll push a separate commit to make the change to how UFVKs are looked up from Sapling addresses (to have it match Orchard).

This ensures we have the same semantics for detecting Orchard and
Sapling receivers in UAs, even if the UA they are part of was derived
outside of the zcashd wallet.
@str4d str4d marked this pull request as ready for review February 23, 2022 09:45
@r3ld3v r3ld3v requested a review from ebfull February 23, 2022 15:29
Copy link
Contributor

@nuttycom nuttycom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor issues.

src/rust/src/unified_keys_ffi.rs Show resolved Hide resolved
auto ufvkpair = wallet.GenerateNewUnifiedSpendingKey();
auto ufvk = ufvkpair.first;
auto account = ufvkpair.second;
uaResult = wallet.GenerateUnifiedAddress(account, {ReceiverType::P2PKH, ReceiverType::Sapling});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not yet; that will be in a successor PR that @str4d is working on.

src/zcash/Address.cpp Show resolved Hide resolved
src/zcash/address/orchard.hpp Show resolved Hide resolved
Copy link
Contributor

@nuttycom nuttycom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 3179e45 After discussion with @str4d, I've opened the following issues to to track work that shouldn't block this PR: #5583, #5584

Copy link
Contributor

@daira daira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@nuttycom nuttycom merged commit 49065be into zcash:feature/wallet_orchard Feb 23, 2022
@str4d str4d deleted the feature/wallet_orchard-ua_integration branch February 23, 2022 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-orchard Area: Orchard protocol A-wallet Area: Wallet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants