From f18b7c2a5562e6763d0e11f8450fea9d619ed6fc Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 7 Apr 2022 12:08:52 +0200 Subject: [PATCH 01/42] remove redundant code --- new_scripts.py | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/new_scripts.py b/new_scripts.py index 84ffd46d8..7e3855e61 100644 --- a/new_scripts.py +++ b/new_scripts.py @@ -168,28 +168,6 @@ def generate_parameter_matrix(params_in, sd_range, target_security_levels=[128]) return results - -def test_it(): - - D = nd.NoiseDistribution.DiscreteGaussian - DEFAULT_PARAMETERS = LWE.Parameters(n=1024, q=2**64, Xs=D(0.50, -0.50), Xe=D(131072.00), m=oo, tag='TFHE_DEFAULT') - - - # x = estimate(params) - # y = get_security_level(x, 2) - # print(y) - #z1 = automated_param_select_n(schemes.TFHE630.updated(n=786), 128) - #print(z1) - sd_range = [1,4] - print("working...") - z3 = generate_parameter_matrix(DEFAULT_PARAMETERS, sd_range=[5, 6], target_security_levels=[128, 192, 256]) - # TODO: in this function call the initial guess for n is way off (security is ~60-bits instead of close to 128). - print(z3) - save(z3, "123.sobj") - - return z3 - - def generate_zama_curves64(sd_range=[2, 60], target_security_levels=[128, 192, 256]): D = ND.DiscreteGaussian @@ -198,5 +176,4 @@ def generate_zama_curves64(sd_range=[2, 60], target_security_levels=[128, 192, 2 return raw_data - generate_zama_curves64() \ No newline at end of file From d0efc71796b3f254fc8d79f1c20e37aa3d0ba691 Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 11 Apr 2022 15:11:03 +0100 Subject: [PATCH 02/42] allow for a single arg for AWS --- new_scripts.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/new_scripts.py b/new_scripts.py index 7e3855e61..4232c5066 100644 --- a/new_scripts.py +++ b/new_scripts.py @@ -2,6 +2,7 @@ from estimator_new import * from sage.all import oo, save from math import log2 + def old_models(security_level, sd, logq = 32): """ Use the old model as a starting point for the data gathering step @@ -142,7 +143,7 @@ def automated_param_select_n(params, target_security=128): return params -def generate_parameter_matrix(params_in, sd_range, target_security_levels=[128]): +def generate_parameter_matrix(params_in, sd_range, target_security_levels=[128], name="v0.sobj"): """ :param sd_range: a tuple (sd_min, sd_max) giving the values of sd for which to generate parameters :param params: the standard deviation of the LWE error @@ -164,16 +165,26 @@ def generate_parameter_matrix(params_in, sd_range, target_security_levels=[128]) Xe_new = nd.NoiseDistribution.DiscreteGaussian(2**sd) params_out = automated_param_select_n(params_in.updated(Xe=Xe_new), target_security=lam) results["{}".format(lam)].append((params_out.n, params_out.q, params_out.Xe.stddev)) + save(results, "{}.sobj".format(name)) return results -def generate_zama_curves64(sd_range=[2, 60], target_security_levels=[128, 192, 256]): +def generate_zama_curves64(sd_range=[2, 60], target_security_levels=[256], name="v0256.sobj"): D = ND.DiscreteGaussian init_params = LWE.Parameters(n=1024, q=2 ** 64, Xs=D(0.50, -0.50), Xe=D(131072.00), m=oo, tag='TFHE_DEFAULT') - raw_data = generate_parameter_matrix(init_params, sd_range=sd_range, target_security_levels=target_security_levels) + raw_data = generate_parameter_matrix(init_params, sd_range=sd_range, target_security_levels=target_security_levels, name=name) return raw_data -generate_zama_curves64() \ No newline at end of file +def plota_curve(raw_data, security_level): + + data = raw_data["{}".format(security_level)] + +import sys +a = int(sys.argv[1]) +print(a) + +generate_zama_curves64(target_security_levels=[a]) + From 5d4de0cd95fde3ad08917a4899fd03086431bf76 Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 11 Apr 2022 15:12:46 +0100 Subject: [PATCH 03/42] naming --- new_scripts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/new_scripts.py b/new_scripts.py index 4232c5066..f91b22b0b 100644 --- a/new_scripts.py +++ b/new_scripts.py @@ -186,5 +186,5 @@ import sys a = int(sys.argv[1]) print(a) -generate_zama_curves64(target_security_levels=[a]) +generate_zama_curves64(target_security_levels=[a], name="{}".format(a)) From 00691670655d0ab25c2d00f45884ea1de1a5a225 Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 11 Apr 2022 16:38:07 +0100 Subject: [PATCH 04/42] optimize --- new_scripts.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/new_scripts.py b/new_scripts.py index f91b22b0b..fdee04dea 100644 --- a/new_scripts.py +++ b/new_scripts.py @@ -122,12 +122,8 @@ def automated_param_select_n(params, target_security=128): # final estimate (we went too far in the above loop) if security_level < target_security: - # TODO: we should somehow keep the previous estimate stored so that we don't need to compute it twice - # if we do this we need to make sure that it works for both sides (i.e. if (i-1) is above or below the - # security level - + # we go back params = params.updated(n = params.n - z * 8) - costs = estimate(params) security_level = get_security_level(costs, 2) print("the finalised parameters are n = {}, log2(sd) = {}, log2(q) = {}, with a security level of {}-bits".format(params.n, From 468dcfc1f3b184da75fb61cf0f9625fe2bcca289 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 12 Apr 2022 13:33:37 +0100 Subject: [PATCH 05/42] add script to bypass mem issues --- job.sh | 4 ++++ 1 file changed, 4 insertions(+) create mode 100755 job.sh diff --git a/job.sh b/job.sh new file mode 100755 index 000000000..52a2a071a --- /dev/null +++ b/job.sh @@ -0,0 +1,4 @@ +#!/bin/sh +sage-python new_scripts.py 80 +sage-python new_scripts.py 128 +sage-python new_scripts.py 192 From 85f05ea6618482ed54a856354446352368814cde Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 12 Apr 2022 14:03:22 +0100 Subject: [PATCH 06/42] uypdates for aws --- new_scripts.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/new_scripts.py b/new_scripts.py index fdee04dea..c3a98ad50 100644 --- a/new_scripts.py +++ b/new_scripts.py @@ -1,6 +1,9 @@ +import gc + from estimator_new import * from sage.all import oo, save from math import log2 +import gc def old_models(security_level, sd, logq = 32): @@ -35,7 +38,6 @@ def old_models(security_level, sd, logq = 32): return round(n_est) - def estimate(params, red_cost_model = RC.BDGL16): """ Retrieve an estimate using the Lattice Estimator, for a given set of input parameters @@ -45,7 +47,6 @@ def estimate(params, red_cost_model = RC.BDGL16): est = LWE.estimate(params, deny_list=("arora-gb", "bkw"), red_cost_model=red_cost_model) return est - def get_security_level(est, dp = 2): """ Get the security level lambda from a Lattice Estimator output @@ -59,7 +60,6 @@ def get_security_level(est, dp = 2): security_level = round(log2(min(attack_costs)), dp) return security_level - def inequality(x, y): """ A utility function which compresses the conditions x < y and x > y into a single condition via a multiplier :param x: the LHS of the inequality @@ -71,7 +71,6 @@ def inequality(x, y): if x > y: return -1 - def automated_param_select_n(params, target_security=128): """ A function used to generate the smallest value of n which allows for target_security bits of security, for the input values of (params.Xe.stddev,params.q) @@ -109,9 +108,6 @@ def automated_param_select_n(params, target_security=128): # if params.n > 1024: # we only need to consider powers-of-two in this case # TODO: fill in this case! For n > 1024 we only need to consider every 256 - - - params = params.updated(n = params.n + z * 8) costs = estimate(params) security_level = get_security_level(costs, 2) @@ -137,6 +133,10 @@ def automated_param_select_n(params, target_security=128): if security_level < target_security: params.updated(n=None) + del(costs) + del(costs2) + gc.collect() + return params def generate_parameter_matrix(params_in, sd_range, target_security_levels=[128], name="v0.sobj"): @@ -162,11 +162,11 @@ def generate_parameter_matrix(params_in, sd_range, target_security_levels=[128], params_out = automated_param_select_n(params_in.updated(Xe=Xe_new), target_security=lam) results["{}".format(lam)].append((params_out.n, params_out.q, params_out.Xe.stddev)) save(results, "{}.sobj".format(name)) - + del(params_out) + gc.collect() return results - -def generate_zama_curves64(sd_range=[2, 60], target_security_levels=[256], name="v0256.sobj"): +def generate_zama_curves64(sd_range=[25, 26], target_security_levels=[256], name="v0256.sobj"): D = ND.DiscreteGaussian init_params = LWE.Parameters(n=1024, q=2 ** 64, Xs=D(0.50, -0.50), Xe=D(131072.00), m=oo, tag='TFHE_DEFAULT') @@ -182,5 +182,10 @@ import sys a = int(sys.argv[1]) print(a) +D = ND.DiscreteGaussian +init_params = LWE.Parameters(n=1024, q=2 ** 64, Xs=ND.UniformMod(2), Xe=D(131072.00), m=oo, tag='TFHE_DEFAULT') + generate_zama_curves64(target_security_levels=[a], name="{}".format(a)) + + From 0381574d9bd9532b2d65dd639ee6b72823933abd Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 12 Apr 2022 14:19:51 +0100 Subject: [PATCH 07/42] update --- new_scripts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/new_scripts.py b/new_scripts.py index c3a98ad50..8db5a23d0 100644 --- a/new_scripts.py +++ b/new_scripts.py @@ -166,7 +166,7 @@ def generate_parameter_matrix(params_in, sd_range, target_security_levels=[128], gc.collect() return results -def generate_zama_curves64(sd_range=[25, 26], target_security_levels=[256], name="v0256.sobj"): +def generate_zama_curves64(sd_range=[2, 56], target_security_levels=[256], name="v0256.sobj"): D = ND.DiscreteGaussian init_params = LWE.Parameters(n=1024, q=2 ** 64, Xs=D(0.50, -0.50), Xe=D(131072.00), m=oo, tag='TFHE_DEFAULT') From 378e4a57d757bdb34a997606cba59542ce9762fb Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 12 Apr 2022 14:41:33 +0100 Subject: [PATCH 08/42] update --- new_scripts.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/new_scripts.py b/new_scripts.py index 8db5a23d0..6233a75ad 100644 --- a/new_scripts.py +++ b/new_scripts.py @@ -118,8 +118,9 @@ def automated_param_select_n(params, target_security=128): # final estimate (we went too far in the above loop) if security_level < target_security: - # we go back - params = params.updated(n = params.n - z * 8) + # we make n larger + params = params.updated(n = params.n + 8) + costs = estimate(params) security_level = get_security_level(costs, 2) print("the finalised parameters are n = {}, log2(sd) = {}, log2(q) = {}, with a security level of {}-bits".format(params.n, From 0dd1825341a8b2750bd3b5daaa1e63ad41d9503a Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 12 Apr 2022 14:52:51 +0100 Subject: [PATCH 09/42] update --- new_scripts.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/new_scripts.py b/new_scripts.py index 6233a75ad..8d31740fa 100644 --- a/new_scripts.py +++ b/new_scripts.py @@ -95,6 +95,13 @@ def automated_param_select_n(params, target_security=128): # TODO -- is this how we want to deal with the small n issue? Shouldn't the model have this baked in? # we want to start no lower than n = 450 n_start = max(n_start, 450) + + #if n_start > 1024: + # we only consider powers-of-two for now, in this range + # n_log = log2(n_start) + # n_start = 2**round(n_log) + + print("n_start = {}".format(n_start)) params = params.updated(n=n_start) print(params) @@ -119,6 +126,7 @@ def automated_param_select_n(params, target_security=128): # final estimate (we went too far in the above loop) if security_level < target_security: # we make n larger + print("we make n larger") params = params.updated(n = params.n + 8) costs = estimate(params) security_level = get_security_level(costs, 2) From b627a5c1ddebce614ca53ff378a2d3aac3d1cee1 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 13 Apr 2022 19:19:42 +0000 Subject: [PATCH 10/42] full data| --- 128.sobj | 6 ++++++ 80.sobj | Bin 0 -> 911 bytes 2 files changed, 6 insertions(+) create mode 100644 128.sobj create mode 100644 80.sobj diff --git a/128.sobj b/128.sobj new file mode 100644 index 000000000..d80c2660b --- /dev/null +++ b/128.sobj @@ -0,0 +1,6 @@ +xwpTUM$QA4vƶ}ټ jΪǒX`]L݀5c7v.vcEcbs?sFgd/gf+먊bI/@LT6Қ5 Bw_XllsПfytY;;_.w{lwTə 2uL]3-mS5ZA]U]!(ٖ`& 2QIhI%$3vL]M;3=ɘ,؋V$p%{3KOhIJ=4(9q`!!Je{H(I2T3H1%M52>|Nu]/hSe|k7oi4kS=4hب'ς_hi<7??%֎A \ No newline at end of file diff --git a/80.sobj b/80.sobj new file mode 100644 index 0000000000000000000000000000000000000000..c5f7033c8d4c3f8ae388f32516fe424640a0810b GIT binary patch literal 911 zcmV;A191F!oQ=>|aMV>4$MH=eNEC?JKoKHXz_RZC^Uv}Rs30N;>xp_q3?Qy4%O;Wp ze!Fx*qJT$27qE+pU*moPin0<<8{Zw|izjbMN;wWKTz^ zEISkm1rcP8LUs@8n%CGSbmnALX3A5^aJr^Gl?kVl<+X{raii1ui9}`7WqdM`;HFvW zgu04kIx#Vs&eV*pkK`lAMGdS;)>fT^a^uBw%5t0DhB#(N55w{%d6;DT5R!xtP&Ga0%_Tl4vs$#idFv zV_Yt{f;L%+XONCcIx(&kTtzFb#5YK1C08@L2)fc-D+vrzsN@<(H$itwJLE@kt&-~) z*9&f-;STv8dMN41xKVHul{n;kxLL_9jIiKVDs;&A5K$6kc!DBo?U3)mS5nM~33}20 zxh>~=2$YmCdJFo{J}YUSUxeF~+|IZ|(3dt?iD!_0O73Lz7u-dwti(6S03~-b1_}nz zJSzzda*vY1j3I(JWgPO0aIX?#lnU;n5f1r2?pN{vg9Q&#e}{Y@LzO(l7$$g_dOGC$ zC{r?=F+wns3LNr%JfdV2<559^PUN(l@8dBg<%|kJB^|Mn=J~~_Qj%nh7Nls4m3RiJ zR#L-wTrh^#Scz|tS|xRidcjy)W+j0^#wh_KEy&O`hx}rUS2BSyQ80mf&mfDGEM`0>SVC*9#5c%NCCeDk3tph*RuUNGMI|pWUKYGU zv#lg$kXMzw##kQs~B$!-l0AY`2pTl@*d-T!3WgM zAwR%}N>(%02tJ~Ghx`B^EBS=+so*m@p4D=G2|icy1>;M>TH0?Vo4@lErqn%@||3wD!dHGygNsM*WdC-{RpSWU__`_&v^926Xi lpLAG36o-}k$@oifB!19g15x~~ Date: Thu, 14 Apr 2022 19:57:18 +0000 Subject: [PATCH 11/42] data from AWS pre-shutdown --- 112.sobj | Bin 0 -> 221 bytes 144.sobj | Bin 0 -> 839 bytes 160.sobj | 1 + 192.sobj | 2 ++ 256.sobj | 3 +++ 96.sobj | 4 ++++ 6 files changed, 10 insertions(+) create mode 100644 112.sobj create mode 100644 144.sobj create mode 100644 160.sobj create mode 100644 192.sobj create mode 100644 256.sobj create mode 100644 96.sobj diff --git a/112.sobj b/112.sobj new file mode 100644 index 0000000000000000000000000000000000000000..1ab2c07e8a472cd2b0b6d31ac4e5707d5974c052 GIT binary patch literal 221 zcmV<303!c*oNHjJEo6vbW?*12G&Cw?j4fo+@Ga)(;$(mV#^mC}^i;i~%)Insy`t2_ zocP>=v?8wf_+%ibBsD%h2q@-Pnwykb6knEFRGgWgXTVj+OpGqK%+#C|Buy;drkxQi zKs$r{T>J`I+Y8x(3fUw0fdVFa1_t&z8YAyq@!sO0BI2nDimrj6!vAqs>KjRi(#P%NQ-Dtp;&vNxbG8oY+8)a Xv`B!oNCp*3wHHdK7V7~32RUCAvYBVE literal 0 HcmV?d00001 diff --git a/144.sobj b/144.sobj new file mode 100644 index 0000000000000000000000000000000000000000..3f9659048ffc304b66d4c396c5088ce1ca721950 GIT binary patch literal 839 zcmV-N1GxNnoQ==vZisphAjFx4&O$#>|`hSW-XjRfp zkj=;uyhb%I|F$Z#>ObNcq_vVZjMoLZG}20ZgS1uBj?rH526eKMa1sgQO(h)|ZwWfm zpV>Cz7^IVu&WyJO@6cTU;+wC1Hjm$fFxp;u*wMlFuj*6w(eW z@eSfBi7-A84511uNzTv1P$k0{9}0$3#7Z246e$_O7%3P3<-lr!cDD(Ie-B90;vJ%fA^-92q3lh{Jjr@ExC|S%{B3Md)G*6vhfMrUS zGgb&brTbRm7-XfARgBLBtEtgST!XApvX-$%#5c%hC0iI< z1>2}|8u^9Tu4D&er(hTTm6bZb5WAJ^VeA!rPLHg_HOM|CUogHDG}1vU@eHzG$pOYe z!6B-*65k+)l^kIl6&#~tD@o4xa9qg=#!0~`>XJsjhto>VFuoFeO@C*m&iC+*lCz9+ zg7fsmN<4#HP;!xRN$@QlwG!VTmz8|S_+D^@8muHaKZ2`Dt}(6)ZqRruaSU=($t}ih z!5!+FMt%f$mHfcCC-{;6$w-|a!B0x=Gkz94pl4R%8|0yqM~ugUU+Baur0pyD;Sipv R`IYfh@GO=H{tFGULZHiRh>rjO literal 0 HcmV?d00001 diff --git a/160.sobj b/160.sobj new file mode 100644 index 000000000..be9e64790 --- /dev/null +++ b/160.sobj @@ -0,0 +1 @@ +xNq)EE0:Z/lLjM;cbNxW]>[_h"O? |H:+{Hb K߆wSοI(tVu㰹l[A=v ޮ~m¸HEU;4X+}m nrR1qƉhoQta6%H1҂a9vQrqJ0JU+ 24,MZI0cBp~m$oI%臕 rYU5b%AdӂJ"P2ø)E+#dq[0GRqG<,O+)Scڳ E%%FYpVWr(XE+/ྒG4r{$ \ No newline at end of file diff --git a/192.sobj b/192.sobj new file mode 100644 index 000000000..8a3d3e431 --- /dev/null +++ b/192.sobj @@ -0,0 +1,2 @@ +xNSQU3xk @TEl6U(Z@Őx7Q_{Mx_{_N4VVRnMˬD H$9n=Cs+a/a%^>9c!}2s/JaH!Zch&gllf4f۫ 77 4u 1A -LUIcVd6vj%;G8٣d/c`?} dt҄xRrqDp$41%'ݴR;ASӴj%AzagiJ\$$F3$+ )` +X>\PrqI0D_1Ȱˌ+T i%#Q ו`QJBRB6}o⎒ ܣOV侒qCYkGǂ'k%A*`<vJ&9AYiAH1Ȍ%[kY%s`:3HI eAk称d$xEV1a, o^X \ No newline at end of file diff --git a/256.sobj b/256.sobj new file mode 100644 index 000000000..c22a70366 --- /dev/null +++ b/256.sobj @@ -0,0 +1,3 @@ +xϷNA3&`r9 &gSXb*S8,3B/@œ/W W+vf%02A0(/ OUrk /gs~u(v;^^X!Y*M3NQNȄiκT?bTߞOIB!5aQ%B%i 42{D +H͒ZmZKlKAdt KKb +閤K2@d W-2,a1&0Ƹ$IƔh[!ӒLƬ+oÒ$BQ% $"%B,K"%Q,KBXeQKAdl;-)d[B/*/x \ No newline at end of file diff --git a/96.sobj b/96.sobj new file mode 100644 index 000000000..fdc930980 --- /dev/null +++ b/96.sobj @@ -0,0 +1,4 @@ +xWpUMHATTDXwoQ'Qd-'~ DQ#^ł+Xb X@|'4gtFr3{=3{w".D"MF`Ⲯ>NQc!Fs-a>6ff43KG6Y̶)\fV6o+GӒmz*K,LvKЛQgd G a a_(%G3*Ti%A*9Op,F=H8^p '*9qb%ANUR 8[I`JNg!8:$4 %g1Ci|"8j= U2OUbJ OPM|F +{ h̯p%2F.VdQ"+ 2Zɥ1˨J\d,c;W +%Ĩ\I>+`UTj%&_}\˸Np= 7(̸QV&% )FZg%=$h4J<4+iaLLM *ic Xf(#'P:dB5Um鏒5qNm%A*q`m (X Zf%AU%XDsg~)A8'񐒇($Uq䐟R%+!?JV1V ŅU^ O*xJ4m  Date: Thu, 12 May 2022 15:48:30 +0100 Subject: [PATCH 12/42] add test code for memory usage --- memory_tests/test.py | 17 +++++++++++++++++ memory_tests/test2.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 memory_tests/test.py create mode 100644 memory_tests/test2.py diff --git a/memory_tests/test.py b/memory_tests/test.py new file mode 100644 index 000000000..22a58d63e --- /dev/null +++ b/memory_tests/test.py @@ -0,0 +1,17 @@ +from estimator_new import * +from sage.all import oo, save + +def test(): + + # code + D = ND.DiscreteGaussian + params = LWE.Parameters(n=1024, q=2 ** 64, Xs=D(0.50, -0.50), Xe=D(2**57), m=oo, tag='TFHE_DEFAULT') + + names = [params, params.updated(n=761), params.updated(q=2 ** 65), params.updated(n=762)] + + for name in names: + x = LWE.estimate(name, deny_list=("arora-gb", "bkw")) + + return 0 + +test() \ No newline at end of file diff --git a/memory_tests/test2.py b/memory_tests/test2.py new file mode 100644 index 000000000..4ad476806 --- /dev/null +++ b/memory_tests/test2.py @@ -0,0 +1,31 @@ + +from multiprocessing import * +from estimator_new import * +from sage.all import oo, save + + +def test_memory(x): + print("doing job...") + print(x) + y = LWE.estimate(x, deny_list=("arora-gb", "bkw")) + return y + +if __name__ == "__main__": + D = ND.DiscreteGaussian + params = LWE.Parameters(n=1024, q=2 ** 64, Xs=D(0.50, -0.50), Xe=D(2**57), m=oo, tag='TFHE_DEFAULT') + + names = [params, params.updated(n=761), params.updated(q=2**65), params.updated(n=762)] + procs = [] + proc = Process(target=print_func) + procs.append(proc) + proc.start() + p = Pool(1) + + for name in names: + proc = Process(target=test_memory, args=(name,)) + procs.append(proc) + proc.start() + proc.join() + + for proc in procs: + proc.join() \ No newline at end of file From 15963ff51fa7e66624ec8f605d0fbfd939df6fc4 Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 9 Jun 2022 22:27:37 +0200 Subject: [PATCH 13/42] start getting multiprocessing to work --- new_scripts.py | 146 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 117 insertions(+), 29 deletions(-) diff --git a/new_scripts.py b/new_scripts.py index 8d31740fa..3f7b74c26 100644 --- a/new_scripts.py +++ b/new_scripts.py @@ -4,9 +4,10 @@ from estimator_new import * from sage.all import oo, save from math import log2 import gc +from multiprocessing import * -def old_models(security_level, sd, logq = 32): +def old_models(security_level, sd, logq=32): """ Use the old model as a starting point for the data gathering step :param security_level: the security level under consideration @@ -14,12 +15,11 @@ def old_models(security_level, sd, logq = 32): :param logq : the (base 2 log) value of the LWE modulus q """ - def evaluate_model(sd, a, b): - return (sd - b)/a + def evaluate_model(a, b, stddev=sd): + return (stddev - b)/a models = dict() - # TODO: figure out a way to import these from a datafile, for future version models["80"] = (-0.04049295502947623, 1.1288318226557081 + logq) models["96"] = (-0.03416314056943681, 1.4704806061716345 + logq) models["112"] = (-0.02970984362676178, 1.7848907787798667 + logq) @@ -34,32 +34,38 @@ def old_models(security_level, sd, logq = 32): models["256"] = (-0.014530554319171845, 3.2094375376751745 + logq) (a, b) = models["{}".format(security_level)] - n_est = evaluate_model(sd, a, b) + n_est = evaluate_model(a, b, sd) return round(n_est) -def estimate(params, red_cost_model = RC.BDGL16): + +def estimate(params, red_cost_model=RC.BDGL16, skip=("arora-gb", "bkw")): """ Retrieve an estimate using the Lattice Estimator, for a given set of input parameters :param params: the input LWE parameters + :param red_cost_model: the lattice reduction cost model + :param skip: attacks to skip """ - est = LWE.estimate(params, deny_list=("arora-gb", "bkw"), red_cost_model=red_cost_model) + est = LWE.estimate(params, red_cost_model=red_cost_model, deny_list=skip) return est -def get_security_level(est, dp = 2): + +def get_security_level(est, dp=2): """ Get the security level lambda from a Lattice Estimator output :param est: the Lattice Estimator output - :param dp : the number of decimal places to consider + :param dp: the number of decimal places to consider """ attack_costs = [] - for key in est.keys(): + # note: key does not need to be specified est vs est.keys() + for key in est: attack_costs.append(est[key]["rop"]) # get the security level correct to 'dp' decimal places security_level = round(log2(min(attack_costs)), dp) return security_level + def inequality(x, y): """ A utility function which compresses the conditions x < y and x > y into a single condition via a multiplier :param x: the LHS of the inequality @@ -71,6 +77,7 @@ def inequality(x, y): if x > y: return -1 + def automated_param_select_n(params, target_security=128): """ A function used to generate the smallest value of n which allows for target_security bits of security, for the input values of (params.Xe.stddev,params.q) @@ -101,15 +108,15 @@ def automated_param_select_n(params, target_security=128): # n_log = log2(n_start) # n_start = 2**round(n_log) - print("n_start = {}".format(n_start)) params = params.updated(n=n_start) print(params) + # costs2 = estimate(params) security_level = get_security_level(costs2, 2) + costs2 = None z = inequality(security_level, target_security) - # we keep n > 2 * target_security as a rough baseline for mitm security (on binary key guessing) while z * security_level < z * target_security: # if params.n > 1024: @@ -118,6 +125,9 @@ def automated_param_select_n(params, target_security=128): params = params.updated(n = params.n + z * 8) costs = estimate(params) security_level = get_security_level(costs, 2) + # try none with delete, try none without delete + # test the list of objects that are in memory before end of program + costs = None if -1 * params.Xe.stddev > 0: print("target security level is unatainable") @@ -127,14 +137,14 @@ def automated_param_select_n(params, target_security=128): if security_level < target_security: # we make n larger print("we make n larger") - params = params.updated(n = params.n + 8) + params = params.updated(n=params.n + 8) costs = estimate(params) security_level = get_security_level(costs, 2) print("the finalised parameters are n = {}, log2(sd) = {}, log2(q) = {}, with a security level of {}-bits".format(params.n, log2(params.Xe.stddev), log2(params.q), - security_level)) + security_level)) # final sanity check so we don't return insecure (or inf) parameters # TODO: figure out inf in new estimator @@ -142,12 +152,9 @@ def automated_param_select_n(params, target_security=128): if security_level < target_security: params.updated(n=None) - del(costs) - del(costs2) - gc.collect() - return params + def generate_parameter_matrix(params_in, sd_range, target_security_levels=[128], name="v0.sobj"): """ :param sd_range: a tuple (sd_min, sd_max) giving the values of sd for which to generate parameters @@ -175,26 +182,107 @@ def generate_parameter_matrix(params_in, sd_range, target_security_levels=[128], gc.collect() return results -def generate_zama_curves64(sd_range=[2, 56], target_security_levels=[256], name="v0256.sobj"): - D = ND.DiscreteGaussian - init_params = LWE.Parameters(n=1024, q=2 ** 64, Xs=D(0.50, -0.50), Xe=D(131072.00), m=oo, tag='TFHE_DEFAULT') - raw_data = generate_parameter_matrix(init_params, sd_range=sd_range, target_security_levels=target_security_levels, name=name) +def generate_parameter_matrix_para(params_in, sd_range, target_security_levels=[128], name="v0.sobj"): + """ + :param sd_range: a tuple (sd_min, sd_max) giving the values of sd for which to generate parameters + :param params: the standard deviation of the LWE error + :param target_security: the target number of bits of security, 128 is default - return raw_data + EXAMPLE: + sage: X = generate_parameter_matrix() + sage: X + """ + if __name__ == "__main__": -def plota_curve(raw_data, security_level): + results = dict() - data = raw_data["{}".format(security_level)] + def test_memory(x): + print("doing job...") + print(x) + y = LWE.estimate(x, deny_list=("arora-gb", "bkw")) + return y + + # grab min and max value/s of n + (sd_min, sd_max) = sd_range + print(sd_range) + + for lam in target_security_levels: + results["{}".format(lam)] = [] + names = range(sd_min, sd_max + 1) + procs = [] + proc = Process(target=automated_param_select_n) + procs.append(proc) + proc.start() + p = Pool(1) + for name in names: + proc = Process(target=test_memory, args=(name,)) + procs.append(proc) + proc.start() + proc.join() + Xe_new = nd.NoiseDistribution.DiscreteGaussian(2**sd) + params_out = automated_param_select_n(params_in.updated(Xe=Xe_new), target_security=lam) + results["{}".format(lam)].append((params_out.n, params_out.q, params_out.Xe.stddev)) + save(results, "{}.sobj".format(name)) + params_out = None + del(params_out) + gc.collect() + return results + +# what we run + +def generate_zama_curves64(sd_range=[2, 56], target_security_levels=[256], name="default", pools = 1): + if __name__ == '__main__': + + D = ND.DiscreteGaussian + vals = sd_range + p = Pool(pools) + procs = [] + for val in vals: + init_params = LWE.Parameters(n=1024, q=2 ** 64, Xs=D(0.50, -0.50), Xe=D(2**55), m=oo, tag='TFHE_DEFAULT') + proc = Process(target=generate_parameter_matrix, args=(init_params, [val, val + 1], target_security_levels, name)) + procs.append(proc) + proc.start() + + return "done" import sys a = int(sys.argv[1]) -print(a) +print("input arg is {}".format(a)) D = ND.DiscreteGaussian -init_params = LWE.Parameters(n=1024, q=2 ** 64, Xs=ND.UniformMod(2), Xe=D(131072.00), m=oo, tag='TFHE_DEFAULT') - -generate_zama_curves64(target_security_levels=[a], name="{}".format(a)) +init_params = LWE.Parameters(n=1024, q=2 ** 32, Xs=ND.UniformMod(2), Xe=D(131072.00), m=oo, tag='TFHE_DEFAULT') +#automated_param_select_n(init_params, target_security=128) +#automated_param_select_n(init_params, target_security=192) +generate_zama_curves64(sd_range=[50, 53], target_security_levels=[a], name="{}".format("testing")) + + + + + + + + + +#if __name__ == "__main__": +# D = ND.DiscreteGaussian +# params = LWE.Parameters(n=1024, q=2 ** 64, Xs=D(0.50, -0.50), Xe=D(2**57), m=oo, tag='TFHE_DEFAULT') +# +# names = [params, params.updated(n=761), params.updated(q=2**65), params.updated(n=762)] +# procs = [] +# proc = Process(target=print_func) +# procs.append(proc) +# proc.start() +# p = Pool(1) +# +# for name in names: +# proc = Process(target=test_memory, args=(name,)) +# procs.append(proc) +# proc.start() +# proc.join() +# +# for proc in procs: +# proc.join() From 997c627fc9031940053b78d156842901d36e2529 Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 20 Jun 2022 18:26:34 +0100 Subject: [PATCH 14/42] use starmap --- new_scripts.py | 122 +++++++++++-------------------------------------- 1 file changed, 26 insertions(+), 96 deletions(-) diff --git a/new_scripts.py b/new_scripts.py index 3f7b74c26..184d66778 100644 --- a/new_scripts.py +++ b/new_scripts.py @@ -1,7 +1,8 @@ import gc +import multiprocessing from estimator_new import * -from sage.all import oo, save +from sage.all import oo, save, load from math import log2 import gc from multiprocessing import * @@ -152,7 +153,7 @@ def automated_param_select_n(params, target_security=128): if security_level < target_security: params.updated(n=None) - return params + return (params, security_level) def generate_parameter_matrix(params_in, sd_range, target_security_levels=[128], name="v0.sobj"): @@ -166,123 +167,52 @@ def generate_parameter_matrix(params_in, sd_range, target_security_levels=[128], sage: X """ - results = dict() - # grab min and max value/s of n (sd_min, sd_max) = sd_range - for lam in target_security_levels: - results["{}".format(lam)] = [] + print("LAM = {}".format(lam)) for sd in range(sd_min, sd_max + 1): Xe_new = nd.NoiseDistribution.DiscreteGaussian(2**sd) - params_out = automated_param_select_n(params_in.updated(Xe=Xe_new), target_security=lam) - results["{}".format(lam)].append((params_out.n, params_out.q, params_out.Xe.stddev)) + (params_out, sec) = automated_param_select_n(params_in.updated(Xe=Xe_new), target_security=lam) + print("PARAMS OUT = {}".format(params_out)) + + try: + results = load("{}.sobj".format(name)) + except: + results = dict() + results["{}".format(lam)] = [] + + results["{}".format(lam)].append((params_out.n, params_out.q, params_out.Xe.stddev, sec)) save(results, "{}.sobj".format(name)) + del(params_out) gc.collect() return results -def generate_parameter_matrix_para(params_in, sd_range, target_security_levels=[128], name="v0.sobj"): - """ - :param sd_range: a tuple (sd_min, sd_max) giving the values of sd for which to generate parameters - :param params: the standard deviation of the LWE error - :param target_security: the target number of bits of security, 128 is default - - EXAMPLE: - sage: X = generate_parameter_matrix() - sage: X - """ - if __name__ == "__main__": - - results = dict() - - def test_memory(x): - print("doing job...") - print(x) - y = LWE.estimate(x, deny_list=("arora-gb", "bkw")) - return y - - # grab min and max value/s of n - (sd_min, sd_max) = sd_range - print(sd_range) - - for lam in target_security_levels: - results["{}".format(lam)] = [] - names = range(sd_min, sd_max + 1) - procs = [] - proc = Process(target=automated_param_select_n) - procs.append(proc) - proc.start() - p = Pool(1) - for name in names: - proc = Process(target=test_memory, args=(name,)) - procs.append(proc) - proc.start() - proc.join() - Xe_new = nd.NoiseDistribution.DiscreteGaussian(2**sd) - params_out = automated_param_select_n(params_in.updated(Xe=Xe_new), target_security=lam) - results["{}".format(lam)].append((params_out.n, params_out.q, params_out.Xe.stddev)) - save(results, "{}.sobj".format(name)) - params_out = None - del(params_out) - gc.collect() - return results - -# what we run - -def generate_zama_curves64(sd_range=[2, 56], target_security_levels=[256], name="default", pools = 1): +def generate_zama_curves64(sd_range=range(5,9), target_security_levels=[256], name="default"): if __name__ == '__main__': D = ND.DiscreteGaussian vals = sd_range - p = Pool(pools) procs = [] - for val in vals: - init_params = LWE.Parameters(n=1024, q=2 ** 64, Xs=D(0.50, -0.50), Xe=D(2**55), m=oo, tag='TFHE_DEFAULT') - proc = Process(target=generate_parameter_matrix, args=(init_params, [val, val + 1], target_security_levels, name)) - procs.append(proc) - proc.start() + pool = multiprocessing.Pool(2) + init_params = LWE.Parameters(n=1024, q=2 ** 64, Xs=D(0.50, -0.50), Xe=D(2 ** 55), m=oo, tag='TFHE_DEFAULT') + inputs = [(init_params, (val, val+1), target_security_levels, name) for val in vals] + print(inputs[0]) + res = pool.starmap(generate_parameter_matrix, inputs) return "done" +def wrap(*args): + return generate_parameter_matrix(*args) + + import sys a = int(sys.argv[1]) -print("input arg is {}".format(a)) - D = ND.DiscreteGaussian init_params = LWE.Parameters(n=1024, q=2 ** 32, Xs=ND.UniformMod(2), Xe=D(131072.00), m=oo, tag='TFHE_DEFAULT') -#automated_param_select_n(init_params, target_security=128) -#automated_param_select_n(init_params, target_security=192) -generate_zama_curves64(sd_range=[50, 53], target_security_levels=[a], name="{}".format("testing")) - - - - - - - - - -#if __name__ == "__main__": -# D = ND.DiscreteGaussian -# params = LWE.Parameters(n=1024, q=2 ** 64, Xs=D(0.50, -0.50), Xe=D(2**57), m=oo, tag='TFHE_DEFAULT') -# -# names = [params, params.updated(n=761), params.updated(q=2**65), params.updated(n=762)] -# procs = [] -# proc = Process(target=print_func) -# procs.append(proc) -# proc.start() -# p = Pool(1) -# -# for name in names: -# proc = Process(target=test_memory, args=(name,)) -# procs.append(proc) -# proc.start() -# proc.join() -# -# for proc in procs: -# proc.join() +generate_zama_curves64(sd_range= range(2,60), target_security_levels=[a], name="{}".format("new_96")) From 35cea16c22284a1ce1cb1d575c063da54efb7001 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 21 Jun 2022 13:41:25 +0100 Subject: [PATCH 15/42] update script --- 128.sobj | 8 ++--- 80.sobj | Bin 911 -> 1156 bytes 96.sobj | Bin 915 -> 939 bytes .../__pycache__/lwe_primal.cpython-38.pyc | Bin 14230 -> 14230 bytes job.sh | 33 ++++++++++++++++-- new_scripts.py | 9 +++-- 6 files changed, 38 insertions(+), 12 deletions(-) diff --git a/128.sobj b/128.sobj index d80c2660b..2d09818c4 100644 --- a/128.sobj +++ b/128.sobj @@ -1,6 +1,2 @@ -xwpTUM$QA4vƶ}ټ jΪǒX`]L݀5c7v.vcEcbs?sFgd/gf+먊bI/@LT6Қ5 Bw_XllsПfytY;;_.w{lwTə 2uL]3-mS5ZA]U]!(ٖ`& 2QIhI%$3vL]M;3=ɘ,؋V$p%{3KOhIJ=4(9q`!!Je{H(I2T3H1%M52>|Nu]/hSe|k7oi4kS=4hب'ς_hi<7??%֎A \ No newline at end of file +xKlUiϩP(cg:m?ՂR02UD(%elaKŽ]`Æ+H\A\rNכ|~{w;02Ad3҇e|axs rԖiWe3%ݕF4j}sTٌӨĺ;Fn')'S&fv7 tr )bqn9fMЋgw;o|g &/,-ئiM~bqooxNvŽ ];(;+NG5wyq$)^ChT??.]v+Q C(cT)U< zSN~YPh9b9+矈{qQcqwAU&C#io{3b*m0 FujUvU|L0enuď8pV|B~aZuI^tO)UpZ]3ķ8$U<%8gqx8$W|ApQU .-܎ˊ\x d WP \ No newline at end of file diff --git a/80.sobj b/80.sobj index c5f7033c8d4c3f8ae388f32516fe424640a0810b..3f5faea9d632da18c3df7cdbfd3129b53d428539 100644 GIT binary patch literal 1156 zcmV-~1bh295a8yMU2H+%wU?M_TNe(T+tpXIOYh3WapL}{vdaWY++O3ZJGx3)E<3gYpF z=7Ube<7~dGUD~=Jk%})%q|(hx7KaMZD~OueoM>sxK)JEtNtNVfJolnri%#IEh5HIVgVE36+~vm% z*XU2`aBmk5{||>zDELgq0E18bR%0NkJZG|JB^L=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sQ0t;RFWCN&>3J`sFMeOBX}<})>)GrkafNz<(+FwJH)TNqynzNU#*6Po55 zHQzF}3bxTGml?$Iotp0%KL~!LVJ<0m!S89xhlR6BmMeo^x)oU@ZEwf+DA literal 915 zcmV;E18n?woQ=>|aMV>4$MH>pNYn%oyFpY`L|AwK`ET~W5fKzoh$q5PWG%Rcu=yvL z1b({#3q(dn;?pgiJ zwkg?MW>z+rZ<*d6D@Tco8q<<(oq7l=txGISmv+C&^`q<2OVFE9magm`_|e$^XJiaV z)D0B$VU!Dwq+y5twz;JFUlJJPC?!WTDg>2OX(gdS`YJhw(NAzJ{n^__;yp+l{goWY zI9_l9?XeQiASWt0iE*;v6xw1XzClh^QpFe`IE|KDNnntHN=|2-Avlvdtt2$aASGup z&K8_QX@`6dgO!}i7$P{2Y8~=D3{^6W5fz+IRSx+cVoKr+Pf$$}hkOsdk_4khkfejX z3g>$Wl%yE7f(vM;mGsQ7#&9JUGDZk4qK#JK8DylAQH+ZPm(U_B@eMLs$)$`jg3GAg zN&p+W9dvXIdw zSVVKIq-TB-_bIub@qpk#$~fdF@sN^-8H)vv&?txeBpy}r7~^rl5*p-?pTtrn%NWZA zE2zvNKZ%t}Rxwr!*3j?8h4TZfRkDt;Uho9%vJ%fAPb%5KcuMdzZMG8MARCoD!+2Kk z94)qzz#z{n*~EB3u$elnBs9ntC0iLU3SOc~4*4m(tmGBOHo>b@>yV$qYf4^cydij# zsvPoDcuUE4#ty;T^mkF={1o0%@-E{&!TYq=Nw^u>5!oAFKI< z@u}c5T5mO;X?CgkobiR=OX{*3-!xyT`I_;K;9HtzHGye%tJ%Z&PVhaAvzpK}KdAYU pu~)ESHU|JX%mrHj delta 20 acmbQ1KP{g-l$V!_0SNR1yf<=pn*#tgNCeja diff --git a/job.sh b/job.sh index 52a2a071a..47b418a64 100755 --- a/job.sh +++ b/job.sh @@ -1,4 +1,31 @@ #!/bin/sh -sage-python new_scripts.py 80 -sage-python new_scripts.py 128 -sage-python new_scripts.py 192 +# 80-bits +sage-python new_scripts.py 80 2 12 +sage-python new_scripts.py 80 13 22 +sage-python new_scripts.py 80 23 32 +sage-python new_scripts.py 80 33 42 +sage-python new_scripts.py 80 43 52 +sage-python new_scripts.py 80 53 59 +# 128-bits +sage-python new_scripts.py 128 2 12 +sage-python new_scripts.py 128 13 22 +sage-python new_scripts.py 128 23 32 +sage-python new_scripts.py 128 33 42 +sage-python new_scripts.py 128 43 52 +sage-python new_scripts.py 128 53 59 +# 192-bits +sage-python new_scripts.py 192 2 12 +sage-python new_scripts.py 192 13 22 +sage-python new_scripts.py 192 23 32 +sage-python new_scripts.py 192 33 42 +sage-python new_scripts.py 192 43 52 +sage-python new_scripts.py 192 53 59 +# 256-bits +sage-python new_scripts.py 256 2 12 +sage-python new_scripts.py 256 13 22 +sage-python new_scripts.py 256 23 32 +sage-python new_scripts.py 256 33 42 +sage-python new_scripts.py 256 43 52 +sage-python new_scripts.py 256 53 59 + + diff --git a/new_scripts.py b/new_scripts.py index 184d66778..959f51da8 100644 --- a/new_scripts.py +++ b/new_scripts.py @@ -194,11 +194,11 @@ def generate_zama_curves64(sd_range=range(5,9), target_security_levels=[256], na if __name__ == '__main__': D = ND.DiscreteGaussian - vals = sd_range + vals = range(sd_range[0], sd_range[1]) procs = [] pool = multiprocessing.Pool(2) init_params = LWE.Parameters(n=1024, q=2 ** 64, Xs=D(0.50, -0.50), Xe=D(2 ** 55), m=oo, tag='TFHE_DEFAULT') - inputs = [(init_params, (val, val+1), target_security_levels, name) for val in vals] + inputs = [(init_params, (val, val), target_security_levels, name) for val in vals] print(inputs[0]) res = pool.starmap(generate_parameter_matrix, inputs) @@ -210,9 +210,12 @@ def wrap(*args): import sys a = int(sys.argv[1]) +b = int(sys.argv[2]) +c = int(sys.argv[3]) +print(b) D = ND.DiscreteGaussian init_params = LWE.Parameters(n=1024, q=2 ** 32, Xs=ND.UniformMod(2), Xe=D(131072.00), m=oo, tag='TFHE_DEFAULT') -generate_zama_curves64(sd_range= range(2,60), target_security_levels=[a], name="{}".format("new_96")) +generate_zama_curves64(sd_range= (b,c), target_security_levels=[a], name="{}".format(a)) From 86eb6734665a8fb23b15acda0fdb6320da5e1e0b Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 21 Jun 2022 15:02:06 +0100 Subject: [PATCH 16/42] update outputs --- new_scripts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/new_scripts.py b/new_scripts.py index 959f51da8..efc937d72 100644 --- a/new_scripts.py +++ b/new_scripts.py @@ -182,7 +182,7 @@ def generate_parameter_matrix(params_in, sd_range, target_security_levels=[128], results = dict() results["{}".format(lam)] = [] - results["{}".format(lam)].append((params_out.n, params_out.q, params_out.Xe.stddev, sec)) + results["{}".format(lam)].append((params_out.n, log(params_out.q,2), log(params_out.Xe.stddev,2), sec)) save(results, "{}.sobj".format(name)) del(params_out) From 40c0cc6744e995e244622cee926f7118fbcd85e7 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 21 Jun 2022 15:03:18 +0100 Subject: [PATCH 17/42] correct bounds --- job.sh | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/job.sh b/job.sh index 47b418a64..7c1928464 100755 --- a/job.sh +++ b/job.sh @@ -1,31 +1,31 @@ #!/bin/sh # 80-bits sage-python new_scripts.py 80 2 12 -sage-python new_scripts.py 80 13 22 -sage-python new_scripts.py 80 23 32 -sage-python new_scripts.py 80 33 42 -sage-python new_scripts.py 80 43 52 -sage-python new_scripts.py 80 53 59 +sage-python new_scripts.py 80 12 22 +sage-python new_scripts.py 80 22 32 +sage-python new_scripts.py 80 32 42 +sage-python new_scripts.py 80 42 52 +sage-python new_scripts.py 80 52 59 # 128-bits sage-python new_scripts.py 128 2 12 -sage-python new_scripts.py 128 13 22 -sage-python new_scripts.py 128 23 32 -sage-python new_scripts.py 128 33 42 -sage-python new_scripts.py 128 43 52 -sage-python new_scripts.py 128 53 59 +sage-python new_scripts.py 128 12 22 +sage-python new_scripts.py 128 22 32 +sage-python new_scripts.py 128 32 42 +sage-python new_scripts.py 128 42 52 +sage-python new_scripts.py 128 52 59 # 192-bits sage-python new_scripts.py 192 2 12 -sage-python new_scripts.py 192 13 22 -sage-python new_scripts.py 192 23 32 -sage-python new_scripts.py 192 33 42 -sage-python new_scripts.py 192 43 52 -sage-python new_scripts.py 192 53 59 +sage-python new_scripts.py 192 12 22 +sage-python new_scripts.py 192 22 32 +sage-python new_scripts.py 192 32 42 +sage-python new_scripts.py 192 42 52 +sage-python new_scripts.py 192 52 59 # 256-bits sage-python new_scripts.py 256 2 12 -sage-python new_scripts.py 256 13 22 -sage-python new_scripts.py 256 23 32 -sage-python new_scripts.py 256 33 42 -sage-python new_scripts.py 256 43 52 -sage-python new_scripts.py 256 53 59 +sage-python new_scripts.py 256 12 22 +sage-python new_scripts.py 256 22 32 +sage-python new_scripts.py 256 32 42 +sage-python new_scripts.py 256 42 52 +sage-python new_scripts.py 256 52 59 From 314ceaf09cd9169088076b48b088eb5bf7cc4b99 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 21 Jun 2022 15:04:28 +0100 Subject: [PATCH 18/42] change for aws --- job.sh | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/job.sh b/job.sh index 7c1928464..b5d58512c 100755 --- a/job.sh +++ b/job.sh @@ -1,31 +1,31 @@ #!/bin/sh # 80-bits -sage-python new_scripts.py 80 2 12 -sage-python new_scripts.py 80 12 22 -sage-python new_scripts.py 80 22 32 -sage-python new_scripts.py 80 32 42 -sage-python new_scripts.py 80 42 52 -sage-python new_scripts.py 80 52 59 +sage new_scripts.py 80 2 12 +sage new_scripts.py 80 12 22 +sage new_scripts.py 80 22 32 +sage new_scripts.py 80 32 42 +sage new_scripts.py 80 42 52 +sage new_scripts.py 80 52 59 # 128-bits -sage-python new_scripts.py 128 2 12 -sage-python new_scripts.py 128 12 22 -sage-python new_scripts.py 128 22 32 -sage-python new_scripts.py 128 32 42 -sage-python new_scripts.py 128 42 52 -sage-python new_scripts.py 128 52 59 +sage new_scripts.py 128 2 12 +sage new_scripts.py 128 12 22 +sage new_scripts.py 128 22 32 +sage new_scripts.py 128 32 42 +sage new_scripts.py 128 42 52 +sage new_scripts.py 128 52 59 # 192-bits -sage-python new_scripts.py 192 2 12 -sage-python new_scripts.py 192 12 22 -sage-python new_scripts.py 192 22 32 -sage-python new_scripts.py 192 32 42 -sage-python new_scripts.py 192 42 52 -sage-python new_scripts.py 192 52 59 +sage new_scripts.py 192 2 12 +sage new_scripts.py 192 12 22 +sage new_scripts.py 192 22 32 +sage new_scripts.py 192 32 42 +sage new_scripts.py 192 42 52 +sage new_scripts.py 192 52 59 # 256-bits -sage-python new_scripts.py 256 2 12 -sage-python new_scripts.py 256 12 22 -sage-python new_scripts.py 256 22 32 -sage-python new_scripts.py 256 32 42 -sage-python new_scripts.py 256 42 52 -sage-python new_scripts.py 256 52 59 +sage new_scripts.py 256 2 12 +sage new_scripts.py 256 12 22 +sage new_scripts.py 256 22 32 +sage new_scripts.py 256 32 42 +sage new_scripts.py 256 42 52 +sage new_scripts.py 256 52 59 From 7feb1f599e6c927da853b6542a52850c9febcf33 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 21 Jun 2022 15:37:27 +0100 Subject: [PATCH 19/42] bug --- new_scripts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/new_scripts.py b/new_scripts.py index efc937d72..baaf2ddf6 100644 --- a/new_scripts.py +++ b/new_scripts.py @@ -182,7 +182,7 @@ def generate_parameter_matrix(params_in, sd_range, target_security_levels=[128], results = dict() results["{}".format(lam)] = [] - results["{}".format(lam)].append((params_out.n, log(params_out.q,2), log(params_out.Xe.stddev,2), sec)) + results["{}".format(lam)].append((params_out.n, log2(params_out.q), log2(params_out.Xe.stddev), sec)) save(results, "{}.sobj".format(name)) del(params_out) From 2a304c4f60f2bb171d5110675a79ecf42d85d4a4 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 21 Jun 2022 17:35:12 +0100 Subject: [PATCH 20/42] tidy finalized script --- new_scripts.py | 78 +++++++++++++++----------------------------------- 1 file changed, 23 insertions(+), 55 deletions(-) diff --git a/new_scripts.py b/new_scripts.py index baaf2ddf6..251bc75ce 100644 --- a/new_scripts.py +++ b/new_scripts.py @@ -1,11 +1,7 @@ -import gc -import multiprocessing - from estimator_new import * from sage.all import oo, save, load from math import log2 -import gc -from multiprocessing import * +import multiprocessing def old_models(security_level, sd, logq=32): @@ -49,6 +45,7 @@ def estimate(params, red_cost_model=RC.BDGL16, skip=("arora-gb", "bkw")): """ est = LWE.estimate(params, red_cost_model=red_cost_model, deny_list=skip) + return est @@ -64,6 +61,7 @@ def get_security_level(est, dp=2): attack_costs.append(est[key]["rop"]) # get the security level correct to 'dp' decimal places security_level = round(log2(min(attack_costs)), dp) + return security_level @@ -91,47 +89,26 @@ def automated_param_select_n(params, target_security=128): 456 """ - # get an initial estimate - # costs = estimate(params) - # security_level = get_security_level(costs, 2) - # determine if we are above or below the target security level - # z = inequality(security_level, target_security) - # get an estimate based on the prev. model print("n = {}".format(params.n)) n_start = old_models(target_security, log2(params.Xe.stddev), log2(params.q)) - # TODO -- is this how we want to deal with the small n issue? Shouldn't the model have this baked in? - # we want to start no lower than n = 450 n_start = max(n_start, 450) + # TODO: think about throwing an error if the required n < 450 - #if n_start > 1024: - # we only consider powers-of-two for now, in this range - # n_log = log2(n_start) - # n_start = 2**round(n_log) - - print("n_start = {}".format(n_start)) params = params.updated(n=n_start) - print(params) - # costs2 = estimate(params) security_level = get_security_level(costs2, 2) - costs2 = None z = inequality(security_level, target_security) # we keep n > 2 * target_security as a rough baseline for mitm security (on binary key guessing) while z * security_level < z * target_security: - # if params.n > 1024: - # we only need to consider powers-of-two in this case - # TODO: fill in this case! For n > 1024 we only need to consider every 256 + # TODO: fill in this case! For n > 1024 we only need to consider every 256 (optimization) params = params.updated(n = params.n + z * 8) costs = estimate(params) security_level = get_security_level(costs, 2) - # try none with delete, try none without delete - # test the list of objects that are in memory before end of program - costs = None if -1 * params.Xe.stddev > 0: - print("target security level is unatainable") + print("target security level is unattainable") break # final estimate (we went too far in the above loop) @@ -147,34 +124,25 @@ def automated_param_select_n(params, target_security=128): log2(params.q), security_level)) - # final sanity check so we don't return insecure (or inf) parameters - # TODO: figure out inf in new estimator - # or security_level == oo: if security_level < target_security: params.updated(n=None) - return (params, security_level) + return params, security_level -def generate_parameter_matrix(params_in, sd_range, target_security_levels=[128], name="v0.sobj"): +def generate_parameter_matrix(params_in, sd_range, target_security_levels=[128], name="default_name"): """ + :param params_in: a initial set of LWE parameters :param sd_range: a tuple (sd_min, sd_max) giving the values of sd for which to generate parameters - :param params: the standard deviation of the LWE error - :param target_security: the target number of bits of security, 128 is default - - EXAMPLE: - sage: X = generate_parameter_matrix() - sage: X + :param target_security_levels: a list of the target number of bits of security, 128 is default + :param name: a name to save the file """ - # grab min and max value/s of n (sd_min, sd_max) = sd_range for lam in target_security_levels: - print("LAM = {}".format(lam)) for sd in range(sd_min, sd_max + 1): Xe_new = nd.NoiseDistribution.DiscreteGaussian(2**sd) (params_out, sec) = automated_param_select_n(params_in.updated(Xe=Xe_new), target_security=lam) - print("PARAMS OUT = {}".format(params_out)) try: results = load("{}.sobj".format(name)) @@ -185,36 +153,36 @@ def generate_parameter_matrix(params_in, sd_range, target_security_levels=[128], results["{}".format(lam)].append((params_out.n, log2(params_out.q), log2(params_out.Xe.stddev), sec)) save(results, "{}.sobj".format(name)) - del(params_out) - gc.collect() return results -def generate_zama_curves64(sd_range=range(5,9), target_security_levels=[256], name="default"): +def generate_zama_curves64(sd_range=[2, 58], target_security_levels=[128], name="default_name"): + """ + The top level function which we use to run the experiment + + :param sd_range: a tuple (sd_min, sd_max) giving the values of sd for which to generate parameters + :param target_security_levels: a list of the target number of bits of security, 128 is default + :param name: a name to save the file + """ if __name__ == '__main__': D = ND.DiscreteGaussian vals = range(sd_range[0], sd_range[1]) - procs = [] pool = multiprocessing.Pool(2) - init_params = LWE.Parameters(n=1024, q=2 ** 64, Xs=D(0.50, -0.50), Xe=D(2 ** 55), m=oo, tag='TFHE_DEFAULT') + init_params = LWE.Parameters(n=1024, q=2 ** 64, Xs=D(0.50, -0.50), Xe=D(2 ** 55), m=oo, tag='params') inputs = [(init_params, (val, val), target_security_levels, name) for val in vals] - print(inputs[0]) res = pool.starmap(generate_parameter_matrix, inputs) return "done" -def wrap(*args): - return generate_parameter_matrix(*args) - +# The script runs the following commands import sys +# grab values of the command-line input arguments a = int(sys.argv[1]) b = int(sys.argv[2]) c = int(sys.argv[3]) -print(b) -D = ND.DiscreteGaussian -init_params = LWE.Parameters(n=1024, q=2 ** 32, Xs=ND.UniformMod(2), Xe=D(131072.00), m=oo, tag='TFHE_DEFAULT') +# run the code generate_zama_curves64(sd_range= (b,c), target_security_levels=[a], name="{}".format(a)) From 3a88a8300398431e05146e586884bdcb4687dfb8 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 21 Jun 2022 18:14:58 +0100 Subject: [PATCH 21/42] this is slowing it down --- new_scripts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/new_scripts.py b/new_scripts.py index 251bc75ce..401f3d37d 100644 --- a/new_scripts.py +++ b/new_scripts.py @@ -92,7 +92,7 @@ def automated_param_select_n(params, target_security=128): # get an estimate based on the prev. model print("n = {}".format(params.n)) n_start = old_models(target_security, log2(params.Xe.stddev), log2(params.q)) - n_start = max(n_start, 450) + # n_start = max(n_start, 450) # TODO: think about throwing an error if the required n < 450 params = params.updated(n=n_start) From 1a59cf56c0f8e37d015f02c054e4bd65905fde4e Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 21 Jun 2022 18:40:14 +0100 Subject: [PATCH 22/42] print --- new_scripts.py | 1 + 1 file changed, 1 insertion(+) diff --git a/new_scripts.py b/new_scripts.py index 401f3d37d..38dd212ce 100644 --- a/new_scripts.py +++ b/new_scripts.py @@ -141,6 +141,7 @@ def generate_parameter_matrix(params_in, sd_range, target_security_levels=[128], (sd_min, sd_max) = sd_range for lam in target_security_levels: for sd in range(sd_min, sd_max + 1): + print("run for {}".format(lam, sd)) Xe_new = nd.NoiseDistribution.DiscreteGaussian(2**sd) (params_out, sec) = automated_param_select_n(params_in.updated(Xe=Xe_new), target_security=lam) From 93804ade442b2d753984622bb09ffbf563b3aaeb Mon Sep 17 00:00:00 2001 From: root Date: Wed, 22 Jun 2022 12:42:32 +0000 Subject: [PATCH 23/42] updated results --- 128.sobj | Bin 828 -> 703 bytes 192.sobj | Bin 553 -> 699 bytes 256.sobj | Bin 377 -> 726 bytes 80.sobj | Bin 1156 -> 715 bytes 4 files changed, 0 insertions(+), 0 deletions(-) diff --git a/128.sobj b/128.sobj index 2d09818c41fc5c159fd24fa873b2f9547265b9dd..79a6242f3cf14f5d10a8ac6c3f8e5c527aac6717 100644 GIT binary patch literal 703 zcmV;w0zmzEoMqHKOjJP-2k>_v9LJ$}o(JLq2O^#W;>q!Ofas~{Au>j6v_PYU7FLXI zg(0~_(Gp9c#ZoN|oe3r;CfaCWV?$vDi4{gW_sB3iFK???{PLgO*_~GjFOqjF;(1=7 zzeu6m6b8U&b>-4^Z+DeT-rmPuZ|z57f(%6fi&`WDA_{m%i@1o;)>3x;hM^k3lon|b zH5yR~E}4){omPPfw?Tc+Dk9pEP|T1BMnHg-N5 zN&wDi(Iq0zr>zIfX^|6=WU&wMZLJc$B4Q7!%g}zne_DX6vio7E0q}(ud3W0RY8gWZ z0KaR|Bce7jVU3|AV51iOBEp;Hcj+gF4g%iOqEAHhi(Ow0r2v1&lo)Us)glQ)hXBWQ zMnOcx?sNXNp)}xUoiXU{)^1~A(@-PenifOu=D4R#fCVjzfqonYT-0LN^}}B6#MhwB67Nz`qflA)=n& zsr?sz(_+%~gS*}h_{JwBBhG)A9y<+MT$YS9zp;~m&$YM|xVc_Cx4sOiviFxdW#`tH zA)bG{4_8SYrWohU7?NR?*3 z+W|Y-J|P)x{Kf|D%!QPg7SYasx*5>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(i!72OOrjhCeULoCcM+PcfT3*+?OG3Y?RK{ePz6q5ps+q?=;GIDLH;~%can2uc3UYY;^ literal 1156 zcmV-~1bh295a8yMU2H+%wU?M_TNe(T+tpXIOYh3WapL}{vdaWY++O3ZJGx3)E<3gYpF z=7Ube<7~dGUD~=Jk%})%q|(hx7KaMZD~OueoM>sxK)JEtNtNVfJolnri%#IEh5HIVgVE36+~vm% z*XU2`aBmk5{||>zDELgq0E18bR%0NkJZG|JB^L=E#274({Y!iCPSzMgYOOQbvyz7j z9>y4MaNh%F9n=^>YM&EFEId;1C`PftWBlY2QYj}+T6nbJF^sVW53LieaTcjACyrWp zoZ#_{vke}wp@EL?)i{ULoB-91fCNuqoNMslCRrNik*W-^=LjYWp2R4XR&6_4Pz87x-dqd%Q{ygD*#TNrfx88_Gw#VaVI8D)IFqAR^1XuBFgi1;y_QtF6DKXa zPVjw<^#)J!_q>7B7AN*Be81oa7!PLr(LF?}H9)I8JS=!4;}L@=`jg~QQnLe8+rwjm zH!(I#pT$nlc%0N9**zy$;t9b|GPW2zMe4Oe<0(>O1MJzu(}JI2Y&AIS-{) z*t76!f?sF6k@05mCaF#*PFnaa!EZC(F?f)FF?N`@p_6doNv#Tpuv7HAj9o_O`O)u@ zTHw?XTfZ-QH{%1N8~v;CA*qN{d$#^a^v8@nM$hn{d@rd1PMx&%KGB~r_8Xn@=h&wd z`#Zq4!}v__=Zr55Uhlshd`Yn%1ME7C1A-4SzB0J*-ydrnIt7l}_-n!6Fuu*WS>K%k Wdp7=F@L|T0416?^F8v4EULy{xr7;Nr From 5f68915c75fd46cad2c78e7530a19e9cf541f0df Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 22 Jun 2022 11:59:00 +0100 Subject: [PATCH 24/42] update file for last exps --- job.sh | 83 +++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 59 insertions(+), 24 deletions(-) diff --git a/job.sh b/job.sh index b5d58512c..036d9b610 100755 --- a/job.sh +++ b/job.sh @@ -1,31 +1,66 @@ #!/bin/sh # 80-bits -sage new_scripts.py 80 2 12 -sage new_scripts.py 80 12 22 -sage new_scripts.py 80 22 32 -sage new_scripts.py 80 32 42 -sage new_scripts.py 80 42 52 -sage new_scripts.py 80 52 59 +#sage new_scripts.py 80 2 12 +#sage new_scripts.py 80 12 22 +#sage new_scripts.py 80 22 32 +#sage new_scripts.py 80 32 42 +#sage new_scripts.py 80 42 52 +#sage new_scripts.py 80 52 59 +# 96-bits +sage new_scripts.py 96 2 12 +sage new_scripts.py 96 12 22 +sage new_scripts.py 96 22 32 +sage new_scripts.py 96 32 42 +sage new_scripts.py 96 42 52 +sage new_scripts.py 96 52 59 +# 112-bits +sage new_scripts.py 112 2 12 +sage new_scripts.py 112 12 22 +sage new_scripts.py 112 22 32 +sage new_scripts.py 112 32 42 +sage new_scripts.py 112 42 52 +sage new_scripts.py 112 52 59 # 128-bits -sage new_scripts.py 128 2 12 -sage new_scripts.py 128 12 22 -sage new_scripts.py 128 22 32 -sage new_scripts.py 128 32 42 -sage new_scripts.py 128 42 52 -sage new_scripts.py 128 52 59 +#sage new_scripts.py 128 2 12 +#sage new_scripts.py 128 12 22 +#sage new_scripts.py 128 22 32 +#sage new_scripts.py 128 32 42 +#sage new_scripts.py 128 42 52 +#sage new_scripts.py 128 52 59 +# 144-bits +sage new_scripts.py 144 2 12 +sage new_scripts.py 144 12 22 +sage new_scripts.py 144 22 32 +sage new_scripts.py 144 32 42 +sage new_scripts.py 144 42 52 +sage new_scripts.py 144 52 59 +# 160-bits +sage new_scripts.py 160 2 12 +sage new_scripts.py 160 12 22 +sage new_scripts.py 160 22 32 +sage new_scripts.py 160 32 42 +sage new_scripts.py 160 42 52 +sage new_scripts.py 160 52 59 +# 176-bits +sage new_scripts.py 176 2 12 +sage new_scripts.py 176 12 22 +sage new_scripts.py 176 22 32 +sage new_scripts.py 176 32 42 +sage new_scripts.py 176 42 52 +sage new_scripts.py 176 52 59 # 192-bits -sage new_scripts.py 192 2 12 -sage new_scripts.py 192 12 22 -sage new_scripts.py 192 22 32 -sage new_scripts.py 192 32 42 -sage new_scripts.py 192 42 52 -sage new_scripts.py 192 52 59 +#sage new_scripts.py 192 2 12 +#sage new_scripts.py 192 12 22 +#sage new_scripts.py 192 22 32 +#sage new_scripts.py 192 32 42 +#sage new_scripts.py 192 42 52 +#sage new_scripts.py 192 52 59 # 256-bits -sage new_scripts.py 256 2 12 -sage new_scripts.py 256 12 22 -sage new_scripts.py 256 22 32 -sage new_scripts.py 256 32 42 -sage new_scripts.py 256 42 52 -sage new_scripts.py 256 52 59 +#sage new_scripts.py 256 2 12 +#sage new_scripts.py 256 12 22 +#sage new_scripts.py 256 22 32 +#sage new_scripts.py 256 32 42 +#sage new_scripts.py 256 42 52 +#sage new_scripts.py 256 52 59 From 8804164d2bbab69be240386ba5a3cfa195c91cef Mon Sep 17 00:00:00 2001 From: root Date: Thu, 23 Jun 2022 08:31:09 +0000 Subject: [PATCH 25/42] turn off aws --- 112.sobj | Bin 221 -> 708 bytes 144.sobj | Bin 839 -> 710 bytes 160.sobj | Bin 415 -> 721 bytes 176.sobj | Bin 0 -> 714 bytes 96.sobj | Bin 939 -> 716 bytes 5 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 176.sobj diff --git a/112.sobj b/112.sobj index 1ab2c07e8a472cd2b0b6d31ac4e5707d5974c052..a50b2f74cb6a1101814de0686621aa684bfb6383 100644 GIT binary patch literal 708 zcmV;#0z3V9oMqKJOp{R*2k^dVO96QmNEu=dAaJW1yE>w3SqegC1znC8E{Y%ITkm%R%R~=n>KI z+W8^B4JSZXwdfX6=0t3+8Lj}0Xps_8pLLhvN>H5^5YcUSTLt!#~6?YjEa^ux=)M-?B2soQEugFxIT7(KXN39;w}O5}lsG8Do1ivOt0Xi57=;PJeqD?gZV|;;@J@Tcr!cTI5A!odH^UWOxrKrNxYhSi-&hhPy!vzKm5* zc=NFr6!B$<@J_!6^fj!+5vdZkH>wwOPm5U*m2lf`I0bs;%aAJ7MVA=f=S+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?ek=7K`1X}O DskB#( literal 415 zcmV;Q0bu@koQ==RP7`qy$MGper3D2Q5$_a5i^wp&I)WF}S}*0)*4Nwm7nD0Jh_R@8Olu(=UzzFUveLD1?wcETXw-mdm*|I;6b*7& z$rZ*`!8Q6~CB8wXlw=swg6s6gN+N^YP%^`~DY!)$E9uYABdcVVaa%A)e^Q6%=W$2L zJi`?%&`&EV8pKnQW8?(|+OrbhAVno5MpKMT`~sGhJZ3x*Jf&YlhvyeiQSyvY6+EZ!R^l7vg_4(ySArUSwvxyoD@uq_7rYL; J?ml}Y;s$=z$58+P diff --git a/176.sobj b/176.sobj new file mode 100644 index 0000000000000000000000000000000000000000..8e96eed3bc99a8ab8f0a93b085a5918bad16ad55 GIT binary patch literal 714 zcmV;*0yX`3oMqHIXjDNI2H>0B#O!X~$>wDq=CMis&122`X>@&MqwzpuA%d~6FpW)y zj3ALfKm;2}VWWao6v09(L2LxYMik35HnFiVm7q2j&efB1&t<2&#m9eU&YU}&kqzTr zjC!6oG%;=pE}IBIbEUcLqW5p*vX%QEE5*zB`F6{iDCn6Mo`{0)w_9JGx26!3)FLUO zA~CzVy<<%g=!O;k7<65WHW4K*V)d~#G0;;jnngt2 zMwj-iiGyae=n&!YJ`$j~7OA|QmVkB=N_2~eb3aN!SuOg5o<2{m@6KCO2700ef{dI` ztSJYTYmv$8X$5Fai{4OK#$CVfsQM$hC>R3|+`l7{P(DkHGtf_YMp~XmE z*K6E-XfY(BY}Id>HAy!gT8su6BmT0c7W6fy#F&WcEjNbmtf>PnXfYY|gXgp!^g@gA zyq-3I8nu`TPRlda2-?tMLPX_~f4SBi1br)3VmdgjYdU^e(*(Mu#SsxT+_7fROD$$Z zBtN?K$(k0>q877x{b&WXYH?IV)dRO4T5|}rcR-0_d1q+@UC`pVh+4k6cF=1rvO(8* zk~=`DP{yX5g=ef2bSIP{qK>1E*cRL9B5XuOu@JlxYS_x%{ z7~qZ#gGRMDBUSqNZbv|okdTZ)e#b^Zk0MH(6_Msy9|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)TtKD+vv9y^_U@ zKEV>2XC(vklej_2jf|TFH&ezTKZ#qE+{#!gxQ)g-$M1&`4hEAb7oO3CAl zCj?K@QY#4z@|2RN8LI_rsM|_HgRE8Z4C7hBb2Ql@KZWO&yuer|c#-NH@>6(8$;*sa z1g}z+Lw*XcDOu0hAb6erDJqg>Xpnc5Y-GGEc#qcaMuzT|ACKXE zH6JiO6nsQ0t;RFWCN&>3J`sFMeOBX}<})>)GrkafNz<(+FwJH)TNqynzNU#*6Po55 zHQzF}3bxTGml?$Iotp0%KL~!LVJ<0m!S89xhlR6BmMeo^x)oU@ZEwf+DA From 04bd8cae5f59e3cc38220ac3c2a5de2040646322 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 24 Jun 2022 11:04:37 +0100 Subject: [PATCH 26/42] update --- 176.sobj | Bin 714 -> 697 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/176.sobj b/176.sobj index 8e96eed3bc99a8ab8f0a93b085a5918bad16ad55..cfc0d59717c40672795f51eb20df0c2299662bab 100644 GIT binary patch literal 697 zcmV;q0!ICKoMqHGXjD-Y2H=;OEHjfmnQUe;%Ov?H%b0yJ#*AAg8V@8EA{Yw`)7a#a zD@Y^|5Wz-L*r;F?MX=CH5F0_U5ydi%O>8VoC8&*s_v!Jx^O#$`;^Ulq|9jruifkJ1 zLe%rT;mHY8aLGgfnlH;`m%P6#m#zB$v0Ac%A8)p;iGrSL;fW~tcB}2>Ico|*NiC8h zDigD7JG<5tfv#&26A|0lP0Si=ia~p&N;Hb7SoN1RC7^3sw2LTpCDtBU69YZbqD4g1 zZFG6xnmA}ii%t<9?;`<a}h@v=|mqzUD_}P14PW7Gpt;QGZ!e2l^6IVq8Scwj0B@*3^R*wU`R>;5lsoJ=bC) zFVjX)lNQs#X?ez)K$}`jil|!lFV~s_psyuL91c$FLdQ>Qnn5?UI3l8!6Kesz&|*eJ z@`GC+t!V`1?hTKpkgv8E4nS&Mn80p4jp=$#g)M0EOr-LPf= zlnK?4F0FhogP^;i8X`LQv>DLvs1iBp(#3D#A<#W77DV*&-421?hiU{}_@x^Lt%hod z805r8Kx0~*mM;B#x1*p)NJxz#e#gc@40B#O!X~$>wDq=CMis&122`X>@&MqwzpuA%d~6FpW)y zj3ALfKm;2}VWWao6v09(L2LxYMik35HnFiVm7q2j&efB1&t<2&#m9eU&YU}&kqzTr zjC!6oG%;=pE}IBIbEUcLqW5p*vX%QEE5*zB`F6{iDCn6Mo`{0)w_9JGx26!3)FLUO zA~CzVy<<%g=!O;k7<65WHW4K*V)d~#G0;;jnngt2 zMwj-iiGyae=n&!YJ`$j~7OA|QmVkB=N_2~eb3aN!SuOg5o<2{m@6KCO2700ef{dI` ztSJYTYmv$8X$5Fai{4OK#$CVfsQM$hC>R3|+`l7{P(DkHGtf_YMp~XmE z*K6E-XfY(BY}Id>HAy!gT8su6BmT0c7W6fy#F&WcEjNbmtf>PnXfYY|gXgp!^g@gA zyq-3I8nu`TPRlda2-?tMLPX_~f4SBi1br)3VmdgjYdU^e(*(Mu#SsxT+_7fROD$$Z zBtN?K$(k0>q877x{b&WXYH?IV)dRO4T5|}rcR-0_d1q+@UC`pVh+4k6cF=1rvO(8* zk~=`DP{yX5g=ef2bSIP{qK>1E*cRL9B5XuOu@JlxYS_x%{ z7~qZ#gGRMDBUSqNZbv|okdTZ)e#b^Zk0MH(6_Msy9|L_338|9eKWZFwO^XE)UEI?N w&{RlBl{S9)CqX@0oRf@U{wt?IT_F)<@a<27I<+9l*ncf&uC8VN0-YR^$ZX Date: Fri, 24 Jun 2022 11:07:59 +0100 Subject: [PATCH 27/42] Update README.rst --- README.rst | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/README.rst b/README.rst index b05d44c55..a20735c63 100644 --- a/README.rst +++ b/README.rst @@ -29,25 +29,15 @@ This is an example of how to generate the parameter curves, and save them to fil We can load results files, and find the interpolants. :: - - sage: load("scripts.py") - sage: interps = [] - sage: results = load("v0.sobj") - sage: for result in results: - sage: interps.append(interpolate_result(result, log_q = 64)) - sage: interps - [(-0.040476778656126484, 1.143346508563902), - (-0.03417207792207793, 1.4805194805194737), - (-0.029681716023268107, 1.752723426758335), - (-0.0263748887657055, 2.0121439233304894), - (-0.023730136557783763, 2.1537066948924095), - (-0.021604493958972515, 2.2696862472846204), - (-0.019897520946588438, 2.4423829771964796), - (-0.018504919354426233, 2.6634073426215745), - (-0.017254242957361113, 2.7353702447139026), - (-0.016178309410530816, 2.8493969373734758), - (-0.01541034709414119, 3.1982749283836283), - (-0.014327640360322604, 2.899270827311096)] +[(-0.04042633119364589, 1.6609788641436722, 80, 'PASS', 450), + (-0.03414780360867051, 2.017310258660345, 96, 'PASS', 450), + (-0.029670137081135885, 2.162463714083856, 112, 'PASS', 450), + (-0.02640502876522622, 2.4826422691043177, 128, 'PASS', 450), + (-0.023821437305989134, 2.7177789440636673, 144, 'PASS', 450), + (-0.02174358218716036, 2.938810548493322, 160, 'PASS', 498), + (-0.019904056582117684, 2.8161252801542247, 176, 'PASS', 551), + (-0.018610403247590085, 3.2996236848399008, 192, 'PASS', 606), + (-0.014606812351714953, 3.8493629234693003, 256, 'PASS', 826)] :: Finding the value of n_{alpha} is done manually. We can also verify the interpolants which are generated at the same time: From 803d64064c453ffe3f4b955e1b1be614515bfca8 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 24 Jun 2022 11:08:19 +0100 Subject: [PATCH 28/42] Update README.rst --- README.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.rst b/README.rst index a20735c63..9e51f56f9 100644 --- a/README.rst +++ b/README.rst @@ -29,6 +29,7 @@ This is an example of how to generate the parameter curves, and save them to fil We can load results files, and find the interpolants. :: + [(-0.04042633119364589, 1.6609788641436722, 80, 'PASS', 450), (-0.03414780360867051, 2.017310258660345, 96, 'PASS', 450), (-0.029670137081135885, 2.162463714083856, 112, 'PASS', 450), @@ -38,6 +39,7 @@ We can load results files, and find the interpolants. (-0.019904056582117684, 2.8161252801542247, 176, 'PASS', 551), (-0.018610403247590085, 3.2996236848399008, 192, 'PASS', 606), (-0.014606812351714953, 3.8493629234693003, 256, 'PASS', 826)] + :: Finding the value of n_{alpha} is done manually. We can also verify the interpolants which are generated at the same time: From 33a64b63b2aadffe474a5317226f01fb7a146cbe Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 24 Jun 2022 11:09:05 +0100 Subject: [PATCH 29/42] Update README.rst --- README.rst | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/README.rst b/README.rst index 9e51f56f9..b194a4561 100644 --- a/README.rst +++ b/README.rst @@ -30,16 +30,15 @@ We can load results files, and find the interpolants. :: -[(-0.04042633119364589, 1.6609788641436722, 80, 'PASS', 450), - (-0.03414780360867051, 2.017310258660345, 96, 'PASS', 450), - (-0.029670137081135885, 2.162463714083856, 112, 'PASS', 450), - (-0.02640502876522622, 2.4826422691043177, 128, 'PASS', 450), - (-0.023821437305989134, 2.7177789440636673, 144, 'PASS', 450), - (-0.02174358218716036, 2.938810548493322, 160, 'PASS', 498), - (-0.019904056582117684, 2.8161252801542247, 176, 'PASS', 551), - (-0.018610403247590085, 3.2996236848399008, 192, 'PASS', 606), - (-0.014606812351714953, 3.8493629234693003, 256, 'PASS', 826)] - + [(-0.04042633119364589, 1.6609788641436722, 80, 'PASS', 450), + (-0.03414780360867051, 2.017310258660345, 96, 'PASS', 450), + (-0.029670137081135885, 2.162463714083856, 112, 'PASS', 450), + (-0.02640502876522622, 2.4826422691043177, 128, 'PASS', 450), + (-0.023821437305989134, 2.7177789440636673, 144, 'PASS', 450), + (-0.02174358218716036, 2.938810548493322, 160, 'PASS', 498), + (-0.019904056582117684, 2.8161252801542247, 176, 'PASS', 551), + (-0.018610403247590085, 3.2996236848399008, 192, 'PASS', 606), + (-0.014606812351714953, 3.8493629234693003, 256, 'PASS', 826)] :: Finding the value of n_{alpha} is done manually. We can also verify the interpolants which are generated at the same time: From 5d26dc23cee011ace1c61e1726b5b87939b6a07f Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 24 Jun 2022 11:28:16 +0100 Subject: [PATCH 30/42] mv data --- 112.sobj => data/v1/112.sobj | Bin 128.sobj => data/v1/128.sobj | Bin 144.sobj => data/v1/144.sobj | Bin 160.sobj => data/v1/160.sobj | Bin 176.sobj => data/v1/176.sobj | Bin 192.sobj => data/v1/192.sobj | Bin 256.sobj => data/v1/256.sobj | Bin 80.sobj => data/v1/80.sobj | Bin 96.sobj => data/v1/96.sobj | Bin 9 files changed, 0 insertions(+), 0 deletions(-) rename 112.sobj => data/v1/112.sobj (100%) rename 128.sobj => data/v1/128.sobj (100%) rename 144.sobj => data/v1/144.sobj (100%) rename 160.sobj => data/v1/160.sobj (100%) rename 176.sobj => data/v1/176.sobj (100%) rename 192.sobj => data/v1/192.sobj (100%) rename 256.sobj => data/v1/256.sobj (100%) rename 80.sobj => data/v1/80.sobj (100%) rename 96.sobj => data/v1/96.sobj (100%) diff --git a/112.sobj b/data/v1/112.sobj similarity index 100% rename from 112.sobj rename to data/v1/112.sobj diff --git a/128.sobj b/data/v1/128.sobj similarity index 100% rename from 128.sobj rename to data/v1/128.sobj diff --git a/144.sobj b/data/v1/144.sobj similarity index 100% rename from 144.sobj rename to data/v1/144.sobj diff --git a/160.sobj b/data/v1/160.sobj similarity index 100% rename from 160.sobj rename to data/v1/160.sobj diff --git a/176.sobj b/data/v1/176.sobj similarity index 100% rename from 176.sobj rename to data/v1/176.sobj diff --git a/192.sobj b/data/v1/192.sobj similarity index 100% rename from 192.sobj rename to data/v1/192.sobj diff --git a/256.sobj b/data/v1/256.sobj similarity index 100% rename from 256.sobj rename to data/v1/256.sobj diff --git a/80.sobj b/data/v1/80.sobj similarity index 100% rename from 80.sobj rename to data/v1/80.sobj diff --git a/96.sobj b/data/v1/96.sobj similarity index 100% rename from 96.sobj rename to data/v1/96.sobj From fb65d080d2375b32a40ddf4852e9203f8b4bb852 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 24 Jun 2022 11:32:39 +0100 Subject: [PATCH 31/42] add verification stuff --- new_scripts.py | 281 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 281 insertions(+) diff --git a/new_scripts.py b/new_scripts.py index 38dd212ce..20e7fc265 100644 --- a/new_scripts.py +++ b/new_scripts.py @@ -186,5 +186,286 @@ c = int(sys.argv[3]) # run the code generate_zama_curves64(sd_range= (b,c), target_security_levels=[a], name="{}".format(a)) +from estimator_new import * +from sage.all import oo, save, load +from math import log2 +import multiprocessing +def old_models(security_level, sd, logq=32): + """ + Use the old model as a starting point for the data gathering step + :param security_level: the security level under consideration + :param sd : the standard deviation of the LWE error distribution Xe + :param logq : the (base 2 log) value of the LWE modulus q + """ + + def evaluate_model(a, b, stddev=sd): + return (stddev - b)/a + + models = dict() + + models["80"] = (-0.04049295502947623, 1.1288318226557081 + logq) + models["96"] = (-0.03416314056943681, 1.4704806061716345 + logq) + models["112"] = (-0.02970984362676178, 1.7848907787798667 + logq) + models["128"] = (-0.026361288425133814, 2.0014671315214696 + logq) + models["144"] = (-0.023744534465622812, 2.1710601038230712 + logq) + models["160"] = (-0.021667220727651954, 2.3565507936475476 + logq) + models["176"] = (-0.019947662046189942, 2.5109588704235803 + logq) + models["192"] = (-0.018552804646747204, 2.7168913723130816 + logq) + models["208"] = (-0.017291091126923574, 2.7956961446214326 + logq) + models["224"] = (-0.016257546811508806, 2.9582401000615226 + logq) + models["240"] = (-0.015329741032015766, 3.0744579055889782 + logq) + models["256"] = (-0.014530554319171845, 3.2094375376751745 + logq) + + (a, b) = models["{}".format(security_level)] + n_est = evaluate_model(a, b, sd) + + return round(n_est) + + +def estimate(params, red_cost_model=RC.BDGL16, skip=("arora-gb", "bkw")): + """ + Retrieve an estimate using the Lattice Estimator, for a given set of input parameters + :param params: the input LWE parameters + :param red_cost_model: the lattice reduction cost model + :param skip: attacks to skip + """ + + est = LWE.estimate(params, red_cost_model=red_cost_model, deny_list=skip) + + return est + + +def get_security_level(est, dp=2): + """ + Get the security level lambda from a Lattice Estimator output + :param est: the Lattice Estimator output + :param dp: the number of decimal places to consider + """ + attack_costs = [] + # note: key does not need to be specified est vs est.keys() + for key in est: + attack_costs.append(est[key]["rop"]) + # get the security level correct to 'dp' decimal places + security_level = round(log2(min(attack_costs)), dp) + + return security_level + + +def inequality(x, y): + """ A utility function which compresses the conditions x < y and x > y into a single condition via a multiplier + :param x: the LHS of the inequality + :param y: the RHS of the inequality + """ + if x <= y: + return 1 + + if x > y: + return -1 + + +def automated_param_select_n(params, target_security=128): + """ A function used to generate the smallest value of n which allows for + target_security bits of security, for the input values of (params.Xe.stddev,params.q) + :param params: the standard deviation of the error + :param target_security: the target number of bits of security, 128 is default + + EXAMPLE: + sage: X = automated_param_select_n(Kyber512, target_security = 128) + sage: X + 456 + """ + + # get an estimate based on the prev. model + print("n = {}".format(params.n)) + n_start = old_models(target_security, log2(params.Xe.stddev), log2(params.q)) + # n_start = max(n_start, 450) + # TODO: think about throwing an error if the required n < 450 + + params = params.updated(n=n_start) + costs2 = estimate(params) + security_level = get_security_level(costs2, 2) + z = inequality(security_level, target_security) + + # we keep n > 2 * target_security as a rough baseline for mitm security (on binary key guessing) + while z * security_level < z * target_security: + # TODO: fill in this case! For n > 1024 we only need to consider every 256 (optimization) + params = params.updated(n = params.n + z * 8) + costs = estimate(params) + security_level = get_security_level(costs, 2) + + if -1 * params.Xe.stddev > 0: + print("target security level is unattainable") + break + + # final estimate (we went too far in the above loop) + if security_level < target_security: + # we make n larger + print("we make n larger") + params = params.updated(n=params.n + 8) + costs = estimate(params) + security_level = get_security_level(costs, 2) + + print("the finalised parameters are n = {}, log2(sd) = {}, log2(q) = {}, with a security level of {}-bits".format(params.n, + log2(params.Xe.stddev), + log2(params.q), + security_level)) + + if security_level < target_security: + params.updated(n=None) + + return params, security_level + + +def generate_parameter_matrix(params_in, sd_range, target_security_levels=[128], name="default_name"): + """ + :param params_in: a initial set of LWE parameters + :param sd_range: a tuple (sd_min, sd_max) giving the values of sd for which to generate parameters + :param target_security_levels: a list of the target number of bits of security, 128 is default + :param name: a name to save the file + """ + + (sd_min, sd_max) = sd_range + for lam in target_security_levels: + for sd in range(sd_min, sd_max + 1): + print("run for {}".format(lam, sd)) + Xe_new = nd.NoiseDistribution.DiscreteGaussian(2**sd) + (params_out, sec) = automated_param_select_n(params_in.updated(Xe=Xe_new), target_security=lam) + + try: + results = load("{}.sobj".format(name)) + except: + results = dict() + results["{}".format(lam)] = [] + + results["{}".format(lam)].append((params_out.n, log2(params_out.q), log2(params_out.Xe.stddev), sec)) + save(results, "{}.sobj".format(name)) + + return results + + +def generate_zama_curves64(sd_range=[2, 58], target_security_levels=[128], name="default_name"): + """ + The top level function which we use to run the experiment + + :param sd_range: a tuple (sd_min, sd_max) giving the values of sd for which to generate parameters + :param target_security_levels: a list of the target number of bits of security, 128 is default + :param name: a name to save the file + """ + if __name__ == '__main__': + + D = ND.DiscreteGaussian + vals = range(sd_range[0], sd_range[1]) + pool = multiprocessing.Pool(2) + init_params = LWE.Parameters(n=1024, q=2 ** 64, Xs=D(0.50, -0.50), Xe=D(2 ** 55), m=oo, tag='params') + inputs = [(init_params, (val, val), target_security_levels, name) for val in vals] + res = pool.starmap(generate_parameter_matrix, inputs) + + return "done" + + +# The script runs the following commands +import sys +# grab values of the command-line input arguments +a = int(sys.argv[1]) +b = int(sys.argv[2]) +c = int(sys.argv[3]) +# run the code +generate_zama_curves64(sd_range= (b,c), target_security_levels=[a], name="{}".format(a)) + +import numpy as np +from sage.all import save, load + +def sort_data(security_level): + from operator import itemgetter + + # step 1. load the data + X = load("{}.sobj".format(security_level)) + + # step 2. sort by SD + x = sorted(X["{}".format(security_level)], key = itemgetter(2)) + + # step3. replace the sorted value + X["{}".format(security_level)] = x + + return X + +def generate_curve(security_level): + + # step 1. get the data + X = sort_data(security_level) + + # step 2. group the n and sigma data into lists + N = [] + SD = [] + for x in X["{}".format(security_level)]: + N.append(x[0]) + SD.append(x[2] + 0.5) + + # step 3. perform interpolation and return coefficients + (a,b) = np.polyfit(N, SD, 1) + + return a, b + + +def verify_curve(security_level, a = None, b = None): + + # step 1. get the table and max values of n, sd + X = sort_data(security_level) + n_max = X["{}".format(security_level)][0][0] + sd_max = X["{}".format(security_level)][-1][2] + + # step 2. a function to get model values + def f_model(a, b, n): + return ceil(a * n + b) + + # step 3. a function to get table values + def f_table(table, n): + for i in range(len(table)): + n_val = table[i][0] + if n < n_val: + pass + else: + j = i + break + + # now j is the correct index, we return the corresponding sd + return table[j][2] + + # step 3. for each n, check whether we satisfy the table + n_min = max(2 * security_level, 450, X["{}".format(security_level)][-1][0]) + print(n_min) + print(n_max) + + for n in range(n_max, n_min, - 1): + model_sd = f_model(a, b, n) + table_sd = f_table(X["{}".format(security_level)], n) + print(n , table_sd, model_sd, model_sd >= table_sd) + + if table_sd > model_sd: + print("MODEL FAILS at n = {}".format(n)) + return "FAIL" + + return "PASS", n_min + + +def generate_and_verify(security_levels, log_q, name = "verified_curves"): + + data = [] + + for sec in security_levels: + print("WE GO FOR {}".format(sec)) + # generate the model for security level sec + (a_sec, b_sec) = generate_curve(sec) + # verify the model for security level sec + res = verify_curve(sec, a_sec, b_sec) + # append the information into a list + data.append((a_sec, b_sec - log_q, sec, res[0], res[1])) + save(data, "{}.sobj".format(name)) + + return data + +# To verify the curves we use +generate_and_verify([80, 96, 112, 128, 144, 160, 176, 192, 256], log_q = 64) + From 3ba8b788a8d6c71922d85306a755930ff28a77f9 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 24 Jun 2022 11:36:20 +0100 Subject: [PATCH 32/42] start to split code --- verify_curves.py | 95 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 verify_curves.py diff --git a/verify_curves.py b/verify_curves.py new file mode 100644 index 000000000..7773591a4 --- /dev/null +++ b/verify_curves.py @@ -0,0 +1,95 @@ +import numpy as np +from sage.all import save, load + +def sort_data(security_level): + from operator import itemgetter + + # step 1. load the data + X = load("{}.sobj".format(security_level)) + + # step 2. sort by SD + x = sorted(X["{}".format(security_level)], key = itemgetter(2)) + + # step3. replace the sorted value + X["{}".format(security_level)] = x + + return X + +def generate_curve(security_level): + + # step 1. get the data + X = sort_data(security_level) + + # step 2. group the n and sigma data into lists + N = [] + SD = [] + for x in X["{}".format(security_level)]: + N.append(x[0]) + SD.append(x[2] + 0.5) + + # step 3. perform interpolation and return coefficients + (a,b) = np.polyfit(N, SD, 1) + + return a, b + + +def verify_curve(security_level, a = None, b = None): + + # step 1. get the table and max values of n, sd + X = sort_data(security_level) + n_max = X["{}".format(security_level)][0][0] + sd_max = X["{}".format(security_level)][-1][2] + + # step 2. a function to get model values + def f_model(a, b, n): + return ceil(a * n + b) + + # step 3. a function to get table values + def f_table(table, n): + for i in range(len(table)): + n_val = table[i][0] + if n < n_val: + pass + else: + j = i + break + + # now j is the correct index, we return the corresponding sd + return table[j][2] + + # step 3. for each n, check whether we satisfy the table + n_min = max(2 * security_level, 450, X["{}".format(security_level)][-1][0]) + print(n_min) + print(n_max) + + for n in range(n_max, n_min, - 1): + model_sd = f_model(a, b, n) + table_sd = f_table(X["{}".format(security_level)], n) + print(n , table_sd, model_sd, model_sd >= table_sd) + + if table_sd > model_sd: + print("MODEL FAILS at n = {}".format(n)) + return "FAIL" + + return "PASS", n_min + + +def generate_and_verify(security_levels, log_q, name = "verified_curves"): + + data = [] + + for sec in security_levels: + print("WE GO FOR {}".format(sec)) + # generate the model for security level sec + (a_sec, b_sec) = generate_curve(sec) + # verify the model for security level sec + res = verify_curve(sec, a_sec, b_sec) + # append the information into a list + data.append((a_sec, b_sec - log_q, sec, res[0], res[1])) + save(data, "{}.sobj".format(name)) + + return data + +# To verify the curves we use +generate_and_verify([80, 96, 112, 128, 144, 160, 176, 192, 256], log_q = 64) + From 0da9a44dbd8e931a3fc4f3006ce1c5da1ae27ac4 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 24 Jun 2022 11:53:24 +0100 Subject: [PATCH 33/42] copy data --- 112.sobj | Bin 0 -> 708 bytes 128.sobj | Bin 0 -> 703 bytes 144.sobj | Bin 0 -> 710 bytes 160.sobj | Bin 0 -> 721 bytes 176.sobj | Bin 0 -> 697 bytes 192.sobj | Bin 0 -> 699 bytes 256.sobj | Bin 0 -> 726 bytes 80.sobj | Bin 0 -> 715 bytes 96.sobj | Bin 0 -> 716 bytes 9 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 112.sobj create mode 100644 128.sobj create mode 100644 144.sobj create mode 100644 160.sobj create mode 100644 176.sobj create mode 100644 192.sobj create mode 100644 256.sobj create mode 100644 80.sobj create mode 100644 96.sobj diff --git a/112.sobj b/112.sobj new file mode 100644 index 0000000000000000000000000000000000000000..a50b2f74cb6a1101814de0686621aa684bfb6383 GIT binary patch literal 708 zcmV;#0z3V9oMqKJOp{R*2k^dVO96QmNEu=dAaJW1yE>w3SqegC1znC8E{Y%ITkm%R%R~=n>KI z+W8^B4JSZXwdfX6=0t3+8Lj}0Xps_8pLLhvN>H5^5YcUSTLt!#~6?YjEa^ux=)M-?B2soQEugFxIT7(KXN39;w}O5}lsG8Do1ivOt0Xi57=;PJeqD?gZV|;;@J@Tcr!cTI5A!odH^UWOxrKrNxYhSi-&hhPy!vzKm5* zc=NFr6!B$<@J_!6^fj!+5vdZkH>wwOPm5U*m2lf`I0bs;%aAJ7MVA=f=S+|wvpOB2O?N~qPQ%H$<$?*EIAJnWf=0w!kdpiJn=F5;OjrQaQL4UNE z6H(=EW!i8WbW4kZRH?HQbO3Zxiv)hF)dDrn6+~{>D&gNkSas=Y;&M_El4uFH)!hea{3=EpN(6?#!q_v9LJ$}o(JLq2O^#W;>q!Ofas~{Au>j6v_PYU7FLXI zg(0~_(Gp9c#ZoN|oe3r;CfaCWV?$vDi4{gW_sB3iFK???{PLgO*_~GjFOqjF;(1=7 zzeu6m6b8U&b>-4^Z+DeT-rmPuZ|z57f(%6fi&`WDA_{m%i@1o;)>3x;hM^k3lon|b zH5yR~E}4){omPPfw?Tc+Dk9pEP|T1BMnHg-N5 zN&wDi(Iq0zr>zIfX^|6=WU&wMZLJc$B4Q7!%g}zne_DX6vio7E0q}(ud3W0RY8gWZ z0KaR|Bce7jVU3|AV51iOBEp;Hcj+gF4g%iOqEAHhi(Ow0r2v1&lo)Us)glQ)hXBWQ zMnOcx?sNXNp)}xUoiXU{)^1~A(@-PenifOu=D4R#fCVjzfqonYT-0LN^}}B6#MhwB67Nz`qflA)=n& zsr?sz(_+%~gS*}h_{JwBBhG)A9y<+MT$YS9zp;~m&$YM|xVc_Cx4sOiviFxdW#`tH zA)bG{4_8SYrWohU7?NR?*3 z+W|Y-J|P)x{Kf|D%!QPg7SYasx*zvnUC?UHEB6!9mrh^+Z0JefrmZ_ ziolJ_C?bel1Yv7eK~fP^1VN9jYZpOa6a)tCy4OC>cP{r^UARB~=X~eh?_18l!;$mR zNF>si$#C8U&If2Jp39z#?5^C}V zxCHcCi$*6F{8kOeK|@-!i74_Sa_fdmL1kKWxQzJZ(%PosGSJH&gqM z)q*B;#*mwb{l`+EH#%c9wA(sRmChJ;RqSb~2R+moW1-zPfU;UlxQW?6xe;_#i*ff| z?1?%6s?lOHG>Q1u{Z? zcz5B97AK`jrJYA7s4*ZUBVlitF3^*x5;KxfZU3>upx;`Y60vX5UxvFuCXgXj>TDlJ zKpz7cB9ivo_JHQJ$Vru2+v!ozPQDVeBI^B1>bBut(5HZqDk*#R`#?>BDxp65K~HtY zX{nO7yBz@C3<$|+u-`TVYSm&+MB3h#gCGhBsnYCU4xNUFK!5X;I3uFPp4(y2*MJD^ sWd!tGi?fpP|H1Gm=w(1i#)v%)W1tN!NHW^}HYN>^U%t`v4?}dGeB{wu#sB~S literal 0 HcmV?d00001 diff --git a/160.sobj b/160.sobj new file mode 100644 index 0000000000000000000000000000000000000000..005181dd19b8e9006bb9819bc629ef6f904c4d7c GIT binary patch literal 721 zcmV;?0xtb{oMqHKOjA)52k=KJPzp$af>f~O+dma+`Ti2Aq7*+)B09)`iGwCCCY*R( zG$zCZ2bYdU9UNqGAPx>B#s%YGB8!Wg2`(mLjM1Qji?7Y?dFQ2Xddd6cf9^f!-nSaK z$Ieo@<2Zw3X)e3M0f6RfvY87`;mKwq#g}V=o$N;RuHkaf3oRTG_2HS7=bsD*L9JRu zMN~g_pC^VZKt_v@h~NkJ**07W`W9BARYZfkj5|Aqt3Yd7bcm>Qzh^fLhd{5jXcrM# z++B-r8mtg9j(}ci0<@&XtS9XG=m2e3C~-nW z@n&~|k~$+JqQQ2(3-rvFv04=S?5*qu{nH{NqS&z>5NmN#sx;g4(FjR*Vpu`!e(rafs40_`el99B3+!4@KEzXMQw(A%L<$OY_z;(2p`D&X@Fb67?ftv+J0?ek=7K`1X}O DskB#( literal 0 HcmV?d00001 diff --git a/176.sobj b/176.sobj new file mode 100644 index 0000000000000000000000000000000000000000..cfc0d59717c40672795f51eb20df0c2299662bab GIT binary patch literal 697 zcmV;q0!ICKoMqHGXjD-Y2H=;OEHjfmnQUe;%Ov?H%b0yJ#*AAg8V@8EA{Yw`)7a#a zD@Y^|5Wz-L*r;F?MX=CH5F0_U5ydi%O>8VoC8&*s_v!Jx^O#$`;^Ulq|9jruifkJ1 zLe%rT;mHY8aLGgfnlH;`m%P6#m#zB$v0Ac%A8)p;iGrSL;fW~tcB}2>Ico|*NiC8h zDigD7JG<5tfv#&26A|0lP0Si=ia~p&N;Hb7SoN1RC7^3sw2LTpCDtBU69YZbqD4g1 zZFG6xnmA}ii%t<9?;`<a}h@v=|mqzUD_}P14PW7Gpt;QGZ!e2l^6IVq8Scwj0B@*3^R*wU`R>;5lsoJ=bC) zFVjX)lNQs#X?ez)K$}`jil|!lFV~s_psyuL91c$FLdQ>Qnn5?UI3l8!6Kesz&|*eJ z@`GC+t!V`1?hTKpkgv8E4nS&Mn80p4jp=$#g)M0EOr-LPf= zlnK?4F0FhogP^;i8X`LQv>DLvs1iBp(#3D#A<#W77DV*&-421?hiU{}_@x^Lt%hod z805r8Kx0~*mM;B#x1*p)NJxz#e#gc@4L4iUMP@sHsz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!a-16W=wOH)b|kvB6o0vZYk&d8W5qo7eKh%<6oe}uFeyLPMR IFS(kTRoJFu0RR91 literal 0 HcmV?d00001 diff --git a/80.sobj b/80.sobj new file mode 100644 index 0000000000000000000000000000000000000000..14697f236394e52974d679fb352c69ec2bccc243 GIT binary patch literal 715 zcmV;+0yO=2oMqKJOjJP>2H@QV7FZDxmiKE}0e=vX_tQlLagp^TVkp#LW6;io15=?U zG&E|Yve3dpv89!m*r>76P^rYm(3xm778qmYy)b+3x$acA`0~%pnKN@&Lbo|^F%$>{ z20J-;g+l=S$VrZ!5A2QPSW)_8HkjOqF7Fu50@a6=2#CmD-f@iKY|sat5f!ojVK@gA z)){%;EZRy@?heBTKtozId%J!5DUx8r1)!hVO01hzBG5gZ(Ji6|yRX*f3?Bx))S}Z{sm&+`EospsqAIcA zti*5$=$RH>8M}>wE^E=7aW18xaV`2pl)FthWw;FVCrgPz@APe-mV;V!M!$$sXRr8e zxB~P=XAEWRwh~mNGX_MII7MGrH(UjJt22hZn%X|C20hT?gow(A&Uj?F2DG8Yh=^*Z z8Z+Mw*Me?ok?`sfam#MF4m7XDsE9_}LG_@N7AHl-ZLh~bK`l;Y?4<$Jt;Lv#*xrZX zIOuCgXRM?J?AaaxRr)eS)Vd9nFx&{*(i!72OOrjhCeULoCcM+PcfT3*+?OG3Y?RK{ePz6q5ps+q?=;GIDLH;~%can2uc3UYY;^ literal 0 HcmV?d00001 diff --git a/96.sobj b/96.sobj new file mode 100644 index 0000000000000000000000000000000000000000..aa776fb427106c3aa424f775f03bf23309de3195 GIT binary patch literal 716 zcmV;-0yF)1oMqKLOjA)52k=Mvv?3rBMZP}@{DD$|LZQVKFix;(IPoSX zDhY{U(SgJbHlu?RIvExnG;X?SOmre{;-ZPhP2Ypt!+GhQn)H|ddH3A&?pqD4urnWU z948UyylWf)sJu9no^ke8CS8&JF`t*&3f5RSuVbAs`=%y9}A{w`6ch{N>SArgD(Jx}Z zyN0VkGg`z%)W3Jv2g4yyOp8Ggb?$@C{xDn(D$`;pr>Dn2uM3nI5z!X&mf_=|zgoma zbS!zxa1H3O7KxmWodA8+Vpv4`UPBDmg6?aP6wzd7tPV7-#VHXzcDMDQB`rpCy50ba zXps`pwc)N!!;Nmov^XuIGw2Pf;U>_}d?m(m_R<*R`0CDha#Wc2HQ0Ga?4<8`S|S_6eynU?->(H14Y+ zB5voyy$inwlsGF@#_ZX4f!_OsWQ^Lg?FJbwCM9FSK1UDexfbU{B<&3o0bTKBNR>JAp?OvkpEu}?9s*qPCW%wlMU!D?EA}-tc=yPu=UxrkgiC%}yCkfGT`KGO}NfB&bRYl8jk<2aPV?iv9 Date: Fri, 24 Jun 2022 11:55:48 +0100 Subject: [PATCH 34/42] organize --- concrete_params.py => old_files/concrete_params.py | 0 .../estimate_oldparams.py | 0 {figs => old_files/figs}/iso.png | Bin {figs => old_files/figs}/plot.png | Bin {figs => old_files/figs}/plot2.png | Bin {figs => old_files/figs}/sieve.png | Bin {figs => old_files/figs}/uSVP.png | Bin hybrid_decoding.py => old_files/hybrid_decoding.py | 0 {memory_tests => old_files/memory_tests}/test.py | 0 {memory_tests => old_files/memory_tests}/test2.py | 0 scripts.py => old_files/scripts.py | 0 11 files changed, 0 insertions(+), 0 deletions(-) rename concrete_params.py => old_files/concrete_params.py (100%) rename estimate_oldparams.py => old_files/estimate_oldparams.py (100%) rename {figs => old_files/figs}/iso.png (100%) rename {figs => old_files/figs}/plot.png (100%) rename {figs => old_files/figs}/plot2.png (100%) rename {figs => old_files/figs}/sieve.png (100%) rename {figs => old_files/figs}/uSVP.png (100%) rename hybrid_decoding.py => old_files/hybrid_decoding.py (100%) rename {memory_tests => old_files/memory_tests}/test.py (100%) rename {memory_tests => old_files/memory_tests}/test2.py (100%) rename scripts.py => old_files/scripts.py (100%) diff --git a/concrete_params.py b/old_files/concrete_params.py similarity index 100% rename from concrete_params.py rename to old_files/concrete_params.py diff --git a/estimate_oldparams.py b/old_files/estimate_oldparams.py similarity index 100% rename from estimate_oldparams.py rename to old_files/estimate_oldparams.py diff --git a/figs/iso.png b/old_files/figs/iso.png similarity index 100% rename from figs/iso.png rename to old_files/figs/iso.png diff --git a/figs/plot.png b/old_files/figs/plot.png similarity index 100% rename from figs/plot.png rename to old_files/figs/plot.png diff --git a/figs/plot2.png b/old_files/figs/plot2.png similarity index 100% rename from figs/plot2.png rename to old_files/figs/plot2.png diff --git a/figs/sieve.png b/old_files/figs/sieve.png similarity index 100% rename from figs/sieve.png rename to old_files/figs/sieve.png diff --git a/figs/uSVP.png b/old_files/figs/uSVP.png similarity index 100% rename from figs/uSVP.png rename to old_files/figs/uSVP.png diff --git a/hybrid_decoding.py b/old_files/hybrid_decoding.py similarity index 100% rename from hybrid_decoding.py rename to old_files/hybrid_decoding.py diff --git a/memory_tests/test.py b/old_files/memory_tests/test.py similarity index 100% rename from memory_tests/test.py rename to old_files/memory_tests/test.py diff --git a/memory_tests/test2.py b/old_files/memory_tests/test2.py similarity index 100% rename from memory_tests/test2.py rename to old_files/memory_tests/test2.py diff --git a/scripts.py b/old_files/scripts.py similarity index 100% rename from scripts.py rename to old_files/scripts.py From 004c576ad73b22a5bc922f4130a0946eb90b0fe7 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 24 Jun 2022 13:30:13 +0100 Subject: [PATCH 35/42] update files --- generate_data.py | 187 +++++++++++++++++++++++++++++++++++++++++++++++ job.sh | 108 +++++++++++++-------------- 2 files changed, 241 insertions(+), 54 deletions(-) create mode 100644 generate_data.py diff --git a/generate_data.py b/generate_data.py new file mode 100644 index 000000000..28a6848b1 --- /dev/null +++ b/generate_data.py @@ -0,0 +1,187 @@ +from estimator_new import * +from sage.all import oo, save, load, ceil +from math import log2 +import multiprocessing + + +def old_models(security_level, sd, logq=32): + """ + Use the old model as a starting point for the data gathering step + :param security_level: the security level under consideration + :param sd : the standard deviation of the LWE error distribution Xe + :param logq : the (base 2 log) value of the LWE modulus q + """ + + def evaluate_model(a, b, stddev=sd): + return (stddev - b)/a + + models = dict() + + models["80"] = (-0.04049295502947623, 1.1288318226557081 + logq) + models["96"] = (-0.03416314056943681, 1.4704806061716345 + logq) + models["112"] = (-0.02970984362676178, 1.7848907787798667 + logq) + models["128"] = (-0.026361288425133814, 2.0014671315214696 + logq) + models["144"] = (-0.023744534465622812, 2.1710601038230712 + logq) + models["160"] = (-0.021667220727651954, 2.3565507936475476 + logq) + models["176"] = (-0.019947662046189942, 2.5109588704235803 + logq) + models["192"] = (-0.018552804646747204, 2.7168913723130816 + logq) + models["208"] = (-0.017291091126923574, 2.7956961446214326 + logq) + models["224"] = (-0.016257546811508806, 2.9582401000615226 + logq) + models["240"] = (-0.015329741032015766, 3.0744579055889782 + logq) + models["256"] = (-0.014530554319171845, 3.2094375376751745 + logq) + + (a, b) = models["{}".format(security_level)] + n_est = evaluate_model(a, b, sd) + + return round(n_est) + + +def estimate(params, red_cost_model=RC.BDGL16, skip=("arora-gb", "bkw")): + """ + Retrieve an estimate using the Lattice Estimator, for a given set of input parameters + :param params: the input LWE parameters + :param red_cost_model: the lattice reduction cost model + :param skip: attacks to skip + """ + + est = LWE.estimate(params, red_cost_model=red_cost_model, deny_list=skip) + + return est + + +def get_security_level(est, dp=2): + """ + Get the security level lambda from a Lattice Estimator output + :param est: the Lattice Estimator output + :param dp: the number of decimal places to consider + """ + attack_costs = [] + # note: key does not need to be specified est vs est.keys() + for key in est: + attack_costs.append(est[key]["rop"]) + # get the security level correct to 'dp' decimal places + security_level = round(log2(min(attack_costs)), dp) + + return security_level + + +def inequality(x, y): + """ A utility function which compresses the conditions x < y and x > y into a single condition via a multiplier + :param x: the LHS of the inequality + :param y: the RHS of the inequality + """ + if x <= y: + return 1 + + if x > y: + return -1 + + +def automated_param_select_n(params, target_security=128): + """ A function used to generate the smallest value of n which allows for + target_security bits of security, for the input values of (params.Xe.stddev,params.q) + :param params: the standard deviation of the error + :param target_security: the target number of bits of security, 128 is default + + EXAMPLE: + sage: X = automated_param_select_n(Kyber512, target_security = 128) + sage: X + 456 + """ + + # get an estimate based on the prev. model + print("n = {}".format(params.n)) + n_start = old_models(target_security, log2(params.Xe.stddev), log2(params.q)) + # n_start = max(n_start, 450) + # TODO: think about throwing an error if the required n < 450 + + params = params.updated(n=n_start) + costs2 = estimate(params) + security_level = get_security_level(costs2, 2) + z = inequality(security_level, target_security) + + # we keep n > 2 * target_security as a rough baseline for mitm security (on binary key guessing) + while z * security_level < z * target_security: + # TODO: fill in this case! For n > 1024 we only need to consider every 256 (optimization) + params = params.updated(n = params.n + z * 8) + costs = estimate(params) + security_level = get_security_level(costs, 2) + + if -1 * params.Xe.stddev > 0: + print("target security level is unattainable") + break + + # final estimate (we went too far in the above loop) + if security_level < target_security: + # we make n larger + print("we make n larger") + params = params.updated(n=params.n + 8) + costs = estimate(params) + security_level = get_security_level(costs, 2) + + print("the finalised parameters are n = {}, log2(sd) = {}, log2(q) = {}, with a security level of {}-bits".format(params.n, + log2(params.Xe.stddev), + log2(params.q), + security_level)) + + if security_level < target_security: + params.updated(n=None) + + return params, security_level + + +def generate_parameter_matrix(params_in, sd_range, target_security_levels=[128], name="default_name"): + """ + :param params_in: a initial set of LWE parameters + :param sd_range: a tuple (sd_min, sd_max) giving the values of sd for which to generate parameters + :param target_security_levels: a list of the target number of bits of security, 128 is default + :param name: a name to save the file + """ + + (sd_min, sd_max) = sd_range + for lam in target_security_levels: + for sd in range(sd_min, sd_max + 1): + print("run for {}".format(lam, sd)) + Xe_new = nd.NoiseDistribution.DiscreteGaussian(2**sd) + (params_out, sec) = automated_param_select_n(params_in.updated(Xe=Xe_new), target_security=lam) + + try: + results = load("{}.sobj".format(name)) + except: + results = dict() + results["{}".format(lam)] = [] + + results["{}".format(lam)].append((params_out.n, log2(params_out.q), log2(params_out.Xe.stddev), sec)) + save(results, "{}.sobj".format(name)) + + return results + + +def generate_zama_curves64(sd_range=[2, 58], target_security_levels=[128], name="default_name"): + """ + The top level function which we use to run the experiment + + :param sd_range: a tuple (sd_min, sd_max) giving the values of sd for which to generate parameters + :param target_security_levels: a list of the target number of bits of security, 128 is default + :param name: a name to save the file + """ + if __name__ == '__main__': + + D = ND.DiscreteGaussian + vals = range(sd_range[0], sd_range[1]) + pool = multiprocessing.Pool(2) + init_params = LWE.Parameters(n=1024, q=2 ** 64, Xs=D(0.50, -0.50), Xe=D(2 ** 55), m=oo, tag='params') + inputs = [(init_params, (val, val), target_security_levels, name) for val in vals] + res = pool.starmap(generate_parameter_matrix, inputs) + + return "done" + + +# The script runs the following commands +import sys +# grab values of the command-line input arguments +a = int(sys.argv[1]) +b = int(sys.argv[2]) +c = int(sys.argv[3]) +# run the code +generate_zama_curves64(sd_range= (b,c), target_security_levels=[a], name="{}".format(a)) \ No newline at end of file diff --git a/job.sh b/job.sh index 036d9b610..def3e07a2 100755 --- a/job.sh +++ b/job.sh @@ -1,66 +1,66 @@ #!/bin/sh # 80-bits -#sage new_scripts.py 80 2 12 -#sage new_scripts.py 80 12 22 -#sage new_scripts.py 80 22 32 -#sage new_scripts.py 80 32 42 -#sage new_scripts.py 80 42 52 -#sage new_scripts.py 80 52 59 +sage generate_data.py 80 2 12 +sage generate_data.py 80 12 22 +sage generate_data.py 80 22 32 +sage generate_data.py 80 32 42 +sage generate_data.py 80 42 52 +sage generate_data.py 80 52 59 # 96-bits -sage new_scripts.py 96 2 12 -sage new_scripts.py 96 12 22 -sage new_scripts.py 96 22 32 -sage new_scripts.py 96 32 42 -sage new_scripts.py 96 42 52 -sage new_scripts.py 96 52 59 +sage generate_data.py 96 2 12 +sage generate_data.py 96 12 22 +sage generate_data.py 96 22 32 +sage generate_data.py 96 32 42 +sage generate_data.py 96 42 52 +sage generate_data.py 96 52 59 # 112-bits -sage new_scripts.py 112 2 12 -sage new_scripts.py 112 12 22 -sage new_scripts.py 112 22 32 -sage new_scripts.py 112 32 42 -sage new_scripts.py 112 42 52 -sage new_scripts.py 112 52 59 +sage generate_data.py 112 2 12 +sage generate_data.py 112 12 22 +sage generate_data.py 112 22 32 +sage generate_data.py 112 32 42 +sage generate_data.py 112 42 52 +sage generate_data.py 112 52 59 # 128-bits -#sage new_scripts.py 128 2 12 -#sage new_scripts.py 128 12 22 -#sage new_scripts.py 128 22 32 -#sage new_scripts.py 128 32 42 -#sage new_scripts.py 128 42 52 -#sage new_scripts.py 128 52 59 +sage generate_data.py 128 2 12 +sage generate_data.py 128 12 22 +sage generate_data.py 128 22 32 +sage generate_data.py 128 32 42 +sage generate_data.py 128 42 52 +sage generate_data.py 128 52 59 # 144-bits -sage new_scripts.py 144 2 12 -sage new_scripts.py 144 12 22 -sage new_scripts.py 144 22 32 -sage new_scripts.py 144 32 42 -sage new_scripts.py 144 42 52 -sage new_scripts.py 144 52 59 +sage generate_data.py 144 2 12 +sage generate_data.py 144 12 22 +sage generate_data.py 144 22 32 +sage generate_data.py 144 32 42 +sage generate_data.py 144 42 52 +sage generate_data.py 144 52 59 # 160-bits -sage new_scripts.py 160 2 12 -sage new_scripts.py 160 12 22 -sage new_scripts.py 160 22 32 -sage new_scripts.py 160 32 42 -sage new_scripts.py 160 42 52 -sage new_scripts.py 160 52 59 +sage generate_data.py 160 2 12 +sage generate_data.py 160 12 22 +sage generate_data.py 160 22 32 +sage generate_data.py 160 32 42 +sage generate_data.py 160 42 52 +sage generate_data.py 160 52 59 # 176-bits -sage new_scripts.py 176 2 12 -sage new_scripts.py 176 12 22 -sage new_scripts.py 176 22 32 -sage new_scripts.py 176 32 42 -sage new_scripts.py 176 42 52 -sage new_scripts.py 176 52 59 +sage generate_data.py 176 2 12 +sage generate_data.py 176 12 22 +sage generate_data.py 176 22 32 +sage generate_data.py 176 32 42 +sage generate_data.py 176 42 52 +sage generate_data.py 176 52 59 # 192-bits -#sage new_scripts.py 192 2 12 -#sage new_scripts.py 192 12 22 -#sage new_scripts.py 192 22 32 -#sage new_scripts.py 192 32 42 -#sage new_scripts.py 192 42 52 -#sage new_scripts.py 192 52 59 +sage generate_data.py 192 2 12 +sage generate_data.py 192 12 22 +sage generate_data.py 192 22 32 +sage generate_data.py 192 32 42 +sage generate_data.py 192 42 52 +sage generate_data.py 192 52 59 # 256-bits -#sage new_scripts.py 256 2 12 -#sage new_scripts.py 256 12 22 -#sage new_scripts.py 256 22 32 -#sage new_scripts.py 256 32 42 -#sage new_scripts.py 256 42 52 -#sage new_scripts.py 256 52 59 +sage generate_data.py 256 2 12 +sage generate_data.py 256 12 22 +sage generate_data.py 256 22 32 +sage generate_data.py 256 32 42 +sage generate_data.py 256 42 52 +sage generate_data.py 256 52 59 From 6d68bd8d6a23f1e813e1eef30e8c99f196255b0f Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 24 Jun 2022 13:31:09 +0100 Subject: [PATCH 36/42] updates --- new_scripts.py | 2 +- verify_curves.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/new_scripts.py b/new_scripts.py index 20e7fc265..db1543550 100644 --- a/new_scripts.py +++ b/new_scripts.py @@ -1,5 +1,5 @@ from estimator_new import * -from sage.all import oo, save, load +from sage.all import oo, save, load, ceil from math import log2 import multiprocessing diff --git a/verify_curves.py b/verify_curves.py index 7773591a4..bad73c93c 100644 --- a/verify_curves.py +++ b/verify_curves.py @@ -1,5 +1,6 @@ import numpy as np -from sage.all import save, load +from sage.all import save, load, ceil + def sort_data(security_level): from operator import itemgetter @@ -15,6 +16,7 @@ def sort_data(security_level): return X + def generate_curve(security_level): # step 1. get the data @@ -90,6 +92,6 @@ def generate_and_verify(security_levels, log_q, name = "verified_curves"): return data -# To verify the curves we use -generate_and_verify([80, 96, 112, 128, 144, 160, 176, 192, 256], log_q = 64) +data = generate_and_verify([80, 96, 112, 128, 144, 160, 176, 192, 256], log_q = 64) +print(data) From 301caec2e85bc58195cf1bab1b63ea27c6619223 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 24 Jun 2022 13:33:13 +0100 Subject: [PATCH 37/42] move old file --- new_scripts.py => old_files/new_scripts.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename new_scripts.py => old_files/new_scripts.py (100%) diff --git a/new_scripts.py b/old_files/new_scripts.py similarity index 100% rename from new_scripts.py rename to old_files/new_scripts.py From fd1c577bcf9da18346b19b852eb730f753a889f2 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 24 Jun 2022 13:34:04 +0100 Subject: [PATCH 38/42] add verified curves --- verified_curves.sobj | Bin 0 -> 670 bytes verified_curves.txt | 9 +++++++++ 2 files changed, 9 insertions(+) create mode 100644 verified_curves.sobj create mode 100644 verified_curves.txt diff --git a/verified_curves.sobj b/verified_curves.sobj new file mode 100644 index 0000000000000000000000000000000000000000..546a32e51814a52cf0cb7db3b53badd39bc666ce GIT binary patch literal 670 zcmV;P0%84loK=$9Pg6k@hr0mE1?q;Vh$|>np^6&_C>M9RQ1IYVH>9@3qGkD&@<337 zm<%Es6>tlP;P#*o;_{*~)|~l|{0DSKYI3~~lbbW&@0&9xGvK-ahu0hG?Ct38^M$(N z5no4dEYTi}$Af)FPbe4*#tk^<_Kk3&uRCJE6>vEmjEjYMYyp+rZ8Q zmU>g!ELAVL-dik3`*}tkmZy`;2+IXl5b{%0wxZ-Tzvah#zo*b)Vx`6k2&)8E6V_O* z(K+whe_nkLImGYyYngl&3XppsCP0u4Rzyj=Op#Xr(bRBLE2VV^(^!L%Nv#I^R8 z<((paxI%tDpk|oFejPbLI4E$4aM(7B)-&=+K7ZiBc_xl%>L}ruKpnxdrj_`Y64(FN z@szyV$kY5S$m7b~pfi3#qd*hkxP2HrDWCIfjE6Ezkj9z`Cj?FsPFb@`UF=HWwEbZO z8fw#d!oy?A8_gtG$Y2 Date: Fri, 24 Jun 2022 13:43:51 +0100 Subject: [PATCH 39/42] tidy repo --- README.rst | 45 +++++++++++++++++-------------------- data/{v1 => v0.2}/112.sobj | Bin data/{v1 => v0.2}/128.sobj | Bin data/{v1 => v0.2}/144.sobj | Bin data/{v1 => v0.2}/160.sobj | Bin data/{v1 => v0.2}/176.sobj | Bin data/{v1 => v0.2}/192.sobj | Bin data/{v1 => v0.2}/256.sobj | Bin data/{v1 => v0.2}/80.sobj | Bin data/{v1 => v0.2}/96.sobj | Bin 10 files changed, 21 insertions(+), 24 deletions(-) rename data/{v1 => v0.2}/112.sobj (100%) rename data/{v1 => v0.2}/128.sobj (100%) rename data/{v1 => v0.2}/144.sobj (100%) rename data/{v1 => v0.2}/160.sobj (100%) rename data/{v1 => v0.2}/176.sobj (100%) rename data/{v1 => v0.2}/192.sobj (100%) rename data/{v1 => v0.2}/256.sobj (100%) rename data/{v1 => v0.2}/80.sobj (100%) rename data/{v1 => v0.2}/96.sobj (100%) diff --git a/README.rst b/README.rst index b194a4561..017ab8e77 100644 --- a/README.rst +++ b/README.rst @@ -3,12 +3,12 @@ Parameter curves for Concrete This Github repository contains the code needed to generate the Parameter curves used inside Zama. The repository contains the following files: -- cpp/, Python scripts to generate a cpp file containing the parameter curves +- cpp/, Python scripts to generate a cpp file containing the parameter curves (needs updating) - data/, a folder containing the data generated for previous curves. -- estimator/, Zama's internal version of the LWE Estimator -- figs/, a folder containing various figures related to the parameter curves -- scripts.py, a copy of all scripts required to generate the parameter curves -- a variety of other python files, used for estimating the security of previous Concrete parameter sets +- estimator_new/, the Lattice estimator (TODO: add as a submodule and use dependabot to alert for new commits) +- old_files/, legacy files used for previous versions +- generate_data.py, functions to gather raw data from the lattice estimator +- verifiy_curves.py, functions to generate and verify curves from raw data .. image:: logo.svg :align: center @@ -20,13 +20,16 @@ Example This is an example of how to generate the parameter curves, and save them to file. :: - - sage: load("scripts.py") - sage: results = get_zama_curves() - sage: save(results, "v0.sobj") + ./job.sh :: -We can load results files, and find the interpolants. +This will generate several data files, {80, 96, 112, 128, 144, 160, 176, 192, 256}.sobj + +To generate the parameter curves from the data files, we run + +`sage verify_curves.py` + +this will generate a list of the form: :: @@ -41,22 +44,15 @@ We can load results files, and find the interpolants. (-0.014606812351714953, 3.8493629234693003, 256, 'PASS', 826)] :: -Finding the value of n_{alpha} is done manually. We can also verify the interpolants which are generated at the same time: +each element is a tuple (a, b, security, P, n_min), where (a,b) are the model +parameters, security is the security level, P is a boolean value denoting PASS or +FAIL of the verification, and n_min is the smallest reccomended value of `n` to be used. -:: +Each model outputs a value of sigma, and is of the form: - # verify the interpolant used for lambda = 256 (which is interps[-1]) - sage: z = verify_interpolants(interps[-1], (128,2048), 64) - [... code runs, can take ~10 mins ...] - # find the index corresponding to n_alpha, which is where security drops below the target security level (256 here) - sage: n_alpha = find_nalpha(z, 256) - 653 - - # so the model in this case is - (-0.014327640360322604, 2.899270827311096, 653) - # which corresponds to - # sd(n) = max(-0.014327640360322604 * n + 2.899270827311096, -logq + 2), n >= 653 -:: +`f(a, b, n) = max(ceil(a * n + b), -log2(q) + 2)` + +where the -log2(q) + 2 term ensures that we are always using at least two bits of noise. Version History ------------------- @@ -67,6 +63,7 @@ Data for the curves are kept in /data. The following files are present: v0: generated using the {usvp, dual, decoding} attacks v0.1: generated using the {mitm, usvp, dual, decoding} attacks + v0.2: generated using the lattice estimator :: TODO List diff --git a/data/v1/112.sobj b/data/v0.2/112.sobj similarity index 100% rename from data/v1/112.sobj rename to data/v0.2/112.sobj diff --git a/data/v1/128.sobj b/data/v0.2/128.sobj similarity index 100% rename from data/v1/128.sobj rename to data/v0.2/128.sobj diff --git a/data/v1/144.sobj b/data/v0.2/144.sobj similarity index 100% rename from data/v1/144.sobj rename to data/v0.2/144.sobj diff --git a/data/v1/160.sobj b/data/v0.2/160.sobj similarity index 100% rename from data/v1/160.sobj rename to data/v0.2/160.sobj diff --git a/data/v1/176.sobj b/data/v0.2/176.sobj similarity index 100% rename from data/v1/176.sobj rename to data/v0.2/176.sobj diff --git a/data/v1/192.sobj b/data/v0.2/192.sobj similarity index 100% rename from data/v1/192.sobj rename to data/v0.2/192.sobj diff --git a/data/v1/256.sobj b/data/v0.2/256.sobj similarity index 100% rename from data/v1/256.sobj rename to data/v0.2/256.sobj diff --git a/data/v1/80.sobj b/data/v0.2/80.sobj similarity index 100% rename from data/v1/80.sobj rename to data/v0.2/80.sobj diff --git a/data/v1/96.sobj b/data/v0.2/96.sobj similarity index 100% rename from data/v1/96.sobj rename to data/v0.2/96.sobj From 1169d029991bfa973741c5f1ebef4a0107373f79 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 24 Jun 2022 13:48:44 +0100 Subject: [PATCH 40/42] remove todos which have been completed, update README --- README.rst | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/README.rst b/README.rst index 017ab8e77..4f94197b2 100644 --- a/README.rst +++ b/README.rst @@ -20,6 +20,7 @@ Example This is an example of how to generate the parameter curves, and save them to file. :: + ./job.sh :: @@ -50,7 +51,10 @@ FAIL of the verification, and n_min is the smallest reccomended value of `n` to Each model outputs a value of sigma, and is of the form: -`f(a, b, n) = max(ceil(a * n + b), -log2(q) + 2)` +:: + + f(a, b, n) = max(ceil(a * n + b), -log2(q) + 2) +:: where the -log2(q) + 2 term ensures that we are always using at least two bits of noise. @@ -66,12 +70,4 @@ Data for the curves are kept in /data. The following files are present: v0.2: generated using the lattice estimator :: -TODO List -------------------- -There are several updates which are still required. - 1. Consider Hybrid attacks (WIP, Michael + Ben are coding up hybrid-dual/hybrid-decoding estimates) - 2. CI/CD stuff for new pushes to the external LWE Estimator. - 3. Fully automate the process of finding n_{alpha} for each curve. - 4. Functionality for q =! 64? This is covered by the curve, but we currently don't account for it in the models, and it needs to be done manually. - 5. cpp file generation From c37a16512a290a4cc65630175062c60ba1496c71 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 24 Jun 2022 13:52:27 +0100 Subject: [PATCH 41/42] pep8 --- generate_data.py | 28 ++++++++++++++++++---------- verify_curves.py | 23 ++++++++++++----------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/generate_data.py b/generate_data.py index 28a6848b1..26a0e933e 100644 --- a/generate_data.py +++ b/generate_data.py @@ -1,3 +1,4 @@ +import sys from estimator_new import * from sage.all import oo, save, load, ceil from math import log2 @@ -91,7 +92,8 @@ def automated_param_select_n(params, target_security=128): # get an estimate based on the prev. model print("n = {}".format(params.n)) - n_start = old_models(target_security, log2(params.Xe.stddev), log2(params.q)) + n_start = old_models(target_security, log2( + params.Xe.stddev), log2(params.q)) # n_start = max(n_start, 450) # TODO: think about throwing an error if the required n < 450 @@ -103,7 +105,7 @@ def automated_param_select_n(params, target_security=128): # we keep n > 2 * target_security as a rough baseline for mitm security (on binary key guessing) while z * security_level < z * target_security: # TODO: fill in this case! For n > 1024 we only need to consider every 256 (optimization) - params = params.updated(n = params.n + z * 8) + params = params.updated(n=params.n + z * 8) costs = estimate(params) security_level = get_security_level(costs, 2) @@ -120,8 +122,10 @@ def automated_param_select_n(params, target_security=128): security_level = get_security_level(costs, 2) print("the finalised parameters are n = {}, log2(sd) = {}, log2(q) = {}, with a security level of {}-bits".format(params.n, - log2(params.Xe.stddev), - log2(params.q), + log2( + params.Xe.stddev), + log2( + params.q), security_level)) if security_level < target_security: @@ -143,7 +147,8 @@ def generate_parameter_matrix(params_in, sd_range, target_security_levels=[128], for sd in range(sd_min, sd_max + 1): print("run for {}".format(lam, sd)) Xe_new = nd.NoiseDistribution.DiscreteGaussian(2**sd) - (params_out, sec) = automated_param_select_n(params_in.updated(Xe=Xe_new), target_security=lam) + (params_out, sec) = automated_param_select_n( + params_in.updated(Xe=Xe_new), target_security=lam) try: results = load("{}.sobj".format(name)) @@ -151,7 +156,8 @@ def generate_parameter_matrix(params_in, sd_range, target_security_levels=[128], results = dict() results["{}".format(lam)] = [] - results["{}".format(lam)].append((params_out.n, log2(params_out.q), log2(params_out.Xe.stddev), sec)) + results["{}".format(lam)].append( + (params_out.n, log2(params_out.q), log2(params_out.Xe.stddev), sec)) save(results, "{}.sobj".format(name)) return results @@ -170,18 +176,20 @@ def generate_zama_curves64(sd_range=[2, 58], target_security_levels=[128], name= D = ND.DiscreteGaussian vals = range(sd_range[0], sd_range[1]) pool = multiprocessing.Pool(2) - init_params = LWE.Parameters(n=1024, q=2 ** 64, Xs=D(0.50, -0.50), Xe=D(2 ** 55), m=oo, tag='params') - inputs = [(init_params, (val, val), target_security_levels, name) for val in vals] + init_params = LWE.Parameters( + n=1024, q=2 ** 64, Xs=D(0.50, -0.50), Xe=D(2 ** 55), m=oo, tag='params') + inputs = [(init_params, (val, val), target_security_levels, name) + for val in vals] res = pool.starmap(generate_parameter_matrix, inputs) return "done" # The script runs the following commands -import sys # grab values of the command-line input arguments a = int(sys.argv[1]) b = int(sys.argv[2]) c = int(sys.argv[3]) # run the code -generate_zama_curves64(sd_range= (b,c), target_security_levels=[a], name="{}".format(a)) \ No newline at end of file +generate_zama_curves64(sd_range=(b, c), target_security_levels=[ + a], name="{}".format(a)) diff --git a/verify_curves.py b/verify_curves.py index bad73c93c..9dfe15ab1 100644 --- a/verify_curves.py +++ b/verify_curves.py @@ -9,7 +9,7 @@ def sort_data(security_level): X = load("{}.sobj".format(security_level)) # step 2. sort by SD - x = sorted(X["{}".format(security_level)], key = itemgetter(2)) + x = sorted(X["{}".format(security_level)], key=itemgetter(2)) # step3. replace the sorted value X["{}".format(security_level)] = x @@ -28,14 +28,14 @@ def generate_curve(security_level): for x in X["{}".format(security_level)]: N.append(x[0]) SD.append(x[2] + 0.5) - + # step 3. perform interpolation and return coefficients - (a,b) = np.polyfit(N, SD, 1) + (a, b) = np.polyfit(N, SD, 1) return a, b - -def verify_curve(security_level, a = None, b = None): + +def verify_curve(security_level, a=None, b=None): # step 1. get the table and max values of n, sd X = sort_data(security_level) @@ -53,9 +53,9 @@ def verify_curve(security_level, a = None, b = None): if n < n_val: pass else: - j = i + j = i break - + # now j is the correct index, we return the corresponding sd return table[j][2] @@ -67,7 +67,7 @@ def verify_curve(security_level, a = None, b = None): for n in range(n_max, n_min, - 1): model_sd = f_model(a, b, n) table_sd = f_table(X["{}".format(security_level)], n) - print(n , table_sd, model_sd, model_sd >= table_sd) + print(n, table_sd, model_sd, model_sd >= table_sd) if table_sd > model_sd: print("MODEL FAILS at n = {}".format(n)) @@ -76,7 +76,7 @@ def verify_curve(security_level, a = None, b = None): return "PASS", n_min -def generate_and_verify(security_levels, log_q, name = "verified_curves"): +def generate_and_verify(security_levels, log_q, name="verified_curves"): data = [] @@ -89,9 +89,10 @@ def generate_and_verify(security_levels, log_q, name = "verified_curves"): # append the information into a list data.append((a_sec, b_sec - log_q, sec, res[0], res[1])) save(data, "{}.sobj".format(name)) - + return data -data = generate_and_verify([80, 96, 112, 128, 144, 160, 176, 192, 256], log_q = 64) +data = generate_and_verify( + [80, 96, 112, 128, 144, 160, 176, 192, 256], log_q=64) print(data) From fc02c989993dd48fc4711508182b5e41d263b471 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 24 Jun 2022 13:55:41 +0100 Subject: [PATCH 42/42] Update pep8.yml --- .github/workflows/pep8.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pep8.yml b/.github/workflows/pep8.yml index f4656a9a2..d5d0aea9e 100644 --- a/.github/workflows/pep8.yml +++ b/.github/workflows/pep8.yml @@ -19,4 +19,5 @@ jobs: - name: PEP8 run: | pip install --upgrade pyproject-flake8 - flake8 new_scripts.py + flake8 generate_data.py + flake8 verify_curves.py