cryptimeleon / math

Library providing mathematical basics for (pairing-based) cryptography.
Apache License 2.0
10 stars 2 forks source link

Curve and subgroup checks #129

Open JanBobolz opened 2 years ago

JanBobolz commented 2 years ago

As noted here, our implementation of BN, secp256k1, and supersingular curves do not check the curve equation, nor do they check if the given element is in the right subgroup.

This needs to be fixed.

The curve check can go into the WeierstrassCurve interface and called in the AbstractEllipticCurvePoint class during deserialization.

The subgroup check should happen in PairingSourceGroupImpl. The current PairingSourceGroupImpl::isMember in there may be a bit wonky because it uses the pow() function, which may optimize the exponentiation by taking the exponent mod size(). So something like the dedicated PairingSourceGroupImpl::cofactorMultiplication() seens to be much better for this use case. It should be called in the PairingSourceGroupImpl::restoreElement() method (together with the check that the point is on the curve).