public static DiscoveryRequest CreateDiscoveryRequest(IList <string> addressBook, Dictionary <string, RemoteAttestation> remoteAttestations)
        {
            byte[] queryDataKey = Util.GetSecretBytes(32);
            byte[] queryData    = BuildQueryData(addressBook);
            AesCipher.AesEncryptedResult encryptedQueryData = AesCipher.Encrypt(queryDataKey, null, queryData);
            byte[] commitment = CryptoUtil.Sha256(queryData);
            Dictionary <string, QueryEnvelope> envelopes = new Dictionary <string, QueryEnvelope>(remoteAttestations.Count);

            foreach (var entry in remoteAttestations)
            {
                envelopes.Add(entry.Key,
                              BuildQueryEnvelope(entry.Value.RequestId, entry.Value.Keys.ClientKey, queryDataKey));
            }

            return(new DiscoveryRequest(addressBook.Count,
                                        commitment,
                                        encryptedQueryData.iv,
                                        encryptedQueryData.data,
                                        encryptedQueryData.mac,
                                        envelopes));
        }
 private static QueryEnvelope BuildQueryEnvelope(byte[] requestId, byte[] clientKey, byte[] queryDataKey)
 {
     AesCipher.AesEncryptedResult result = AesCipher.Encrypt(clientKey, requestId, queryDataKey);
     return(new QueryEnvelope(requestId, result.iv, result.data, result.mac));
 }