Skip to content

Instantly share code, notes, and snippets.

Last active September 3, 2019 20:03
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
CryptoFractions encrypt_audio(vector<float> signal, int startIndex, int sampleSize, const char *keysFilePath, const long precision) {
vector<int64_t> intSignal;
CryptoFractions encryptedSignal;
int numerator;
int endIndex = startIndex + sampleSize;
for (int i = startIndex; i < endIndex; i += 1) {
numerator = int(signal[i] * precision);
int val;
EncryptionInfo info = read_encryption_info(keysFilePath);
Plaintext signalArray = info.cryptocontext->MakePackedPlaintext(encryptedSignal.numerators);
Plaintext ones = info.cryptocontext->MakePackedPlaintext(encryptedSignal.denominators);
Ciphertext<DCRTPoly> encSignal = info.cryptocontext->Encrypt(info.keypair.publicKey, signalArray);
// For now, the denominator will be 1. We keep track of the precision adjustments separately and deal with that once we are ready to decrypt the result
Ciphertext<DCRTPoly> encSignalDen = info.cryptocontext->Encrypt(info.keypair.publicKey, ones);
encryptedSignal.encryptedNumerators = encSignal;
encryptedSignal.encryptedDenominators = encSignalDen;
return encryptedSignal;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment