Queries on Encrypted Data Library

Encrypt has three steps: Initialize HVE, Populate HVE, and run QED_Encrypt.
An example is presented at the end

  1. Initialize HVE:

    To initialize an HVE for the encryption function, simply call HVE_Init_Ciphertext with the Public Key. This can be done only after the Setup has been ran, and a Public Key has been generated;
    int HVE_Init_Ciphertext(
    		HVE_t *HVE, 
    		QEDPublicKey_t *PubKey);
    

  2. Populate HVE:

    Please refer to the subsection on Populating the HVE.


  3. Run QED_Encrypt:

    QED_Encrypt will take in the Public Key, the HVE and the context, and populate the CipherText and the MessageKey.

    int QED_Encrypt(
           	 	QEDEncryption_t *C,   
            	QEDMessageKey_t *M,   
            	QEDPublicKey_t *PubKey,
            	HVE_t *HVE,
            	QED_CTX *c);
    
    


    The QEDMessageKey_t M now contains an unsigned character string key_blob. This can be used to generate a symmetric key and encrypt the plaintext. For more information on this please see QED Internals.



Example

This example builds on top of the example started in the setup section.

First, declare a context, a cipher text, a message key, a public key and an HVE variable.

        QED_CTX c;
        QEDEncryption_t Cipher;
        QEDPublicKey_t PubKey;
	QEDMessageKey_t MsgKey;
        HVE_t HVE;


Second, initialize the context variable to use TYPE1 algorithm.
        QED_Init(&c, TYPE1);


Third, obtain the public key.


Fourth, initialize the HVE with the Public Key.
        HVE_Init_Ciphertext(&HVE, &PubKey);


Fifth, populate the HVE with appropriate data.

Finally, generate the ciphertext for the above HVE and message key.
        QED_Encrypt(&Cipher, &MsgKey, &PrivKey, &HVE, &c);