ricmoo / GMEllipticCurveCrypto

Elliptic Curve Cryptography library for iOS (ECDSA and ECDH)
BSD 2-Clause "Simplified" License
122 stars 46 forks source link

publicKeyXBase64 and publicKeyYBase64 are nil #31

Open deepesh-vasthimal-cko opened 4 years ago

deepesh-vasthimal-cko commented 4 years ago

Hi all ,

I am getting nil values when accessing publicKeyXBase64 and publicKeyYBase64 of the generateKeyPair. See below code example for reference.

only after I access publicKeyBase64 once I am able to then retrieve publicKeyXBase64 and publicKeyYBase64, Seems to be a bit weird is there a dependency between accessing publicKeyBase64 and generating publicKeyXBase64 and publicKeyYBase64 values ? . Please help and suggest.


        let testEC = GMEllipticCurveCrypto.generateKeyPair(for: GMEllipticCurveSecp256r1)
        testEC?.compressedPublicKey = false

        print(testEC?.publicKeyXBase64) // nil
        print(testEC?.publicKeyYBase64) // nil

        print(testEC?.privateKeyBase64) // Optional("A91MmkAlqO3CQYYUujwxpn0fSCH4vFX1bMcUgAQ7aB4=")
        let publicKeyBase64 = testEC?.publicKeyBase64 // only after accessing publicKeyBase64 once I get below x and y values

        print(testEC?.publicKeyXBase64) // Optional("GsKdKK0HUN8MhaNZtZwB3hdSOizpPlwkUF2h8uppiZQ=")
        print(testEC?.publicKeyYBase64) // Optional("RAq/+6/L7q/JqTO3QRO+Kft5xuku0dTKYE3gdDYvxOA=")

Thanks Deepesh