I am working on following scenario:
- Generate private and public key
Generate compressed public key with:
PublicKey.AccessGroupParameters().SetPointCompression(true)
Sign some data and send to other end with compressed public key.
[At other end] verify signature using public key
For step 4, I need recover y value. Is there some API I can use among Crypto++?
During verification, you will load the persisted or serialized key after setting point compression to
true
.Below is a little program to experiment with point compression. You can find it on the Crypto++ wiki under Point Compression.
It generates a random key, then creates two public key - one with and and without compression. They two public keys are serialized. Then, it loads two new public keys with the serialized values.
Key 1 (no compress) and Key 2 (compress) and saved, then Key 3 (no compress) and Key 4 (no compress) are loaded from saved values. The keys are the same, and the output is:
Here's the program to create, copy, save, load, compress, uncompress and serialize the keys and points.
You can even cross wires when loading the serialized keys and it just works. Below, the compressed key was loaded from a non-compressed serialization (and vice-versa):
If you want to get at the underlying domain parameters (like the base point), use: