Now you need to register the users who will participate in encrypted communications.
In order to sign and encrypt a message 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
aliceKey, err := api.Keys.Generate()
// save the Virgil Key into storage
err = aliceKey.Save("[KEY_NAME]", "[KEY_PASSWORD]")
// create a Virgil Card
aliceCard, err := api.Cards.Create("alice", aliceKey, nil/* custom fields */)
Virgil doesn't keep a copy of your Virgil Key. If you lose a Virgil Key, there is no way to recover it.
In order for the Sender to be able to send a message, we also need a Virgil Card associated with the Recipient. 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 these Cards to your server, where you will Approve & Publish Users' Cards.
// export a Virgil Card to string
exportedCard, err := aliceCard.Export()
// transmit the Virgil Card to the server
Use the approve & publish users guide to publish users Virgil Cards on Virgil Services.