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

No tests for EdDSA.sol #117

Open
HarryR opened this issue Apr 8, 2019 · 0 comments
Open

No tests for EdDSA.sol #117

HarryR opened this issue Apr 8, 2019 · 0 comments

Comments

@HarryR
Copy link
Owner

HarryR commented Apr 8, 2019

The EdDSA.sol file doesn't have any tests for it, it also seems to be incompatible for the following reasons:

  • JubJub.Generator() is different compared to the one in jubjub.py
  • SHA256 is used, but none of the implementatitons (Python, C++) use SHA256 for EdDSA

The following code should produce valid signatures for the scheme in EdDSA.sol, but whenever I try testing in Remix it hangs the browser.

from ethsnarks.eddsa import _SignatureScheme, as_scalar
from hashlib import sha256

class SHA256EdDSA(_SignatureScheme):
    @classmethod
    def hash_public(cls, R, A, M):
        args = [R.x.n, R.y.n, A.x.n, A.y, M]
        msg = b''.join([int.to_bytes(_, 32, 'big') for _ in as_scalar(*args)])
        hashed_msg = sha256(msg).digest()
        return int.from_bytes(hashed_msg, 'big') & ((2<<249) - 1)


msg = 1234
k, A = SHA256EdDSA.random_keypair()
smsg = SHA256EdDSA.sign(1234, k)
SHA256EdDSA.verify(A, smsg.sig, msg)

args_for_contract = [A, msg, smsg.sig.R, smsg.sig.s]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant