Commit ddce2c42 authored by Antoine Douteau's avatar Antoine Douteau
Browse files

Modification scripts

parent 774758dd
Loading
Loading
Loading
Loading
+2 −2
Changes for README.md: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -18,9 +18,9 @@ Using the `scripts` files, the user can manually generate the complete list of c
Clone the repository
--------------------

As our code exploits the actual structure of the code from the [LaZer library](https://github.com/lazer-crypto/lazer), 
As our code exploits the actual structure of the code from the [LaZer library](https://github.com/lazer-crypto/lazer) and from the [LWE-estimator](https://github.com/malb/lattice-estimator).
we manage to use and link the github repository from the Library directly in ours.
Then, in order to have the entire list of files from our code with the [LaZer library](https://github.com/lazer-crypto/lazer), run:
Then, in order to have the entire list of files from our code with the libraries, run:

`git clone --recursive git@github.com:rejection-free/rejection-free-framework-under-Hint-MLWE.git`

+18 −18
Changes for scripts/Makefile: 18 added lines, 18 removed lines.
Original line number Diff line number Diff line
@@ -10,27 +10,27 @@ params-setup:
	

params-abdlop: params-setup
	sage modified-abdlop-codegen.sage ../params/params1.sage > ../tests/modified-abdlop-params1.h
	sage modified-abdlop-codegen.sage ../params/params2.sage > ../tests/modified-abdlop-params2.h
	sage modified-abdlop-codegen.sage ../params/params3.sage > ../tests/modified-abdlop-params3.h
	sage modified-abdlop-codegen.sage ../params/params4.sage > ../tests/modified-abdlop-params4.h
	sage modified-abdlop-codegen.sage ../params/params5.sage > ../tests/modified-abdlop-params5.h
	sage rf_abdlop_param.sage ../params/params1.sage > ../tests/modified-abdlop-params1.h
	sage rf_abdlop_param.sage ../params/params2.sage > ../tests/modified-abdlop-params2.h
	sage rf_abdlop_param.sage ../params/params3.sage > ../tests/modified-abdlop-params3.h
	sage rf_abdlop_param.sage ../params/params4.sage > ../tests/modified-abdlop-params4.h
	sage rf_abdlop_param.sage ../params/params5.sage > ../tests/modified-abdlop-params5.h

	rm modified-abdlop-codegen.sage.py
	rm rf_abdlop_param.sage.py

params-quad: params-setup
	sage modified-quad-codegen.sage ../params/params1.sage > ../tests/modified-quad-params1.h
	sage modified-quad-codegen.sage ../params/params2.sage > ../tests/modified-quad-params2.h
	sage modified-quad-codegen.sage ../params/params3.sage > ../tests/modified-quad-params3.h
	sage modified-quad-codegen.sage ../params/params4.sage > ../tests/modified-quad-params4.h
	sage modified-quad-codegen.sage ../params/params5.sage > ../tests/modified-quad-params5.h
	sage rf_quad_param.sage ../params/params1.sage > ../tests/modified-quad-params1.h
	sage rf_quad_param.sage ../params/params2.sage > ../tests/modified-quad-params2.h
	sage rf_quad_param.sage ../params/params3.sage > ../tests/modified-quad-params3.h
	sage rf_quad_param.sage ../params/params4.sage > ../tests/modified-quad-params4.h
	sage rf_quad_param.sage ../params/params5.sage > ../tests/modified-quad-params5.h

	rm modified-quad-codegen.sage.py
	rm rf_quad_param.sage.py

params-many: params-setup
	sage modified-quad-eval-codegen.sage ../params/params1.sage > ../tests/modified-quad-eval-params1.h
	sage modified-quad-eval-codegen.sage ../params/params2.sage > ../tests/modified-quad-eval-params2.h
	sage modified-quad-eval-codegen.sage ../params/params3.sage > ../tests/modified-quad-eval-params3.h
	sage modified-quad-eval-codegen.sage ../params/params4.sage > ../tests/modified-quad-eval-params4.h
	sage modified-quad-eval-codegen.sage ../params/params5.sage > ../tests/modified-quad-eval-params5.h
	rm modified-quad-eval-codegen.sage.py
 No newline at end of file
	sage rf_quad_eval_param.sage ../params/params1.sage > ../tests/modified-quad-eval-params1.h
	sage rf_quad_eval_param.sage ../params/params2.sage > ../tests/modified-quad-eval-params2.h
	sage rf_quad_eval_param.sage ../params/params3.sage > ../tests/modified-quad-eval-params3.h
	sage rf_quad_eval_param.sage ../params/params4.sage > ../tests/modified-quad-eval-params4.h
	sage rf_quad_eval_param.sage ../params/params5.sage > ../tests/modified-quad-eval-params5.h
	rm rf_quad_eval_param.sage.py
 No newline at end of file
Compare 374f0733 to 374f0733
Changes for scripts/lattice-estimator: 0 added lines, 1 removed line.
Original line number Diff line number Diff line
Subproject commit 374f07331e6575d1856b2212f3b8aeac96e0295e
+159 −134
Changes for scripts/rf_abdlop_param.sage: 159 added lines, 134 removed lines.
Original line number Diff line number Diff line
@@ -8,112 +8,110 @@ from estimator import *

# We do not claim the knowledge of this script and only modify the existant ones from the script subdirectory from the LaZer Library

mp.mp.prec = 512
mp.mp.prec = 512 # precision for mp
prec = 8  # precision for nstr

assert len(sys.argv) == 2
params_file = sys.argv[1]

load("codegen.sage")
load("common_code.sage")
blockPrint()
loaded = 1
verbose = 1
code = 1
# alpha_1 and alpha_2 (bounds for the binding property)
def alpha_1():
    global sigma_1
    global m_1
    global d
    global b
    global k
    return (b + 1) * sigma_1 * mp.sqrt(k * m_1 * d)

def smoothing_param(dimension_lattice, lambda_n_lattice, eps):
    bound = sqrt(ln(2*dimension_lattice * (1 + 1/eps))/pi)
    return bound * lambda_n_lattice
def alpha_2():
    global sigma_2
    global m_2
    global d
    global b
    return (b + 1) * sigma_2 * mp.sqrt(m_2 * d)

def smoothing_param_bound(dim, cst, eps):
    bound = sqrt(ln(2*dim * (1 + 1/eps))/pi)
    return ceil(bound * cst)
# beta_1 and beta_2 (bounds for the knowledge soudness)
def beta_1():
    global sigma_1
    global m_1
    global d
    global b
    global k
    global eta
    global frak_s_1
    return (b + 1) * (eta * sigma_1 + mp.sqrt(2) * frak_s_1) * mp.sqrt(k * m_1 * d)

# bound B
def Bound_():
    global stdev2
    global m2
def beta_2():
    global sigma_2
    global m_2
    global d
    global b
    global eta
    global D
    global kmsis
    global gamma
    return stdev2 * mp.sqrt(2 * m2 * d) + mpf(eta) * 2 ** (D-1) * mp.sqrt(kmsis*d) + (gamma * mp.sqrt(kmsis * d))/mpf(2)
    global frak_s_2

    return (eta * sigma_2 + frak_s_2) * mp.sqrt(m_2 * d) + mpf(eta) * 2 ** (D-1) * mp.sqrt(kmsis*d) + (gamma * mp.sqrt(kmsis * d))/mpf(2)

# bound B1
def Bound1():
    global stdev1
    global m1
    global d
    return mpf(2) * stdev1 * mp.sqrt(2 * m1 * d)
# varsigma_1 and varsigma_2 (simulatability)

def varsigma_1():
    global sigma_1
    global eta
    global frak_s_1
    return ceil(mp.sqrt(1/2 * (1/(sigma_1^2) + (eta^2)/(mpf(2)*frak_s_1^2) )^(-1)))

# bound B2
def Bound2():
    return mpf(2) * Bound_()
def varsigma_2():
    global sigma_2
    global eta
    global frak_s_2
    return ceil(mp.sqrt(1/2 * (1/(sigma_2^2) + (eta^2)/(frak_s_2^2) )^(-1)))

# bound B on the extracted MSIS solution
def Bound():
# bound on the extracted MSIS solution (Binding)
def bound_binding():
    return 2 * mp.sqrt(alpha_1() ** 2 + alpha_2() ** 2)

# bound B on the extracted MSIS solution (Know. Soundness)
def bound_know_soundness():
    global eta
    return 4 * mpf(eta) * mp.sqrt(Bound1() ** 2 + Bound2() ** 2)

# Estimate the hardness of MLWE, the problem defined by: 
#  - Distinguishing if (A,As + e) from the uniform for a public matrix A in Rq^(n x n)
# It returns the root hermite factor or either the default value 2^1
def findMLWEdelta(n, d, p, stddev):
    n = n * d
    law=ND.DiscreteGaussian(stddev)
    params = LWE.Parameters(n=n,q=p,Xs = law, Xe = law, m=n)
    L = LWE.estimate.rough(params)
    try:
        delta_enum = L['usvp']['delta'] 
    except:
        delta_enum = 2
    return delta_enum
    
# Estimate the hardness of MSIS, the problem defined by: 
# - Find s != 0 such that |s| <= betasuch and resolving A*s = 0 for A in Rq^(n x m)
# It returns the root hermite factor or either the default value 2^1
def get_delta_msis(beta, n, d, q):
    log2q = log(q, 2)
    log2beta = mp.log(beta, 2)
    delta = mpf(2) ** (log2beta ** 2 / mpf(4*n*d*log2q))
    return delta
    return 8 * mpf(eta) * mp.sqrt(beta_1() ** 2 + beta_2() ** 2)

loaded = 1
# Early checks to launch the scripts

# constants, dont change
KAPPA = 128    # security param, bit security
DELTA128 = 1.0044  # root hermite factor for 128-bit security
assert len(sys.argv) == 2
params_file = sys.argv[1]

param_sec = 2^(-KAPPA)
epsilon = 2^(-param_sec)
# number of irreducible factors of X^d + 1 modulo each q_i,  q_i = 2l+1 (mod 4l)
L = 2
NADDS = 128  # chose P big enough for this many additions
### security parameters
LAMBDA = 128 
ROOT_HERMITE_128 = 1.0044 # 128-bit security 
param_sec = mpf(2^(-LAMBDA))

k = 2
load(params_file)
name = "modif_"+ name
m1 = k*(m1 + l) # We keep l as the script of parameters can be used for the lnp framework from the LaZer Library
                # We just show here that we do not need to separate bounded and unbounded message: setting m1 to (m1 + l) and l to 0
                # Third point: we enhance k * as we define the commitment scheme over the randomized encoding of size k * m1
                # and need to provide security for this length and not for m1 only
name = "rf_"+ name

m_1 = m_1 + l # We keep l as the script of parameters can be used for the lnp framework from the LaZer Library
            # We just show here that we do not need to separate bounded and unbounded message: setting m_1 to (m_1 + l) and l to 0
            # Third point: we enhance k * as we define the commitment scheme over the randomized encoding of size k * m_1
            # and need to provide security for this length and not for m_1 only      

l = 0
lext = 0

degree = k * d
### choices
k = 2
b = 2^(log2q//k)
p = b^k + 1
p = b ** k + 1
lext = 0
l = 0

if d not in [64, 128]:
    err("d not in [64,128]")
log2d = log(d, 2)
log2d = mp.log(d, 2)

D = 0       # dropping low-order bits of t_A
gamma = 0   # dropping low-order bits of w

# number of irreducible factors of X^d + 1 modulo each q_i,  q_i = 2l+1 (mod 4l)
L = 2
NADDS = 128  # chose P big enough for this many additions

# challenge space
if d == 64 and L == 2 and log2q >= 4:
    omega = 8
@@ -127,34 +125,40 @@ else:
    err("challenge space undefined")

# sample from [-omega,omega] <=> sample from [0,2*omega] - omega
omega_bits = ceil(log(2*omega+1, 2))
omega_bits = ceil(mp.log(2*omega+1, 2))

# Relations parameters : standard deviations and bounds
lambda_classic = 1
lambda_ideal_p = sqrt(p)
lambda_ideal_p = mp.sqrt(p)
# the distribution of the message s_1 is not restricted
sigma_1 = smoothing_param(m1 * degree, lambda_classic, param_sec)                            # SD of the randomized encoding function
frak_s1 = max(smoothing_param(m1 * degree, lambda_classic, param_sec)/sqrt(2),sqrt(2)/(b-1) * smoothing_param(m1 * degree, lambda_ideal_p ,param_sec))        # SD of the randomized encoding function of y_1
stdev1 = (eta*(b +1) * sigma_1 + frak_s1)  # SD of the hint z1

sigma_2 = 0                            # SD of the randomness s_2 : later (depends on length of randomness s2)
frak_s2 = 0                            # SD of y_2 : later (depends on length of randomness s2)
varsigma_2 = 0                         # SD to ensure hardness of Hint-MLWE : later (depends on length of randomness s2)
stdev2 = (eta* sigma_2 + frak_s2)      # SD of the hint z2   
### PARAMETERS FOR S1

sigma_1 = smoothing_param_bound(k * m_1 * d, lambda_classic, param_sec) # SD of the randomized encoding function

frak_s_1 = max(smoothing_param_bound(k * m_1 * d, lambda_classic, param_sec)/mp.sqrt(2),mp.sqrt(2)/(b-1) * smoothing_param_bound(m_1 * d, lambda_ideal_p,param_sec))        # SD of the randomized encoding function of y_1

while mp.sqrt(2) * (b-1) * varsigma_1() < smoothing_param_bound(k * m_1 * d, lambda_ideal_p,param_sec):
    frak_s_1 *= mp.sqrt(2)

### PARAMETERS FOR S2

kmlwe = 0           # MLWE dim, to be determined
easy_mlwe_dim = 0   # lower bound for MLWE dim
hard_mlwe_dim = 64  # guess for upper bound for MLWE dim

sigma_2 = mpf(2)*smoothing_param_bound(hard_mlwe_dim*d, lambda_classic, param_sec)                            # SD of the randomness s_2 : later (depends on length of randomness s2)
frak_s_2 = mp.sqrt(2)*smoothing_param_bound(hard_mlwe_dim*d, lambda_classic, param_sec)                           # SD of y_2 : later (depends on length of randomness s2)

# find upper actual bound (and possibly improve lower bound)
while True:
    sigma_2 = smoothing_param_bound(2*(2*hard_mlwe_dim*d), 1, param_sec)                       
    frak_s2 = smoothing_param_bound(2*m1*d, (sqrt(2**(log2q+1))/(b-1)), param_sec)
    varsigma_2 = ceil(sqrt(1/2 * (1/(sigma_2^2) + (eta^2)/(frak_s2^2) )^(-1))) 
    sigma_2 = mpf(2)*smoothing_param_bound(hard_mlwe_dim*d, lambda_classic, param_sec)                      
    frak_s_2 = mp.sqrt(2)*smoothing_param_bound(hard_mlwe_dim*d, lambda_classic, param_sec)
    while varsigma_2() < mp.sqrt(2)*smoothing_param_bound(hard_mlwe_dim*d, lambda_classic, param_sec):
        frak_s_2 *= mp.sqrt(2)                       
    delta_mlwe = max(findMLWEdelta(hard_mlwe_dim, d, 2 ** log2q, sigma_2),findMLWEdelta(hard_mlwe_dim, d, 2 ** log2q, varsigma_2()))

    delta_mlwe = max(findMLWEdelta(hard_mlwe_dim, d, 2 ** log2q, varsigma_2), findMLWEdelta(hard_mlwe_dim, d, 2 ** log2q, sigma_2))
    
    if delta_mlwe <= DELTA128:
    if delta_mlwe <= ROOT_HERMITE_128:
        print(f"MLWE dim {kmlwe} : hard")
        break
    print(f"MLWE dim {kmlwe} : easy")
@@ -164,13 +168,13 @@ while True:
# binary search for smallest MLWE dimension that is still hard
while True:
    kmlwe = (easy_mlwe_dim + hard_mlwe_dim) / 2
    sigma_2 = smoothing_param_bound(2*(2*kmlwe*d), 1, param_sec)                       
    frak_s2 = smoothing_param_bound(2*m1*d, (sqrt(2**(log2q+1))/(b-1)), param_sec)
    varsigma_2 = ceil(sqrt( 1/2 * (1/(sigma_2^2) + (eta^2)/(frak_s2^2) )^(-1)))
    
    delta_mlwe = max(findMLWEdelta(kmlwe, d, 2 ** log2q, varsigma_2),findMLWEdelta(kmlwe, d, 2 ** log2q, sigma_2))
    sigma_2 = mpf(2)*smoothing_param_bound(kmlwe*d, lambda_classic, param_sec)
    frak_s_2 = mp.sqrt(2)*smoothing_param_bound(kmlwe*d, lambda_classic, param_sec)
    while varsigma_2() < mp.sqrt(2)*smoothing_param_bound(kmlwe*d, lambda_classic, param_sec):
        frak_s_2 *= mp.sqrt(2)                       
    delta_mlwe = max(findMLWEdelta(kmlwe, d, 2 ** log2q, sigma_2),findMLWEdelta(kmlwe, d, 2 ** log2q, varsigma_2()))
    
    if delta_mlwe <= DELTA128:
    if delta_mlwe <= ROOT_HERMITE_128:
        print(f"MLWE dim {kmlwe} : hard")
        hard_mlwe_dim = kmlwe
    else:
@@ -185,73 +189,94 @@ while True:
kmsis = 0   # dimension of the MSIS problem
while True:
    kmsis += 1
    m2 = kmlwe + kmsis + l
    sigma_2 = smoothing_param_bound(2*(2*kmlwe*d), 1, param_sec)                            # Standard deviation of the randomness s_2
    frak_s2 = smoothing_param_bound(2*m1*d, (sqrt(2*p)/(b-1)), param_sec)
    stdev2 = (eta* sigma_2 + frak_s2)
    m_2 = kmlwe + kmsis
    
    print(f"d {d}")
    print(f"2^log2q {2^log2q}")
    print(f"kmsis {kmsis}")
    print(f"Bound {Bound()}")
    print(f"delta {get_delta_msis(Bound(), kmsis, d, 2 ** log2q)}")
    if get_delta_msis(Bound(), kmsis, d, 2 ** log2q) < DELTA128 and Bound() < 2 ** log2q:
    print(f"Bound {bound_know_soundness()}")
    print(f"delta {get_delta_msis(bound_know_soundness(), kmsis, d, 2 ** log2q)}")
    print(f"delta {get_delta_msis(bound_binding(), kmsis, d, 2 ** log2q)}")
    if get_delta_msis(bound_know_soundness(), kmsis, d, 2 ** log2q) < ROOT_HERMITE_128 and bound_know_soundness() < 2 ** log2q and get_delta_msis(bound_binding(), kmsis, d, 2 ** log2q) < ROOT_HERMITE_128 and bound_binding() < 2 ** log2q:
        break

# Find the largest possible gamma which makes the MSIS solution still small.
gamma = 2 ** log2q 
while True:       # searching for right gamma
    gamma /= 2
    if get_delta_msis(Bound(), kmsis, d, 2 ** log2q) < DELTA128 and Bound() < 2 ** log2q:
    if get_delta_msis(bound_know_soundness(), kmsis, d, 2 ** log2q) < ROOT_HERMITE_128 and bound_know_soundness() < 2 ** log2q and get_delta_msis(bound_binding(), kmsis, d, 2 ** log2q) < ROOT_HERMITE_128 and bound_binding() < 2 ** log2q:
        break

# Finding exact values for q, b and gamma:
true_gamma_found = false    # Boolean for finding correct gamma
b = 2^(log2q//k)                                                 # we need p to be congruent to 5 modulo 8
p = b^2 + 1 
b = 2 ** (log2q//k) - 1             
while true_gamma_found == false:
    b = b+1
    p = b^2 + 1  
    while not is_prime(p) or not p%8 == 5:
        b = b+1
        p = b^2 + 1  
    div_b = divisors(b^2)                                                                # consider divisors of b
    if is_prime(p):     # we need p to be prime
        if p%8 == 5:    # we need p to be congruent to 5 modulo 8
            div_b = divisors(p-1)     # consider divisors of b^2
            for i in div_b:                
                if gamma*4/5 < i and i <= gamma and is_even(i): # find a divisor which is close to gamma
                    gamma = i # we found a good candidate for gamma
                    true_gamma_found = true

m = (p-1) / gamma

# Find the largest possible D which makes the MSIS solution small
D = log2q
while True:
while D != 0:
    D -= 1
    if get_delta_msis(Bound(), kmsis, d, p) < DELTA128 and Bound() < 2 ** log2q and 2 ** (D-1)*omega*d < gamma:
    if get_delta_msis(bound_know_soundness(), kmsis, d, p) < ROOT_HERMITE_128 and bound_know_soundness() < p and get_delta_msis(bound_binding(), kmsis, d, p) < ROOT_HERMITE_128 and bound_binding() < p and 2 ** (D-1)*omega*d < gamma:
        break

# update MLWE root hermite factor with exact q
delta_mlwe = max(findMLWEdelta(kmlwe, d, p, varsigma_2),findMLWEdelta(kmlwe, d, p, sigma_2))
# assert all the conditions

assert sigma_1 >= smoothing_param_bound(k*m_1*d, lambda_classic, param_sec)
assert mp.sqrt(2) * frak_s_1 >= smoothing_param_bound(k*m_1*d, lambda_classic, param_sec)
assert mpf(b-1) * frak_s_1 >= mp.sqrt(2) *smoothing_param_bound(k*m_1*d, lambda_ideal_p, param_sec)
assert mp.sqrt(2) * (b-1) * varsigma_1() >=  smoothing_param_bound(k*m_1*d, lambda_ideal_p, param_sec)

assert sigma_2 >= mpf(2)*smoothing_param_bound(kmlwe*d, lambda_classic, param_sec)
assert frak_s_2 >= mp.sqrt(2)*smoothing_param_bound(kmlwe*d, lambda_classic, param_sec)
assert varsigma_2() >= mp.sqrt(2)*smoothing_param_bound(kmlwe*d, lambda_classic, param_sec)

# update MLWE root hermite factor with exact p
delta_mlwe = max(findMLWEdelta(kmlwe, d, p, varsigma_2()),findMLWEdelta(kmlwe, d, p, sigma_2))

# computation of the proof size 
full_size = kmsis * d * (log2q - D) + l* d * log2q   
challenge = ceil(log(2*omega+1,2)) * d 
short_size1 = m1 * d * (ceil(log(stdev1,2) + 2.57)) + (m2 - kmsis) * d * (ceil(log(stdev2,2) + 2.57))

logp = ceil(mp.log(p,2))

full_size = kmsis * d * (logp - D) + l * d * logp 

hint = 2.25 * kmsis * d

challenge = ceil(mp.log(2*omega+1,2)) * d 

length_z_1 = (k * m_1) * d * (ceil(2 * mp.log( eta * (b+1) * sigma_1 + mp.sqrt(2)*frak_s_1,2)) + 2.57)

length_z_2 = m_2 * d * (ceil(2 * mp.log( eta * sigma_2 + frak_s_2,2)) + 2.57)

enablePrint()
printv(f"auto-generated by modified-abdlop-codegen.sage from {params_file}.")
printv(f"")

if not (kmlwe >= 0 and kmlwe == m2 - kmsis - l):
    err("protocol not simulatable")
if not (kmlwe >= 0 and kmlwe == m_2 - kmsis - l):
    err("protocol not simulatable because of the parameters")

printv(
    f"the commitment scheme is hiding under MLWE({kmlwe},{kmsis+l}) with sd={nstr(sigma_2, prec)})") 
    f"the commitment scheme is binding under MSIS({kmsis},{k*m_1 - l + m_2}) with bound={nstr(bound_binding(), prec)})") 

printv(
    f"the commitment scheme is hiding under MLWE({kmsis+l},{kmlwe}) with sd={nstr(sigma_2, prec)})") 

printv(
    f"protocol is simulatable under Hint-MLWE implied by MLWE({kmlwe},{kmsis+l}) with sd={nstr(varsigma_2, prec)})") 
    f"protocol is simulatable under Hint-MLWE implied by MLWE({kmsis+l},{kmlwe}) with sd={nstr(varsigma_2(), prec)})") 

eknow = mpf(1)/mpf(Csize)
printv(
    f"protocol is knowledge-sound with knowledge error <= 2^({nstr(mp.ceil(mp.log(eknow,2)),prec)})")
    f"protocol is knowledge-sound with knowledge error <= 2^({nstr(mp.ceil(mp.log(eknow,2)),prec)}) under MSIS({kmsis},{k*m_1- l + m_2}) with bound={nstr(bound_know_soundness(), prec)})")

# print params
printv(f"")
@@ -266,12 +291,12 @@ printv(f"gamma = {gamma}, log(gamma) ~ {nstr(mp.log(gamma,2),prec)}")
printv(f"m = (q-1)/gamma = {m}, log(m) ~ {nstr(mp.log(m,2),prec)}")
printv(f"")
printv(f"Dimensions of secrets")
printv(f"s1: m1 = {m1/2}")
printv(f"s2: m2 = {m2}")
printv(f"s1: m_1 = {(m_1-l)/k}")
printv(f"s2: m_2 = {m_2}")
printv(f"")
printv(f"Size of secrets")
printv(f"s1 unbounded")
printv(f"s2 uniform in distributed with standard deviation {nstr(sigma_2, prec)}")
printv(f"s2 a gaussian element distributed with standard deviation {nstr(sigma_2, prec)}")
printv(f"")
printv(f"Challenge space")
printv(
@@ -281,16 +306,16 @@ printv(f"")
printv(f"Security")
printv(f"MSIS dimension: {kmsis}")
printv(
    f"MSIS root hermite factor: {nstr(get_delta_msis(Bound(), kmsis, d, p), prec)}")
    f"MSIS root hermite factor: {nstr(get_delta_msis(bound_know_soundness(), kmsis, d, p), prec)}")
printv(f"MLWE dimension: {kmlwe}")
printv(f"MLWE root hermite factor: {nstr(mpf(delta_mlwe), prec)}")
printv(f"")
printv(f"Proof size of the modified abdlop opening ")

printv(f"Total proof size in KB:  { round((full_size + challenge + short_size1 + hint)/(2^13) , 2)}")
printv(f"Total proof size in KB:  { round((full_size + challenge + length_z_1 + length_z_2 + hint)/(2^13) , 2)}")
printv(f"full-sized polynomials in KB: {round(full_size/(2^13) , 2)}")
printv(f"challenge c in KB: {round(challenge/(2^13) , 2)}")
printv(f"short-sized polynomials in KB: {round((short_size1 + hint)/(2^13) , 2)}")
printv(f"short-sized polynomials in KB: {round((length_z_1 + length_z_2 + hint)/(2^13) , 2)}")
printv(f"")

q_nlimbs = int2limbs(p, -1)[1]
@@ -324,11 +349,11 @@ out += f"""
{int_t(f"{name}_gammaby2", gamma / 2, q_nlimbs)}
{int_t(f"{name}_pow2D", 2^D, q_nlimbs)}
{int_t(f"{name}_pow2Dby2", 2^D / 2, q_nlimbs)}
{int_t(f"{name}_Bsq", floor(Bound_()^2), 2*q_nlimbs)}
{int_t(f"{name}_Bsq", floor(bound_know_soundness()^2), 2*q_nlimbs)}
{int_t(f"{name}_sigma_1", int(mp.nint(sigma_1^2)), 2*q_nlimbs)}
{int_t(f"{name}_sigma_2", int(mp.nint(sigma_2^2)), 2*q_nlimbs)}
{int_t(f"{name}_frak_s1", int(mp.nint(frak_s1^2)), 2*q_nlimbs)}
{int_t(f"{name}_frak_s2", int(mp.nint(frak_s2^2)), 2*q_nlimbs)}
{int_t(f"{name}_frak_s1", int(mp.nint(frak_s_1^2)), 2*q_nlimbs)}
{int_t(f"{name}_frak_s2", int(mp.nint(frak_s_2^2)), 2*q_nlimbs)}
{int_t(f"{name}_inv2", redc(1/2 % p, p))}
{int_t(f"{name}_Pmodq", Pmodq, q_nlimbs)}
"""
@@ -336,9 +361,9 @@ for i in range(len(moduli)):
    out += int_t(f"{name}_Ppmodq_{i}", Ppmodq[i], q_nlimbs) + f"\n"
out += f"""
static const int_srcptr {name}_Ppmodq[] = {Ppmodq_array};
static const polyring_t {name}_ring = {{{{{name}_q, {d}, {ceil(log(p-1,2))}, {log2d}, moduli_d{d}, {nmoduli}, {name}_Pmodq, {name}_Ppmodq, {name}_inv2}}}};
static const dcompress_params_t {name}_dcomp = {{{{ {name}_q, {name}_qminus1, {name}_m, {name}_mby2, {name}_gamma, {name}_gammaby2, {name}_pow2D, {name}_pow2Dby2, {D}, {m % 2}, {ceil(log(m,2))} }}}};
static const modified_abdlop_params_t {name} = {{{{ {name}_ring, {name}_dcomp, {name}_b, {m1}, {m2}, {l}, {lext}, {kmsis}, {name}_Bsq, {omega}, {omega_bits}, {eta}, {name}_sigma_1, {ceil(log(sigma_1,2))}, {name}_sigma_2, {ceil(log(sigma_2,2))}, {name}_frak_s1, {ceil(log(frak_s1,2))}, {name}_frak_s2, {ceil(log(frak_s2,2))}}}}};
static const polyring_t {name}_ring = {{{{{name}_q, {d}, {ceil(mp.log(p-1,2))}, {log2d}, moduli_d{d}, {nmoduli}, {name}_Pmodq, {name}_Ppmodq, {name}_inv2}}}};
static const dcompress_params_t {name}_dcomp = {{{{ {name}_q, {name}_qminus1, {name}_m, {name}_mby2, {name}_gamma, {name}_gammaby2, {name}_pow2D, {name}_pow2Dby2, {D}, {m % 2}, {ceil(mp.log(m,2))} }}}};
static const modified_abdlop_params_t {name} = {{{{ {name}_ring, {name}_dcomp, {name}_b, {m_1}, {m_2}, {l}, {lext}, {kmsis}, {name}_Bsq, {omega}, {omega_bits}, {eta}, {name}_sigma_1, {ceil(mp.log(sigma_1,2))}, {name}_sigma_2, {ceil(log(sigma_2,2))}, {name}_frak_s1, {ceil(mp.log(frak_s_1,2))}, {name}_frak_s2, {ceil(mp.log(frak_s_2,2))}}}}};
"""

printc(out)
+170 −146

File changed and moved.

Preview size limit exceeded, changes collapsed.

Loading