Botan library and 'compressed' public keys

217 Views Asked by At

Does Botan support serialisation / deserialisation of a 'compressed' representation of an EC public key? (only X coordinate of the point on EC + sign). Any example?

1

There are 1 best solutions below

0
On

Yes. Botan compresses ECC points by default eg when serializing a public key to X.509 format. It accepts compressed or uncompressed points. Given an ECC point, you can convert it to an octet string in compressed form with

const PointGFp& pt = my_ecc_key.public_point(); secure_vector<uint8_t> uncompressed_point = EC2OSP(pt, PointGFp::UNCOMPRESSED); secure_vector<uint8_t> compressed_point = EC2OSP(pt, PointGFp::COMPRESSED);