We have a backup format for secret (sub)keys sk_keyID.gpg which is generated when you create a key on a smart card and choose to make a backup of the encryption key.
Now we want to add a card action in Kleopatras smart card window (could maybe be named "Generate Keys using Backup"). It should only be executed on an empty smart card and in the end there should be as many subkeys as are generated by the "Generate New Keys" action (3).
These are the steps you have to do on the command line for restoring the encryption key backup to a new smart card (in GPD 5.0.2):
gpg/card> generate --algo=brainpoolP256r1 OPENPGP.1 # create signing key
gpg --full-gen-key # create public key for the signing key
(14) Existing key from card
gpg --edit-key NAME # given in last step
gpg> bkuptocard /path/sk-backupdatei.gpg # copy encrypt key to card
(2) Encryption key
gpg> addkey # add encryption key zu public key
(14) Existing key from card
(2) F431A26E54E99AC04E8BEABED9701A955B93E382 OPENPGP.2 brainpoolP256r1 (encr*)
saveOr, if you have generated keys for all key slots in the first step (like in "Generate New Keys"):
gpg --edit-key NAME key 2 # select encryption key delkey # delete the encrypt key, because otherwise the pubkey has a no longer existing key listed after the next step bkuptocard … # copy encrypt key to card (2) Encryption key addkey # add encryption key zu public key (14) Existing key from card (2) F431A26E54E99AC04E8BEABED9701A955B93E382 OPENPGP.2 brainpoolP256r1 (encr*) save