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

ZIP 225 & ZIP 244 #375

Merged
merged 26 commits into from
Jun 8, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2ae55b4
Add more flexibility to vector serialization.
nuttycom May 12, 2021
4bcad97
Add amount conversion for Orchard values.
nuttycom May 12, 2021
fd1790f
Move sighash.rs -> sighash_v4.rs
nuttycom May 12, 2021
1138343
Add data structures for transaction digests.
nuttycom May 12, 2021
55d1090
Add v5 txid & signature hashing.
nuttycom May 12, 2021
1a5aad7
Use generalized signature_hash for transaction builder.
nuttycom May 13, 2021
e828dbf
Add v5 parsing and serialization for Sapling components.
nuttycom May 13, 2021
38b864c
Implement V5 transaction serialization & roundtrip property tests.
nuttycom May 13, 2021
dac68ce
Drop proptest space size to reduce test runtime.
nuttycom May 18, 2021
ab1b31e
Store partial authorizing data for transparent txs in transparent aut…
nuttycom Jun 3, 2021
6635895
Clean up TZE signature generation.
nuttycom Jun 4, 2021
6348400
Store patial authorizing data for sapling components in bundle author…
nuttycom Jun 4, 2021
df0095e
Add ZIP-244 test vectors.
nuttycom Jun 4, 2021
4623f98
Fix bugs in construction of Sapling txid hashes.
nuttycom Jun 4, 2021
e71a1ce
Rename Vector::write_items -> Array::write and Vector::read_count -> …
nuttycom Jun 4, 2021
28d3f48
Apply suggestions from code review.
nuttycom Jun 4, 2021
d0a911c
Fix rustdocs
nuttycom Jun 4, 2021
69e5a49
Fix generation of arbitrary jubjub points.
nuttycom Jun 4, 2021
47ce97c
Keep builder spend data in spend_auth_sig fields.
nuttycom Jun 5, 2021
97bef30
Remove consensus branch id from roundtrip serialization check.
nuttycom Jun 5, 2021
4f764c3
Use Vector read/write operations where possible instead of Array
nuttycom Jun 5, 2021
b93c503
Deserialize signatures directly into actions.
nuttycom Jun 5, 2021
0253442
Be more explicit about empty sapling & orchard hashes.
nuttycom Jun 5, 2021
371f84d
Minor error message improvement.
nuttycom Jun 5, 2021
f70285d
Fix error in transaction auth digest.
nuttycom Jun 5, 2021
eb3d01a
Apply suggestions from code review
nuttycom Jun 8, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix bugs in construction of Sapling txid hashes.
  • Loading branch information
nuttycom committed Jun 4, 2021
commit 4623f98d9a87b8f71ce383866f823bff92461745
6 changes: 5 additions & 1 deletion zcash_primitives/src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,11 @@ impl Transaction {
let orchard_bundle = Self::read_v5_orchard(&mut reader)?;

#[cfg(feature = "zfuture")]
let tze_bundle = Self::read_tze(&mut reader)?;
let tze_bundle = if version.has_tze() {
Self::read_tze(&mut reader)?
} else {
None
};

let data = TransactionData {
version,
Expand Down
2 changes: 1 addition & 1 deletion zcash_primitives/src/transaction/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ fn zip_0243() {
fn zip_0244() {
for tv in self::data::zip_0244::make_test_vectors() {
let tx = Transaction::read(&tv.tx[..], BranchId::Nu5).unwrap();
let txid_parts = tx.deref().digest(TxIdDigester);
assert_eq!(tx.txid.as_ref(), &tv.txid);

let txid_parts = tx.deref().digest(TxIdDigester);
match tv.transparent_input {
Some(n) => {
let script = Script(tv.script_code.unwrap());
Expand Down
26 changes: 15 additions & 11 deletions zcash_primitives/src/transaction/txid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,12 @@ pub(crate) fn hash_sapling_spends<A: sapling::Authorization>(
}

let mut h = hasher(ZCASH_SAPLING_SPENDS_HASH_PERSONALIZATION);
nuttycom marked this conversation as resolved.
Show resolved Hide resolved
h.write_all(&ch.finalize().as_bytes()).unwrap();
h.write_all(&nh.finalize().as_bytes()).unwrap();
if !shielded_spends.is_empty() {
let compact_digest = ch.finalize();
h.write_all(&compact_digest.as_bytes()).unwrap();
let noncompact_digest = nh.finalize();
h.write_all(&noncompact_digest.as_bytes()).unwrap();
}
h.finalize()
}

Expand All @@ -185,9 +189,11 @@ pub(crate) fn hash_sapling_outputs<A>(shielded_outputs: &[OutputDescription<A>])
}

let mut h = hasher(ZCASH_SAPLING_OUTPUTS_HASH_PERSONALIZATION);
nuttycom marked this conversation as resolved.
Show resolved Hide resolved
h.write_all(&ch.finalize().as_bytes()).unwrap();
h.write_all(&mh.finalize().as_bytes()).unwrap();
h.write_all(&nh.finalize().as_bytes()).unwrap();
if !shielded_outputs.is_empty() {
h.write_all(&ch.finalize().as_bytes()).unwrap();
h.write_all(&mh.finalize().as_bytes()).unwrap();
h.write_all(&nh.finalize().as_bytes()).unwrap();
}
h.finalize()
}

Expand Down Expand Up @@ -258,18 +264,16 @@ fn hash_sapling_txid_data<A: sapling::Authorization>(
) -> Blake2bHash {
let mut h = hasher(ZCASH_SAPLING_HASH_PERSONALIZATION);
if let Some(bundle) = sapling_bundle {
if !bundle.shielded_spends.is_empty() {
if !(bundle.shielded_spends.is_empty() && bundle.shielded_outputs.is_empty()) {
nuttycom marked this conversation as resolved.
Show resolved Hide resolved
h.write_all(hash_sapling_spends(&bundle.shielded_spends).as_bytes())
.unwrap();
}

if !bundle.shielded_outputs.is_empty() {
h.write_all(hash_sapling_outputs(&bundle.shielded_outputs).as_bytes())
.unwrap();
}

h.write_all(&bundle.value_balance.to_i64_le_bytes())
.unwrap();
h.write_all(&bundle.value_balance.to_i64_le_bytes())
.unwrap();
}
}
h.finalize()
}
Expand Down