I am using fido2 python package and I would like to know how to generate an EC pair (ES256)
public and private key.
and also how to sign a challenge using the private key
so it'll be possible to verify it with the public key
Thanks
The Web Authentication protocol (and FIDO2 CTAP2 protocol built on top of it) have a challenge/response protocol against a device representing authentication of the user called an Authenticator.
The fido2 python library is meant to be used to talk to the authenticator, not to emulate an authenticator itself. The role that talks to the authenticator is called a Relying Party.
Systems typically further divide the Relying Party role into client and server roles - the client communicates with the authenticator, but really it is relaying the communication to and from the server. In WebAuthn, the browser, the site javascript it is running, and any underlying platform support are all considered part of the client. If you have native code talking USB or NFC to an authenticator (on platforms which let you), that native code is considered an authenticator.
The underlying authentication challenge does not have a cryptographic signature from the relying party. Instead, the cryptographic signature is made by the authenticator - the authenticator generates a new key pair on registration, and then supplies a signature from that key to prove possession and thus prove authentication. Since fido2 does not have authenticator support, it has no need to generate key pairs (outside of potential test code).
Note that this gets to an essential of the underlying WebAuthn and FIDO2 platform trust model - the user must trust the client. For this reason, several platforms have locked out low-level access to authenticator hardware (USB, NFC and BLE communication to hardware) and instead provide system API. Native applications must have entitlements to operate on behalf of a particular web origin as a WebAuthn client, and browsers must request special entitlements from the platform in order to represent all web domains.
This does not affect usage of fido2 for implementing server functionality, but I'd advise you to double-check platform support if you plan to use it to implement any client functionality.
how to generate fido2.cose import ES256 fido2 key pairs