OpenCryptoProject / JCMathLib

Implementation of mathematical operations with big numbers and elliptic curve points for smart cards with JavaCard platform.
MIT License
85 stars 29 forks source link

Can't get add JCMathLib to work with two ECPoints #25

Open JFBB opened 2 years ago

JFBB commented 2 years ago

Hello, I downloaded the latest version of JCMathLib and got the below errors. I then downloaded the latest release (JCMathLib 1.1.0) and got the same result.

I need to be able to add two public keys (BrainpoolP256R1) and read the result. Can you help, please?

        ECConfig ecc = new ECConfig((short)256);
        ECCurve curve = new ECCurve(false, SecP256r1.p, SecP256r1.a, SecP256r1.b, SecP256r1.G, SecP256r1.r);
        ECPoint point1 = new ECPoint(curve, ecc.ech);
        ECPoint point2 = new ECPoint(curve, ecc.ech);
        point1.randomize(); 
        point2.randomize(); 
        point1.add(point2);

This gave a Crypto error.

I also tried

        ECConfig ecc = new ECConfig((short)256);
        ECCurve curve = new ECCurve(
                false,
                Brainpool256R1.getFp(),
                Brainpool256R1.getA(),
                Brainpool256R1.getB(),
                Brainpool256R1.getG(),
                Brainpool256R1.getR()
                );
        ECPoint point1 = new ECPoint(curve, ecc.ech);
        ECPoint point2 = new ECPoint(curve, ecc.ech);
        point1.setW(cryptoBuf, (short)0, hashLen);
        point2.setW(CA, (short)0, (short)CA.length);
        point1.add(point2);

This gave the same error.

dufkan commented 1 year ago

Hi, on which card are you trying to use JCMathLib? Is it one of the cards on which JCMathLib has been tested? I would recommend using the new version of the library, Release 2.0., which extended its support to more cards.