I am wondering how the precomputed table for scalar multiplication for elliptic curve (in my case 25519) is generated/precomputed?

I am talking about this [https://github.com/WhisperSystems/libsignal-protocol-javascript/blob/master/native/ed25519/base.h

The piece of code which uses this header file is:

/* base[i][j] = (j+1)*256^i*B */
/*static const ge_precomp base[32][8] = {
#include "base.h"
} ;*/

ge_precomp is defined as

ge_precomp (Duif): (y+x,y-x,2dxy)

Is there a paper or a piece of code where I can see how this table is generated? I am not trying to learn more about elliptic curves, I simply want to precompute this myself because of the specifics of my project.

I guess I would have to add point B to itself for (j+1)*256^i mod p times for each i and j. Is there a less compute intensive way to do this on an e.g. Raspberry Pi?

Thanks in advance!


1 Answer 1


CodesInChaos created an exact gist in C# for this: https://gist.github.com/CodesInChaos/ef914909941ce7caf514

It worked for me, took around 8 seconds on a 48MHz 32bit device, but either way, works. My C port can be found here https://gist.github.com/irfansehic/9c0b204845370f372bdfccfb66ec5942


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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