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

crypto/ed25519: add edge case tests #40478

FiloSottile opened this issue Jul 29, 2020 · 2 comments

crypto/ed25519: add edge case tests #40478

FiloSottile opened this issue Jul 29, 2020 · 2 comments


Copy link

@FiloSottile FiloSottile commented Jul 29, 2020

We'll want to add tests for the edge cases that led to #40475.

Ideally, they would go into Wycheproof and run from there, making sure they run against all architectures.

/cc @hdevalence @katiehockman

@cagedmantis cagedmantis added this to the Backlog milestone Jul 29, 2020
Copy link

@hdevalence hdevalence commented Jul 30, 2020 is a fork of crypto/ed25519 with a VerifyConsensus method implementing the ZIP215 validation rules described in that repo. (Please forgive my Go, I don't write it regularly).

Relevant to this issue, the zip215_test.go file in that repo has a list of 196 = 14^2 test vectors consisting of purported (public key, signature) pairs on the message b"Zcash". These are constructed by taking pairs from a list of 14 encodings of low-order points, 8 of which are canonically encoded and 6 of which are non-canonically encoded.

The difference between (my interpretation of) RFC 8032 and the current Go behaviour can be visualized as follows:

RFC 8032 (as interpreted) Go crypto/ed25519
rfc8032 go-crypto-ed25519

On the left, the dark shade indicates MUST-reject (according to RFC 8032, which was written after this implementation and is incompatible with it), medium indicates MAY-accept, light indicates MUST-accept. (RFC 8032 does not require implementations to agree on whether signatures are valid). On the right, dark and light indicate rejected and accepted, respectively.

Note that all of these test cases require carefully crafted public keys. Therefore, there's no security issue with the signatures themselves, because an attacker who can control the public key can sign any message whatsoever. The problem is just the inconsistency, which could allow, e.g., a malicious party to inject faults into a consensus algorithm and cause consensus divergence.

Copy link
Member Author

@FiloSottile FiloSottile commented Oct 5, 2020

There's more context in @hdevalence's article here:

Indeed, since there is no security risk we probably should not change the behavior now and risk forking some blockchains. We'll add test cases and a paragraph to the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.