publicKeyOnCurve

fun publicKeyOnCurve(signatureScheme: SignatureScheme, publicKey: PublicKey): Boolean

Check if a point's coordinates are on the expected curve to avoid certain types of ECC attacks. Point-at-infinity is not permitted as well. See Small subgroup and invalid-curve attacks for a more descriptive explanation on such attacks. We use this function on validatePublicKey, which is currently used for signature verification only. Thus, as these attacks are mostly not relevant to signature verification, we should note that we are doing it out of an abundance of caution and specifically to proactively protect developers against using these points as part of a DH key agreement or for use cases as yet unimagined. This method currently applies to BouncyCastle's ECDSA (both R1 and K1 curves) and JCA EdDSA (ed25519 curve).

Return

true if the point lies on the curve or false if it doesn't.

Parameters

publicKey

a PublicKey, usually used to validate a signer's public key in on the Curve.

signatureScheme

a SignatureScheme object, retrieved from supported signature schemes, see Crypto.

Throws

if the requested signature scheme or the key type is not supported.