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

Fix Orchard implementation, refactor, and add more test vectors #2445

Merged
merged 23 commits into from
Jul 16, 2021

Conversation

dconnolly
Copy link
Contributor

@dconnolly dconnolly commented Jul 5, 2021

Motivation

We want our Orchard code in zebra-chain to conform to the independent Python implementation in zcash-hackworks, for confidence in the correctness (or at least agreement in implementation) of our implementation.

Solution

Pull in generated test vectors for:

  • empty note commitment tree roots
  • non-empty note commitment trees
  • key components
  • sinsemilla

Resolves #2079

Review

@conradoplg @upbqdn @jvff @teor2345

Reviewer Checklist

  • Code implements Specs and Designs
  • Tests for Expected Behaviour

Follow Up Work

Wallet/transaction/proof-creation test vectors are out of scope until we build Zebra Client / wallet functionality.

@dconnolly dconnolly force-pushed the orchard-keys-notes-nullifers-test-vectors branch from b0ac7e8 to c5cb86c Compare July 5, 2021 22:04
@dconnolly dconnolly marked this pull request as ready for review July 5, 2021 22:05
@dconnolly dconnolly added the A-rust Area: Updates to Rust code label Jul 5, 2021
@dconnolly dconnolly added this to the 2021 Sprint 13 milestone Jul 5, 2021
jvff
jvff previously approved these changes Jul 6, 2021
Copy link
Contributor

@jvff jvff left a comment

Choose a reason for hiding this comment

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

Looks good to me, but the crypto parts are out of my current reach 😓

Added some optional suggestions 👍

zebra-chain/src/orchard/commitment.rs Outdated Show resolved Hide resolved
zebra-chain/src/orchard/sinsemilla.rs Outdated Show resolved Hide resolved
zebra-chain/src/orchard/sinsemilla.rs Outdated Show resolved Hide resolved
zebra-chain/src/orchard/sinsemilla.rs Outdated Show resolved Hide resolved
zebra-chain/src/orchard/keys.rs Outdated Show resolved Hide resolved
zebra-chain/src/orchard/keys/tests.rs Outdated Show resolved Hide resolved
zebra-chain/src/orchard/note.rs Outdated Show resolved Hide resolved
zebra-chain/src/orchard/keys.rs Show resolved Hide resolved
Copy link
Contributor

@teor2345 teor2345 left a comment

Choose a reason for hiding this comment

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

I have a few comments about the code, but it mostly looks good.

It looks like this PR contains bug fixes or refactors, as well as tests.
Can you rename this PR so the changelog is accurate?

In future, can we split PRs like this into smaller changes?
It helps keep code reviews more focused.

Maybe we could have done the refactors later, or split the changes by module. But I understand that is not always possible.

@mpguerra mpguerra removed this from the 2021 Sprint 13 milestone Jul 6, 2021
Copy link
Collaborator

@conradoplg conradoplg left a comment

Choose a reason for hiding this comment

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

I've reviewed the code, mainly the crypto parts, and it looks good.

After that I've addressed the issues.

zebra-chain/src/orchard/address.rs Outdated Show resolved Hide resolved
zebra-chain/src/orchard/commitment.rs Outdated Show resolved Hide resolved
zebra-chain/src/orchard/keys/tests.rs Outdated Show resolved Hide resolved
zebra-chain/src/orchard/note.rs Outdated Show resolved Hide resolved
zebra-chain/src/orchard/sinsemilla.rs Show resolved Hide resolved
zebra-chain/src/orchard/keys.rs Show resolved Hide resolved
zebra-chain/src/orchard/sinsemilla.rs Outdated Show resolved Hide resolved
zebra-chain/src/orchard/sinsemilla.rs Outdated Show resolved Hide resolved
zebra-chain/src/orchard/sinsemilla.rs Outdated Show resolved Hide resolved
zebra-chain/src/orchard/keys.rs Outdated Show resolved Hide resolved
@teor2345 teor2345 changed the title More Orchard test vectors conformance tests Fix Orchard implementation, refactor, and add more test vectors Jul 14, 2021
@teor2345
Copy link
Contributor

It looks like this PR contains bug fixes or refactors, as well as tests.
Can you rename this PR so the changelog is accurate?

I renamed the PR.

zebra-chain/src/orchard/commitment.rs Show resolved Hide resolved
zebra-chain/src/orchard/note.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@conradoplg conradoplg left a comment

Choose a reason for hiding this comment

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

Addressed comments and synced with main.

While syncing I renamed the test_vectors.rs added in #2407 (which was renamed to empty_roots.rs in this PR) to tree.rs (since it now contains empty roots, commitments and resulting roots)

zebra-chain/src/orchard/commitment.rs Outdated Show resolved Hide resolved
zebra-chain/src/orchard/note.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@teor2345 teor2345 left a comment

Choose a reason for hiding this comment

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

Seems good to me!

@conradoplg conradoplg enabled auto-merge (squash) July 16, 2021 13:31
@conradoplg conradoplg merged commit 8a4add5 into main Jul 16, 2021
@conradoplg conradoplg deleted the orchard-keys-notes-nullifers-test-vectors branch July 16, 2021 13:52
mpguerra added a commit that referenced this pull request May 19, 2023
mergify bot pushed a commit that referenced this pull request May 23, 2023
* ZIPs were updated to remove ambiguity, this was tracked in #1267.

* #2105 was fixed by #3039 and #2379 was closed by #3069

* #2230 was a duplicate of #2231 which was closed by #2511

* #3235 was obsoleted by #2156 which was fixed by #3505

* #1850 was fixed by #2944, #1851 was fixed by #2961 and #2902 was fixed by #2969

* We migrated to Rust 2021 edition in Jan 2022 with #3332

* #1631 was closed as not needed

* #338 was fixed by #3040 and #1162 was fixed by #3067

* #2079 was fixed by #2445

* #4794 was fixed by #6122

* #1678 stopped being an issue

* #3151 was fixed by #3934

* #3204 was closed as not needed

* #1213 was fixed by #4586

* #1774 was closed as not needed

* #4633 was closed as not needed

* Clarify behaviour of difficulty spacing

Co-authored-by: teor <teor@riseup.net>

* Update comment to reflect implemented behaviour

Co-authored-by: teor <teor@riseup.net>

* Update comment to reflect implemented behaviour when retrying block downloads

Co-authored-by: teor <teor@riseup.net>

* Update `TODO` to remove closed issue and clarify when we might want to fix

Co-authored-by: teor <teor@riseup.net>

* Update `TODO` to remove closed issue and clarify what we might want to change in future

Co-authored-by: teor <teor@riseup.net>

* Clarify benefits of how we do block verification

Co-authored-by: teor <teor@riseup.net>

* Fix rustfmt errors

---------

Co-authored-by: teor <teor@riseup.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rust Area: Updates to Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Import and test against Sinsemilla test vectors from zcash-hackworks
7 participants