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 secp256k1_scalar_chacha20 in big endian mode. #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tecnovert
Copy link

No description provided.

@antiochp
Copy link
Member

Hi @tecnovert thanks for the PR!
Can you give some context on what's going on here?

@tecnovert
Copy link
Author

The modified code is reversing the scalar (bignum) results. secp256k1 scalars are big endian and the chacha20 code output is little endian.
They always need reversing regardless of the endianness of the underlying system, but on big endian systems BE32 is defined as a NOP. The fix is to use a new always defined SW32 macro.

The changes to configure.ac set WORDS_BIGENDIAN which wasn't defined anywhere.
The changes to .travis.yml add an extra test case on a big endian system (s390x).

Here is the log of a travis run with debugging messages without the fix (expand "$ cat ./tests.log"):
https://travis-ci.org/github/tecnovert/secp256k1/jobs/738789811

Notice result vs expected:

r1 ade0b876 903df1a0 e56a5d40 28bd8653b819d2bd1aed8da0ccef36a8c70d778b
e1 76b8e0ad a0f13d90 405d6ae5 5386bd28bdd219b8a08ded1aa836efcc8b770dc7

And after:
https://travis-ci.org/github/tecnovert/secp256k1/jobs/738794486

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

Successfully merging this pull request may close these issues.

2 participants