I'm communicating to you using Bitcointalk aren't I? Why would you think that two people communicating with each other is impossible given the fact that we are communicating with each other right now?
It was the Bitcointalk forum that inspired us to create Bitcointalksearch.org - Bitcointalk is an excellent site that should be the default page for anybody dealing in cryptocurrency, since it is a virtual gold-mine of data. However, our experience and user feedback led us create our site; Bitcointalk's search is slow, and difficult to get the results you need, because you need to log in first to find anything useful - furthermore, there are rate limiters for their search functionality.
The aim of our project is to create a faster website that yields more results and faster without having to create an account and eliminate the need to log in - your personal data, therefore, will never be in jeopardy since we are not asking for any of your data and you don't need to provide them to use our site with all of its capabilities.
We created this website with the sole purpose of users being able to search quickly and efficiently in the field of cryptocurrency so they will have access to the latest and most accurate information and thereby assisting the crypto-community at large.
Ciphertext encrypted_utxo = encrypt_utxo_amount(context, utxo_amount, public_key, encryptor);
string serialized_utxo = serialize_encrypted_utxo(encrypted_utxo);
Ciphertext aggregated_utxos = aggregate_utxos({encrypted_utxo1, encrypted_utxo2}, evaluator);
bool meets_threshold = check_threshold(context, aggregated_utxos, threshold, decryptor, encoder);
#include
#include "seal/seal.h"
using namespace std;
using namespace seal;
// setup the encryption context
shared_ptrsetup_context() {
EncryptionParameters parms(scheme_type::ckks);
size_t poly_modulus_degree = 8192;
parms.set_poly_modulus_degree(poly_modulus_degree);
parms.set_coeff_modulus(CoeffModulus::Create(poly_modulus_degree, { 60, 40, 40, 60 }));
auto context = SEALContext::Create(parms);
return context;
}
// encrypt a UTXO amount
Ciphertext encrypt_utxo_amount(shared_ptrcontext, double amount, PublicKey public_key, Encryptor& encryptor) {
CKKSEncoder encoder(context);
Plaintext plain;
double scale = pow(2.0, 40);
vectorinput{ amount };
encoder.encode(input, scale, plain);
Ciphertext encrypted;
encryptor.encrypt(plain, encrypted);
return encrypted;
}
// serialize a ciphertext (for sharing or storage)
string serialize_encrypted_utxo(const Ciphertext& encrypted) {
stringstream ss;
encrypted.save(ss);
return ss.str();
}
// deserialize a ciphertext
Ciphertext deserialize_encrypted_utxo(shared_ptrcontext, const string& data) {
stringstream ss(data);
Ciphertext encrypted(context);
encrypted.load(context, ss);
return encrypted;
}
// aggregate encrypted UTXOs
Ciphertext aggregate_utxos(const vector& utxos, Evaluator& evaluator) {
Ciphertext aggregated = utxos[0];
for (size_t i = 1; i < utxos.size(); ++i) {
evaluator.add_inplace(aggregated, utxos[i]);
}
return aggregated;
}
// check if aggregated UTXOs meet the threshold
bool check_threshold(shared_ptrcontext, const Ciphertext& aggregated, double threshold, Decryptor& decryptor, CKKSEncoder& encoder) {
// Subtract the threshold homomorphically
Plaintext plain_threshold;
encoder.encode(vector{threshold}, aggregated.scale(), plain_threshold);
Ciphertext encrypted_threshold;
Encryptor encryptor(context, decryptor.public_key());
encryptor.encrypt(plain_threshold, encrypted_threshold);
Ciphertext result;
Evaluator evaluator(context);
evaluator.sub(aggregated, encrypted_threshold, result);
// Decrypt
Plaintext result_plain;
decryptor.decrypt(result, result_plain);
vectorresult_vector;
encoder.decode(result_plain, result_vector);
return result_vector[0] >= 0;
}
int main() {
auto context = setup_context();
KeyGenerator keygen(context);
PublicKey public_key = keygen.public_key();
SecretKey secret_key = keygen.secret_key();
Encryptor encryptor(context, public_key);
Decryptor decryptor(context, secret_key);
CKKSEncoder encoder(context);
Ciphertext encrypted_utxo1 = encrypt_utxo_amount(context, 2.5, public_key, encryptor);
Ciphertext encrypted_utxo2 = encrypt_utxo_amount(context, 1.7, public_key, encryptor);
vectorutxos{ encrypted_utxo1, encrypted_utxo2 };
Ciphertext aggregated = aggregate_utxos(utxos, Evaluator(context));
bool meets_threshold = check_threshold(context, aggregated, 4.0, decryptor, encoder);
cout << "Aggregated UTXOs meet threshold: " << (meets_threshold ? "true" : "false") << endl;
return 0;
}