Score:1

Can I store a public key used to verify a Schnorr signature in PEM format?

ke flag

I want to ask if there is any way to store a Schnorr signature key in PEM format, or any other standardized format.

And, if possible, I would like to know if that's possible to be done in C language; here's my code so far:

EC_KEY *key = EC_KEY_new();
EC_KEY_set_group(*key, group);
EC_KEY_set_private_key(*key, *a);
EC_KEY_set_public_key(*key, *Q);
...
FILE* fout2 = fopen("pub.key", "wb");
PEM_write_EC_PUBKEY(fout2, Key);
fclose(fout2);

which generates the following public key in PEM format:

-----BEGIN PUBLIC KEY-----
MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAE6F0upHIXEB8DIEYIBOt+Ps/m3GErnhWy
D35+HMDogZhgrQ0r3Bs4Dm0lIgTKYUU/Mg997FStJx4IrmNqeH5zwQ==
-----END PUBLIC KEY-----

I tried to implement a way of storing Schnorr keys using the EC_KEY structure from openssl. I would like to know if there is any other way or if what i did is correct. Thanks :)

Maarten Bodewes avatar
in flag
It looks to me that Schnorr uses the exact same key generation as the related ECDSA. As your key is encoded as bog standard [X.509 EC public key](https://lapo.it/asn1js/#MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAE6F0upHIXEB8DIEYIBOt-Ps_m3GErnhWyD35-HMDogZhgrQ0r3Bs4Dm0lIgTKYUU_Mg997FStJx4IrmNqeH5zwQ) using the named secp256k1 Koblitz curve, I would assume that this is correct.
Maarten Bodewes avatar
in flag
PS Didn't answer because I didn't do any practical work with Schnorr sigs. Please always [edit] additional info into questions instead of posting a hard to read comment.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.