0
$\begingroup$

I am interested in representing p = 2^255 - 19 in the Ed255519 curve as hexadecimal byte representation.

When I was looking through the original NaCL source code written by DJB, I saw a code fragment that says:

static const unsigned int minusp[32] = {
 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128
} ;

Am I safe to assume that this is the 32 byte integer representation of p = 2^255 - 19 and all I need to do is translate the 32 byte integers into 32 byte hexadecimal string representation ?

How should I represent the p for Ed25519 in hexadecimal string ?

$\endgroup$
1
$\begingroup$

The constant is named minusp, thus it's $-p \pmod {2^{256}}$, or $2^{255} + 19$, encoded in little-endian.

Assuming you want the hex string in big-endian, which is the way numbers are usually written, you get:

$p = 2^{255}-19$ = 7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFED

$2^{256} - p = 2^{255}+19$ = 8000000000000000000000000000000000000000000000000000000000000013

|improve this answer|||||
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.