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

Make transparent signatures commit to all input amounts & scripts. #472

Merged
merged 6 commits into from
Jan 19, 2022

Conversation

nuttycom
Copy link
Contributor

@nuttycom nuttycom commented Dec 23, 2021

This implements the changes to ZIP 244 sighash rules specified in zcash/zips#577 .

Transparent UTXOs are referred to as a pair of previous txid and index. In order to verify a UTXO's amount, e.g. in a hardware wallet, under the previous rules the whole previous transaction containing this UTXO would have needed to be streamed into the device. This would have increased the complexity of signing process significantly, but is not necessary under the new rules.

Fixes #473

@nuttycom nuttycom requested review from str4d and daira December 23, 2021 21:16
@nuttycom nuttycom marked this pull request as draft December 23, 2021 21:18
@nuttycom nuttycom force-pushed the zip_244/hw_wallet_commitments branch 2 times, most recently from cf8a31c to 7fcad74 Compare January 6, 2022 05:11
@nuttycom nuttycom marked this pull request as ready for review January 6, 2022 05:11
@r3ld3v r3ld3v added this to the Core Sprint 2021-52 milestone Jan 6, 2022
@r3ld3v r3ld3v requested a review from ebfull January 6, 2022 15:13
@nuttycom nuttycom force-pushed the zip_244/hw_wallet_commitments branch 5 times, most recently from 3e984cf to f38f5a4 Compare January 7, 2022 18:03
@codecov
Copy link

codecov bot commented Jan 7, 2022

Codecov Report

Merging #472 (eaa3ec5) into master (c910ffd) will increase coverage by 0.37%.
The diff coverage is 53.74%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #472      +/-   ##
==========================================
+ Coverage   50.20%   50.57%   +0.37%     
==========================================
  Files          88       88              
  Lines        7962     8002      +40     
==========================================
+ Hits         3997     4047      +50     
+ Misses       3965     3955      -10     
Impacted Files Coverage Δ
zcash_primitives/src/legacy.rs 78.94% <ø> (ø)
zcash_primitives/src/transaction/builder.rs 49.26% <0.00%> (+0.71%) ⬆️
...sh_primitives/src/transaction/components/sprout.rs 33.84% <ø> (ø)
.../src/transaction/components/transparent/builder.rs 63.15% <0.00%> (-11.85%) ⬇️
zcash_primitives/src/transaction/tests/data.rs 100.00% <ø> (ø)
zcash_primitives/src/transaction/sighash.rs 36.36% <37.50%> (+16.36%) ⬆️
zcash_primitives/src/transaction/sighash_v5.rs 41.75% <39.47%> (+6.23%) ⬆️
zcash_primitives/src/transaction/sighash_v4.rs 46.21% <46.66%> (+2.30%) ⬆️
zcash_primitives/src/transaction/mod.rs 32.11% <50.00%> (+0.61%) ⬆️
zcash_primitives/src/transaction/tests.rs 88.15% <94.28%> (-1.08%) ⬇️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c910ffd...eaa3ec5. Read the comment docs.

@nuttycom nuttycom added the S-committed Status: Planned work in a sprint label Jan 10, 2022
@nuttycom nuttycom force-pushed the zip_244/hw_wallet_commitments branch 3 times, most recently from c808f36 to c66bb89 Compare January 13, 2022 14:54
Copy link
Contributor

@str4d str4d left a comment

Choose a reason for hiding this comment

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

utACK

zcash_primitives/src/transaction/tests.rs Outdated Show resolved Hide resolved
@@ -5985,39 +5986,36 @@ pub mod zip_0244 {
0xdc, 0x7f, 0x83, 0x46, 0xb2, 0x82, 0xec, 0x04, 0xb8, 0x40, 0xf2, 0x45, 0x1d,
0x09, 0xc0, 0x86, 0x3c, 0xda, 0x6b,
],
Copy link
Contributor

Choose a reason for hiding this comment

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

I have not checked the test data changes.

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.

https://github.com/zcash/librustzcash/pull/472/files/c66bb892baf7e54437be7341c163f40909a64b43#r785116088 (the incorrect comment in sighash_v5::transparent_sig_digest) is blocking.

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

@daira
Copy link
Contributor

daira commented Jan 18, 2022

The refactoring of array hashing needed a rustfmt, sorry about that.

@nuttycom nuttycom force-pushed the zip_244/hw_wallet_commitments branch from 9baceba to 8cf5c8c Compare January 18, 2022 22:31
nuttycom and others added 6 commits January 19, 2022 08:32
Transparent UTXOs are referred as pair of previous txid and index. In
order to verify UTXO's amount in HWW (hardware wallet), whole previous
transaction containing this UTXO must be streamed into the device. This
increases complexity of signing process significantly.

zcash/zips#574 identifies this problem and suggests a modification
to ZIP-244 to resolve this issue, by adding three new fields to
section S.2 of the signature hash.
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
@nuttycom nuttycom force-pushed the zip_244/hw_wallet_commitments branch from 8cf5c8c to eaa3ec5 Compare January 19, 2022 15:33
@nuttycom nuttycom merged commit 81c69dd into zcash:master Jan 19, 2022
@nuttycom nuttycom deleted the zip_244/hw_wallet_commitments branch January 19, 2022 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-committed Status: Planned work in a sprint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ZIP 244: Implement changes to bring its transparent semantics closer to BIP 341
4 participants