-
Notifications
You must be signed in to change notification settings - Fork 172
[ZIP 216] Require Canonical Jubjub Point Encodings #442
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fd63a49
ZIP 216: Main draft
str4d acf88b8
ZIP 216: Rename to only apply to Jubjub points
str4d c4a8630
ZIP 216: Fix references
str4d 5a92818
Apply suggestions from code review
daira 6502643
* Don't imply that the non-canonical encoding of (0, -1) is not a pro…
daira afc3ae4
edithtml.sh: fix to links of the form "foo.rst#anchor".
daira faf27e2
ZIP 216: generate HTML and update index.
daira File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,122 @@ | ||
| :: | ||
|
|
||
| ZIP: 216 | ||
| Title: Require Canonical Point Encodings | ||
| Owners: Daira Hopwood <daira@electriccoin.co> | ||
| Status: Reserved | ||
| Title: Require Canonical Jubjub Point Encodings | ||
| Owners: Jack Grigg <jack@electriccoin.co> | ||
| Daira Hopwood <daira@electriccoin.co> | ||
| Status: Draft | ||
| Category: Consensus | ||
| Created: 2021-02-11 | ||
| License: BSD-2-Clause | ||
| Discussions-To: <https://github.com/zcash/zips/issues/400> | ||
|
|
||
|
|
||
| Terminology | ||
| =========== | ||
|
|
||
| The key words "MUST" and "MUST NOT" in this document is to be interpreted as described | ||
| in RFC 2119. [#RFC2119]_ | ||
|
|
||
|
|
||
| Abstract | ||
| ======== | ||
|
|
||
| This ZIP fixes an oversight in the implementation of the Sapling consensus rules, by | ||
| correctly rejecting all non-canonical representations of Jubjub points. | ||
|
|
||
|
|
||
| Motivation | ||
| ========== | ||
|
|
||
| The Sapling specification was written with the intent that all values, including Jubjub | ||
| points, are strongly-typed with canonical representations. [#protocol-jubjub]_ This has | ||
daira marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| significant advantages for security analysis, because it allows the protocol to be | ||
| modelled with just the abstract types. | ||
|
|
||
| The intention of the Jubjub implementation (both in the `jubjub` crate [#jubjub-crate]_ | ||
| and its prior implementations) was to ensure that only canonical point encodings would be | ||
| accepted by the decoding logic. However, an oversight in the implementation allowed an | ||
| edge case to slip through: for each point on the curve where the $u$ coordinate is zero, | ||
daira marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| there are two encodings that will be accepted: | ||
|
|
||
| ```rust | ||
| // Fix the sign of `u` if necessary | ||
| let flip_sign = Choice::from((u.to_bytes()[0] ^ sign) & 1); | ||
| let u_negated = -u; | ||
| let final_u = Fq::conditional_select(&u, &u_negated, flip_sign); | ||
| ``` | ||
|
|
||
| This code accepts either sign bit, because `u_negated == u`. | ||
|
|
||
| There are two such points on the Jubjub curve: | ||
daira marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - `(0, -1)`, which is a point of order two, and thus rejected by the implementation | ||
| anywhere that a prime-order subgroup point is specified. | ||
| - `(0, 1)`, which is the identity, and thus is an element of the prime-order subgroup. | ||
|
|
||
| The non-canonical identity creates a consensus issue because unlike other non-canonical | ||
| points that are rejected, a non-canonical identity that is decoded and then encoded, does | ||
| not produce the original encoding. For example, if a non-canonical encoding appeared in a | ||
| transaction field, then node implementations that store points internally as abstract | ||
| curve points, and used those to derive transaction IDs, would derive different IDs than | ||
| nodes which store transactions as bytes (such as `zcashd`). | ||
daira marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| Specification | ||
| ============= | ||
|
|
||
| TODO: Define a non-canonical Jubjub point encoding. | ||
|
|
||
| When this ZIP activates, all places within the Sapling consensus protocol where Jubjub | ||
| points occur MUST reject non-canonical Jubjub point encodings. | ||
daira marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - Sapling addresses: | ||
| - `pk_d` | ||
daira marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - Sapling Spend description: | ||
| - `cv` | ||
| - `rk` | ||
| - The `R` component of the `spendAuthSig` RedDSA signature. | ||
| - Sapling Output description: | ||
| - `cv` | ||
| - `ephemeralKey` | ||
| - The `R` component of the `bindingSigSapling` RedDSA signature. | ||
|
|
||
daira marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Rationale | ||
| ========= | ||
|
|
||
| Zcash previously had a similar issue with non-canonical representations of points in | ||
| Ed25519 public keys and signatures. In that case, given the prevalence of Ed25519 | ||
| signatures in the wider ecosystem, the decision was made in ZIP 215 [#zip-0215]_ (which | ||
| activated with the Canopy network upgrade [#zip-0251]_) to allow non-canonical | ||
| representations of points. | ||
|
|
||
| Here, we are motivated instead to reject these non-canonical points: | ||
daira marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - The chance of the identity occuring anywhere within Sapling transactions from | ||
| implementations following the standard protocol is cryptographically negligible. | ||
daira marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - This re-enables the aforementioned simpler security analysis of the Sapling protocol. | ||
| - The Jubjub curve has a vastly-smaller scope of usage than Curve25519. | ||
daira marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| Security and Privacy Considerations | ||
| =================================== | ||
|
|
||
| This ZIP eliminates a potential source of consensus divergence between differing full node | ||
| implementations. At the time of writing (February 2021), no such divergence exists for any | ||
| production implementation of Zcash, but the alpha-stage `zebrad` node implementation would | ||
| be susceptible to this issue. | ||
|
|
||
|
|
||
| Deployment | ||
| ========== | ||
|
|
||
| TBD | ||
daira marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| References | ||
| ========== | ||
|
|
||
| .. [#RFC2119] `RFC 2119: Key words for use in RFCs to Indicate Requirement Levels <https://www.rfc-editor.org/rfc/rfc2119.html>`_ | ||
| .. [#protocol-jubjub] `Zcash Protocol Specification, Version 2020.1.15. Section 5.4.8.3: Jubjub <protocol/protocol.pdf#jubjub>`_ | ||
| .. [#jubjub-crate] `jubjub <https://crates.io/crates/jubjub>`_ | ||
daira marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| .. [#zip-0215] `ZIP 215: Explicitly Defining and Modifying Ed25519 Validation Rules <zip-0215.rst>`_ | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.