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

Implementation for ZIP-222 Transparent Zcash Extensions #286

Merged
merged 52 commits into from
Oct 13, 2020

Conversation

nuttycom
Copy link
Contributor

@nuttycom nuttycom commented Sep 1, 2020

This implements the core data structures and transaction builder function for TZEs.

ZIP: zcash/zips#248

@codecov
Copy link

codecov bot commented Sep 1, 2020

Codecov Report

Merging #286 into master will decrease coverage by 1.27%.
The diff coverage is 53.28%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #286      +/-   ##
==========================================
- Coverage   68.17%   66.89%   -1.28%     
==========================================
  Files          59       62       +3     
  Lines        5963     6435     +472     
==========================================
+ Hits         4065     4305     +240     
- Misses       1898     2130     +232     
Impacted Files Coverage Δ
zcash_extensions/src/consensus/transparent.rs 0.00% <0.00%> (ø)
zcash_primitives/src/consensus.rs 17.96% <0.00%> (-1.39%) ⬇️
zcash_primitives/src/legacy.rs 67.53% <ø> (+1.29%) ⬆️
zcash_primitives/src/prover.rs 33.33% <ø> (+2.56%) ⬆️
zcash_primitives/src/redjubjub.rs 87.12% <ø> (+0.25%) ⬆️
...sh_primitives/src/transaction/components/amount.rs 42.55% <ø> (ø)
zcash_primitives/src/extensions/transparent.rs 33.33% <33.33%> (ø)
zcash_primitives/src/transaction/builder.rs 57.93% <42.10%> (-1.24%) ⬇️
zcash_primitives/src/transaction/mod.rs 44.33% <54.76%> (-3.93%) ⬇️
zcash_primitives/src/transaction/sighash.rs 75.51% <56.09%> (-14.20%) ⬇️
... and 36 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 d077872...eeb0c2b. Read the comment docs.

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.

Looking good overall!

Cargo.toml Outdated Show resolved Hide resolved
zcash_extensions/Cargo.toml Outdated Show resolved Hide resolved
zcash_extensions/src/consensus/transparent.rs Outdated Show resolved Hide resolved
zcash_extensions/src/consensus/transparent.rs Show resolved Hide resolved
zcash_extensions/src/consensus/transparent.rs Show resolved Hide resolved
zcash_extensions/src/transparent/demo.rs Outdated Show resolved Hide resolved
zcash_extensions/src/transparent/demo.rs Outdated Show resolved Hide resolved
zcash_extensions/src/transparent/demo.rs Outdated Show resolved Hide resolved
zcash_extensions/src/transparent/demo.rs Outdated Show resolved Hide resolved
zcash_extensions/src/transparent/demo.rs Outdated Show resolved Hide resolved
nuttycom and others added 2 commits September 23, 2020 13:44
Co-authored-by: str4d <thestr4d@gmail.com>
@nuttycom nuttycom requested a review from str4d September 23, 2020 20:49
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

}

#[derive(Debug, PartialEq)]
pub enum Error<E> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It may be possible now to move this to zcash_extensions.

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 with comments.

zcash_extensions/Cargo.toml Outdated Show resolved Hide resolved
zcash_primitives/src/extensions/transparent.rs Outdated Show resolved Hide resolved
zcash_extensions/src/transparent/demo.rs Show resolved Hide resolved
zcash_extensions/src/transparent/demo.rs Show resolved Hide resolved
zcash_primitives/src/transaction/builder.rs Outdated Show resolved Hide resolved
zcash_primitives/src/transaction/builder.rs Outdated Show resolved Hide resolved
// The witness is expected to commit to the precommitment internally?
// (Or make it part of the sighash?)
// - TODO: Check whether transparent inputs committing to script_pubkey was
// only so that hardware wallets "knew" what address was being spent from.
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe so. @str4d?

(In any case this TODO should be resolved.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@str4d what are your thoughts here? It seems like the information that a hardware wallet would need to display to the user in order for that user to be able to confidently sign a TZE transaction would vary by TZE; is there actually anything "general" that we can do here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the "general" thing we do is what we are currently doing: require the entire TZE precondition to be part of the signed transaction digest. Any future address format linked to TZEs would be inherently linked to a particular precondition, and thus derivable from it.

The "Need to enable witness to commit to the amount" is already "solved", because each TZE has access to the prevout before calling Builder::add_tze_input, so they can cache the needed properties there. Alternatively, we could explicitly pass the prevout back to them when calling tze_in.builder.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think expecting the TZE to cache what it needs is the proper thing to do here. That makes it so that there's a single path by which the implementers can achieve their goal, which is a good thing.

zcash_extensions/Cargo.toml Outdated Show resolved Hide resolved
nuttycom and others added 2 commits October 9, 2020 16:19
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
@str4d str4d added the S-committed Status: Planned work in a sprint label Oct 12, 2020
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.

5 participants