Skip to content

ECC key size for secp224k1 is not consistent with key size specification #200

Open
@Emill

Description

@Emill

The key size for secp224k1 is specified to be 225 bits:

* secp224k1 : ``key_bits = 225``

This does not follow the specification of the key size:

The size of an elliptic curve key is the bit size associated with the curve, that is, the bit size of :math:`q`` for a curve over a field :math:`\mathbb{F}_q`.

As seen at https://neuromancer.sk/std/secg/secp224k1, the bit size of the prime for this curve is 224. However, the bit size of the curve order is 225 and this is why the key size needs to be one bit bigger for private keys, since a private key for ECDH and ECDSA is a number between 1 and n-1, where n is the curve order. However for corresponding public keys, each coordinate is at most p and hence fits in 224 bits for secp224k1.

Note that the public key size is specified to the same as the private key:

The size of an elliptic curve public key is the same as the corresponding private key. See `PSA_KEY_TYPE_ECC_KEY_PAIR()` and the documentation of each elliptic curve family for details.

Not sure what the intention here is regarding secp224k1 if public key size should be 225 (with always one msb zero bit) or 224.

As a side note, it's even worse for Ed25519, where the private key is not a number between 1 and n-1 but is a 256 bit random bit string that is internally to be fed into a KDF per RFC 8032. Currently Edwards25519 keys are specified to have 255 key bits, which technically corresponds to the description for key size above since the bit size of the prime of the curve is 255, but does not match with what is used as private key for the EdDSA scheme (256 bits). And public keys are also 256 bits (not 255).

I'm not sure what the exact purpose of the "key size" attribute is. If it is to describe the actual size of a key (used when allocating buffer sizes etc.), it is apparently wrong, as seen above. If the intention is to rather specify the strength of the curve/algorithm (e.g. the size of the prime field of the curve, which can differ slightly from key sizes), then make that clear in the description and change secp224k1's "size" to 224. But in that case I'm not sure what the purpose of "public key size" would be. It anyway confuses me that the public key size is the size of only one coordinate, while typically the public key needs both coordinates.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Crypto APIIssue or PR related to the Cryptography APIFAQAn answered question, that might help others

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions