Skip to content

group: ge(j) should have as invariant that the curve equation holds #1376

Open
@real-or-random

Description

@real-or-random

I was surprised to see that this may be violated in secp256k1_eckey_pubkey_parse:

secp256k1_ge_set_xy(elem, &x, &y);
if ((pub[0] == SECP256K1_TAG_PUBKEY_HYBRID_EVEN || pub[0] == SECP256K1_TAG_PUBKEY_HYBRID_ODD) &&
secp256k1_fe_is_odd(&y) != (pub[0] == SECP256K1_TAG_PUBKEY_HYBRID_ODD)) {
return 0;
}
return secp256k1_ge_is_valid_var(elem);

I claim

  • ge(j) objects should always represent valid points on the curve.
  • This invariant should be checked in VERIFY mode, in secp256k1_ge(j)_verify or at least in secp256k1_ge_set_xy
  • There should be a separate function secp256k1_ge_try_set_xy which checks if (x,y) is on the curve, and only if yes, returns 1 and outputs a ge. That function can be used to implement secp256k1_eckey_pubkey_parse.
  • secp256k1_ge_is_valid_var should be removed (or repurposed to secp256k1_ge_verify_on_curve_var without return value, as mentioned above).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions