When we multiply the basepoint of curve25519 with a scalar number, an exception is thrown.
Integer gx(group.GetSubgroupGenerator().x);
Integer gy(group.GetSubgroupGenerator().y);
ECP::Point g(gx, gy);
ECP::Point P(group.GetCurve().ScalarMultiply(g, 3));
Exception thrown at 0x005B4412 in CryptoExample.exe: 0xC0000005: Access violation reading location 0x00000000.
How can we take generator, other than basepoint in this curve?
group.GetCurve()is likely returningNULLbecause no curve has been set. But the curve25519 gear is probably not going to function correctly using the standard way of doing things (like shown at Scalar multiplication on secp521r1 using Crypto++). In fact, if you run the following code:Then the code will result in an exception because the domain parameters are missing in
eccrypto.handeccrypto.cpp:The curve25519 gear is special in Crypto++. Rather than using the library's underlying
Integerclass and typical field operations throughGroupParametersobject, it uses a constant time implementation from Andrew Moon called Donna. The library then wraps Moon's Donna code and provides most expected operation using Crypto++ objects likePK_SignerandPK_Verifier.However, "... and provides most expected operation" stops precisely at the lower-level objects like
DL_GroupParameters_EC, which is the interface you are trying to use.You might also want to take a look at the functions available in
donna.h:Those are the scalar multiplications you are looking for. The first
curve25519_multuses a basepoint of 9. The secondcurve25519_multallows you to specify an arbitrary basepoint.donna.hshould be a private header, but we had to expose it because of the missing curve operations. However, Donna is still missing functions forAddandDouble, though they could probably be exported if needed.And also see
x25519anded25519on the Crypto++ wiki; and Scalar multiplication on secp521r1 using Crypto++ on Stack Overflow.The
x25519anded25519wiki pages actually discuss your problem:The reason curve25519 is special is, we needed to provide the gear, but wanted to avoid a lot of changes required to properly support it. The library supports short Weierstrass curves well, but has nearly no support for Edwards and Twisted Edward curves.
Eventually curve25519 will be properly added to the library.