-
Notifications
You must be signed in to change notification settings - Fork 868
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
Implement ZCash transparent tx signing #20895
Conversation
A Storybook has been deployed to preview UI for the latest push |
A Storybook has been deployed to preview UI for the latest push |
@@ -267,7 +286,7 @@ absl::optional<std::string> ZCashWalletService::GetUnusedChangeAddress( | |||
// TODO(cypt4): this always returns first change address. Should return | |||
// first unused change address. | |||
return keyring_service_->GetZCashAddress( | |||
account_id, mojom::ZCashKeyId(account_id.bitcoin_account_index, 1, 0)); | |||
account_id, mojom::ZCashKeyId(account_id.bitcoin_account_index, 0, 0)); |
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.
This now returns first receive address. Is this expected?
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, it simplifies testing until discovery is implemented
A Storybook has been deployed to preview UI for the latest push |
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.
wallet core lgtm with some nits
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.
++ Desktop Front-end
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.
My apologies on the delay in getting this review back to you. There's one blocking concern around the rule of 2, but everything else is just questions to make sure my understanding isn't missing anything.
@@ -21,13 +22,13 @@ constexpr uint32_t kWitnessScaleFactor = 4; | |||
namespace { | |||
|
|||
void PushOutpoint(const BitcoinTransaction::Outpoint& outpoint, | |||
BitcoinSerializerStream& stream) { | |||
BtcLikeSerializerStream& stream) { |
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.
would it be more useful to refer to this as a UtxoSerializerStream
instead?
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.
@supermassive WDYT?
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's use naming which refers to origin of this binary format. And there are some utxo-based crypto currencies that are not based on bitcoin.
@@ -598,7 +598,8 @@ const mojom::NetworkInfo* GetZCashMainnet() { | |||
static base::NoDestructor<mojom::NetworkInfo> network_info( | |||
{chain_id, | |||
"ZCash Mainnet", | |||
{""}, // TODO(cypt4): explorer url | |||
{"https://zcashblockexplorer.com/transactions"}, // TODO(cypt4): |
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.
nit: might be worth refactoring all of these urls into the constants file
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'm fine with this being done in a follow up PR as well.
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 think we can move whole list of default network infos to another file.
@supermassive wdyt?
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.
This whole file needs some cleanup I think :)
|
||
namespace brave_wallet { | ||
|
||
TEST(ZCashSerializerTest, HashPrevouts) { |
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.
are these standardized test vectors listed somewhere or just tests to make sure code doesn't break if we refactor in the future?
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.
There are vectors, but they mostly depend on shielded parts too, so we can't just borrow them at this moment.
I've added a couple of tests based on real transactions here: ZCashSerializerTest::TxId_TransparentOnly and
ZCashWalletServiceUnitTest, SignAndPostTransaction.
Tests for Hash* are just making easier to find which part is actually broken.
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.
We can likely generate these from here: https://github.com/zcash/zcash-test-vectors
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.
As i see there is no intermediate data like sub-digests in such vectors.
I think we can just reuse published vectors when shielded will be implemented for top-level things like tx id and sig digest.
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.
Approving, but we'll need to address some issues in follow up PRs
A Storybook has been deployed to preview UI for the latest push |
A Storybook has been deployed to preview UI for the latest push |
A Storybook has been deployed to preview UI for the latest push |
/build android |
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.
iOS++
Implement ZCash transparent tx signing
Resolves brave/brave-browser#33661
Tx id digest and signature per-input digest is calculated via https://zips.z.cash/zip-0244.
Calculation is implemented in ZCashSerializer.
Nu5 Tx format https://zips.z.cash/zip-0225. Implemented in ZCashSerializer::SerializeRawTransaction.
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
wikinpm run lint
,npm run presubmit
wiki,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan: