compressEcPublicKey

Compresses an EC public key point to SEC1 compressed form (0x02/0x03 || x), as required by the multicodec table for secp256k1-pub, p256-pub, p384-pub and p521-pub.

Accepts either an uncompressed point (0x04 || x || y) or an already-compressed point (returned unchanged).

Throws

if algorithm is not a supported EC curve or point is not a valid SEC1 encoding