I'd like to create LSAG in C and now I need to calculate ciKi as element in L. Then, I try an example with MiniNero like below:

K = "210330a31c3caab4087c19fbe770514e5e6b80eda552d1e5f8becabd12c4540e"
c = "30837c72f9e0034f5669d5b122a200565666f6d31ba9a4c707ebfd0860303988"
print(MiniNero.scalarmultKey(K, c))

And I got the answer:


However, I got a different result with my C version...

from_hex(c, 32, "30837c72f9e0034f5669d5b122a200565666f6d31ba9a4c707ebfd0860303988");
from_hex(K, 32, "210330a31c3caab4087c19fbe770514e5e6b80eda552d1e5f8becabd12c4540e");

scalarmultKey((const unsigned char *) K, (const unsigned char *)c, (unsigned char *)result);

for(i=0; i<32; i++){

I got the result:


where the content of scalarmultKey is:

void scalarmultKey(const unsigned char *P, const unsigned char *a, unsigned char *aP)
    ge_p3 *A = malloc(sizeof(ge_p3));
    ge_p2 *R = malloc(sizeof(ge_p2));

    ge_frombytes_vartime(A, P);
    ge_scalarmult(R, a, A);
    ge_tobytes(aP, R);

Is there difference between scalarmultKeys in MiniNero with monero-project's.

Please help on this problem.. Many thanks!

  • 2
    210330a31c3caab4087c19fbe770514e5e6b80eda552d1e5f8becabd12c4540e is not a valid Ed25519 curve point, so you'd expect things to break. Only 50% of 256 bit sequences are valid curve points. Where did you get that hex from?
    – knaccc
    Apr 18, 2020 at 12:12
  • @knaccc Thanks for your reply! I got the hex from PaperWallet.skGen() in MiniNero If my memory serves me right... BTW, how can I verify them? Should I use sc_reduce32() first?
    – Mooooo
    Apr 18, 2020 at 13:17
  • 2
    skGen creates a secret key, which is a scalar and not a curve point. sc_reduce32 applies to scalars and not curve points. You want to use pkGen to generate a curve point.
    – knaccc
    Apr 18, 2020 at 19:05

1 Answer 1


As @knaccc astutely points out, your keys are not valid.

An example with valid test keys, in Python:

p = '644206dabcd3014180f120c0d3da7fc167701a310ca520467199fcefbd7e0109'
P = 'c2f9d63a7dbfb73fc24dae28df2ecf5b3667eff59124511fa6735ac848938cce'
print MiniNero.scalarmultKey(P, p)



And in C:

key r,p,P;
hex_to_pod("644206dabcd3014180f120c0d3da7fc167701a310ca520467199fcefbd7e0109", p);
hex_to_pod("c2f9d63a7dbfb73fc24dae28df2ecf5b3667eff59124511fa6735ac848938cce", P);
scalarmultKey(r, P, p);
for(int i=0; i<32; i++)
    printf("%02x", r[i]);

Outputs the same:


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.