-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP #15: Add tests for comparisons and the ternary operator
Co-authored-by: Dimitris Mouris <[email protected]>
- Loading branch information
Showing
21 changed files
with
312 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/main/java/org/twc/terminator/t2dsl_compiler/configs/helib-bfv-cmp-int-128.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
unsigned long p = 19, m = 16109, r = 1, bits = 250; | ||
unsigned long c = 2; | ||
Context context = helib::ContextBuilder<helib::BGV>() | ||
.m(m).p(p).r(r).bits(bits).c(c).build(); | ||
SecKey secret_key(context); | ||
secret_key.GenSecKey(); | ||
addSome1DMatrices(secret_key); | ||
PubKey& public_key = secret_key; | ||
const EncryptedArray& ea = context.getEA(); | ||
long slots = ea.size(); | ||
|
||
Ptxt<helib::BGV> tmp(context); | ||
Ctxt scratch(public_key); | ||
|
||
Ctxt tmp_(public_key); |
15 changes: 15 additions & 0 deletions
15
src/main/java/org/twc/terminator/t2dsl_compiler/configs/helib-bfv-cmp-int-insecure.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
unsigned long p = 19, m = 4097, r = 1, bits = 500; | ||
unsigned long c = 2; | ||
Context context = helib::ContextBuilder<helib::BGV>() | ||
.m(m).p(p).r(r).bits(bits).c(c).build(); | ||
SecKey secret_key(context); | ||
secret_key.GenSecKey(); | ||
addSome1DMatrices(secret_key); | ||
PubKey& public_key = secret_key; | ||
const EncryptedArray& ea = context.getEA(); | ||
long slots = ea.size(); | ||
|
||
Ptxt<helib::BGV> tmp(context); | ||
Ctxt scratch(public_key); | ||
|
||
Ctxt tmp_(public_key); |
19 changes: 19 additions & 0 deletions
19
src/main/java/org/twc/terminator/t2dsl_compiler/configs/lattigo-128-more-levels.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
paramDef := bfv.PN15QP880 | ||
paramDef.T = 0x3ee0001 | ||
params, err := bfv.NewParametersFromLiteral(paramDef) | ||
slots := 2048 | ||
if err != nil { | ||
panic(err) | ||
} | ||
encoder := bfv.NewEncoder(params) | ||
kgen := bfv.NewKeyGenerator(params) | ||
clientSk, clientPk := kgen.GenKeyPair() | ||
encryptorPk := bfv.NewEncryptor(params, clientPk) | ||
encryptorSk := bfv.NewEncryptor(params, clientSk) | ||
decryptor := bfv.NewDecryptor(params, clientSk) | ||
rlk := kgen.GenRelinearizationKey(clientSk, 1) | ||
evaluator := bfv.NewEvaluator(params, rlwe.EvaluationKey{Rlk: rlk}) | ||
funits.FunitsInit(&encryptorPk, &encoder, &evaluator, ¶ms, int(paramDef.T), slots, word_sz) | ||
ptxt := bfv.NewPlaintext(params) | ||
tmp := make([]int64, slots) | ||
encoder.EncodeInt(tmp, ptxt) |
28 changes: 28 additions & 0 deletions
28
src/main/java/org/twc/terminator/t2dsl_compiler/configs/lattigo_insecure_int_cmp.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
customParams := bfv.ParametersLiteral{ | ||
LogN: 7, | ||
T: 257, | ||
Q: []uint64{0x7ffffffffe70001, 0x7ffffffffe10001, 0x7ffffffffcc0001, // 59 + 59 + 59 bits | ||
0x400000000270001, 0x400000000350001, 0x400000000360001, // 58 + 58 + 58 bits | ||
0x3ffffffffc10001, 0x3ffffffffbe0001, 0x3ffffffffbd0001, // 58 + 58 + 58 bits | ||
0x4000000004d0001, 0x400000000570001, 0x400000000660001}, // 58 + 58 + 58 bits | ||
P: []uint64{0x7ffffffffb4001}, | ||
Sigma: rlwe.DefaultSigma, | ||
} | ||
paramDef := customParams | ||
params, err := bfv.NewParametersFromLiteral(paramDef) | ||
slots := 10 | ||
if err != nil { | ||
panic(err) | ||
} | ||
encoder := bfv.NewEncoder(params) | ||
kgen := bfv.NewKeyGenerator(params) | ||
clientSk, clientPk := kgen.GenKeyPair() | ||
encryptorPk := bfv.NewEncryptor(params, clientPk) | ||
encryptorSk := bfv.NewEncryptor(params, clientSk) | ||
decryptor := bfv.NewDecryptor(params, clientSk) | ||
rlk := kgen.GenRelinearizationKey(clientSk, 1) | ||
evaluator := bfv.NewEvaluator(params, rlwe.EvaluationKey{Rlk: rlk}) | ||
funits.FunitsInit(&encryptorPk, &encoder, &evaluator, ¶ms, int(paramDef.T), slots, word_sz) | ||
ptxt := bfv.NewPlaintext(params) | ||
tmp := make([]int64, slots) | ||
encoder.EncodeInt(tmp, ptxt) |
17 changes: 17 additions & 0 deletions
17
src/main/java/org/twc/terminator/t2dsl_compiler/configs/palisade-bfv-depth-20-bin.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
uint32_t depth = 20; | ||
double sigma = 3.2; | ||
SecurityLevel securityLevel = HEStd_128_classic; | ||
size_t plaintext_modulus = 65537; | ||
CryptoContext<DCRTPoly> cc = CryptoContextFactory< | ||
DCRTPoly>::genCryptoContextBFVrns(plaintext_modulus, | ||
securityLevel, sigma, 0, depth, 0, OPTIMIZED, 2); | ||
cc->Enable(ENCRYPTION); | ||
cc->Enable(SHE); | ||
auto keyPair = cc->KeyGen(); | ||
cc->EvalMultKeyGen(keyPair.secretKey); | ||
size_t slots(cc->GetRingDimension()); | ||
vector<int64_t> tmp_vec_(slots); | ||
Plaintext tmp; | ||
vector<vector<int64_t>> tmp_bin_vec_(word_sz, vector<int64_t>(slots, 0)); | ||
vector<Ciphertext<DCRTPoly>> tmp_(word_sz); | ||
|
15 changes: 15 additions & 0 deletions
15
src/main/java/org/twc/terminator/t2dsl_compiler/configs/palisade-bfv-depth-20-int.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
uint32_t depth = 20; | ||
double sigma = 3.2; | ||
SecurityLevel securityLevel = HEStd_128_classic; | ||
size_t plaintext_modulus = 65537; | ||
CryptoContext<DCRTPoly> cc = CryptoContextFactory< | ||
DCRTPoly>::genCryptoContextBFVrns(plaintext_modulus, | ||
securityLevel, sigma, 0, depth, 0, OPTIMIZED, 2); | ||
cc->Enable(ENCRYPTION); | ||
cc->Enable(SHE); | ||
auto keyPair = cc->KeyGen(); | ||
cc->EvalMultKeyGen(keyPair.secretKey); | ||
size_t slots(cc->GetRingDimension()); | ||
vector<int64_t> tmp_vec_(slots); | ||
Plaintext tmp; | ||
Ciphertext<DCRTPoly> tmp_; |
21 changes: 21 additions & 0 deletions
21
...n/java/org/twc/terminator/t2dsl_compiler/configs/seal-bfv-bin-comparisons-insecure.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
size_t poly_modulus_degree = 1024; | ||
auto p_mod = PlainModulus::Batching(poly_modulus_degree, 20); | ||
size_t plaintext_modulus = (size_t) p_mod.value(); | ||
EncryptionParameters parms(scheme_type::bfv); | ||
parms.set_poly_modulus_degree(poly_modulus_degree); | ||
parms.set_coeff_modulus(CoeffModulus::Create(poly_modulus_degree, {50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50})); | ||
parms.set_plain_modulus(p_mod); | ||
SEALContext context(parms, true, sec_level_type::none); | ||
KeyGenerator keygen(context); | ||
SecretKey secret_key = keygen.secret_key(); | ||
PublicKey public_key; | ||
RelinKeys relin_keys; | ||
keygen.create_public_key(public_key); | ||
keygen.create_relin_keys(relin_keys); | ||
Encryptor encryptor(context, public_key); | ||
Evaluator evaluator(context); | ||
Decryptor decryptor(context, secret_key); | ||
BatchEncoder batch_encoder(context); | ||
size_t slots = poly_modulus_degree/2; | ||
Plaintext tmp; | ||
vector<Ciphertext> tmp_(word_sz); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
0 | ||
1 | ||
2 | ||
3 | ||
4 | ||
5 | ||
6 | ||
6 | ||
7 | ||
8 | ||
8 |
Oops, something went wrong.