Skip to content

wNAF uses PrimeField::to_repr on scalars assuming little endian #78

Description

@tarcieri

Several places in wnaf.rs, PrimeField::to_repr is called on scalars assuming this outputs a little endian serialization. That method is documented as follows:

/// The endianness of the byte representation is implementation-specific. Generic
/// encodings of field elements should be treated as opaque.

We are using the big endian SEC1 serialization of scalars for our implementations of the NIST P-curves as well as secp256k1.

It would be nice to eliminate the endianness assumptions in the implementation. As a hack we added a secondary method which always provides a little endian serialization to PrimeField in rustcrypto-ff, but whatever can eliminate the endianness assumptions here would be nice. Perhaps something that constructs an Iterator over the bits of the scalar in little endian order would be generally useful?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions