Now you need to register the users who will encrypt data.
In order to encrypt a data each user must have his own tools, which allow him to perform cryptographic operations, and these tools must contain the necessary information to identify users. In Virgil Security, these tools are the Virgil Key and the Virgil Card.
When we have already set up the Virgil SDK on the server & client sides, we can finally create Virgil Cards for the users and transmit the Cards to your Server for further publication on Virgil Services.
Generate Keys and Create Virgil Card
Use the Virgil SDK on the client side to generate a new Key Pair, and then create a user's Virgil Card using the recently generated Virgil Key. All keys are generated and stored on the client side.
In this example, we will pass on the user's username and a password, which will lock in their private encryption key. Each Virgil Card is signed by a user's Virgil Key, which guarantees the Virgil Card's content integrity over its life cycle.
// generate a new Virgil Key
VSSVirgilKey *aliceKey = [virgil.keys generateKey];
// save the Virgil Key into storage
// create identity for Alice
VSSUserIdentity *aliceIdentity = [virgil.identities
// create a Virgil Card
VSSVirgilCard *aliceCard = [virgil.cards
createCardWithIdentity:aliceIdentity ownerKey:aliceKey error:nil];
Virgil doesn't keep a copy of your Virgil Key. If you lose a Virgil Key, there is no way to recover it.
It should be noted that recently created user Virgil Cards will be visible only for application users because they are related to the Application.
Read more about Virgil Cards and their types here.
Transmit the Cards to Your Server
Next, you must serialize and transmit this Card to your server, where you will Approve & Publish Users' Cards.
// export a Virgil Card to string
NSString *exportedCard = [aliceCard exportData];
// transmit the Virgil Card to the server
Use the approve & publish users guide to publish user's Virgil Card on Virgil Services.