Skip to content
Snippets Groups Projects
Commit 64276a01 authored by Julia Sauvage's avatar Julia Sauvage
Browse files

Version qui marche

parent 9535d842
No related branches found
No related tags found
No related merge requests found
import time
import random as r
import fpylll as f
import os
k = 64
known_up = 6
......@@ -44,6 +45,19 @@ Greduite1 = getGreduite(nbiter - 1, 2^k)
Greduite2 = getGreduite(nboutput - 1, 2^(2 * k - known_low))
#### Récupération des données ####
'''def recupDonnees():
listfiles = os.listdir('results')
print(listfiles)
listDonnees = []
for i in range(listfiles):
listDonnees.append[]
f = open(listfiles[i], "r")
while(1):
s = f.readline()'''
def sortiesGenerateur():#OK !
c = (r.randint(0, 1<<(2 * k)) * 2 + 1) % 1<<(2 * k) #c est impair
S=[r.randint(0,1<<(k * 2))]
......@@ -91,7 +105,6 @@ def getDY(Y, WC, W0): #OK ! avec erreurs de retenues ~64bits (polC polW)
######FINDDS######
def FindDS64(uX, rot, W0,WC, Greduite): #rajouter rot dans la version non test ? #OK! ~64bits
#polW = getPolW(W0)
Y = getY(W0, WC, rot, uX)
DY = getDY(Y, WC, W0) #OK avec erreurs de retenues!
tmp = vector([y * 1<<(k - known_up - known_low) for y in DY])#on rajoute les zéros, recentrage impossible à cause des erreurs de retenues
......@@ -135,22 +148,19 @@ def findDS(rot, Greduite): #OK!
def recFindDS(rot, tabrot, Greduite, i):
DS = []
#print("taille tabrot", len(tabrot), "i", i)
if(i == nboutput):
DS = [findDS(rot, Greduite)]
return(DS)
#print(tabrot[i])
for r in tabrot[i]:
rot.append(r)
DS += reclistDS(copy(rot), tabrot, Greduite, i+1)
DS += recFindDS(copy(rot), tabrot, Greduite, i+1)
return(DS)
######## ATTENTION CHANGEMENT DE KNOWN_UP DANS LA DEUXIEME PARTIE A RAJOUTER (POUR LE MOMENT 4% DE REUSSITE)
cpt = 0
cptcaca = 0
cptrotfail = 0
n = 1000
#X, S,c = sortiesGenerateur()
#recupDonnees()
for blabla in range(n):
X, S,c = sortiesGenerateur()
......@@ -165,7 +175,7 @@ for blabla in range(n):
tabrot = FindRot(DS64[0],X, Y0, W0, WC)#a l'air OK!
test = 0
if(len(tabrot) == 0):
cptcaca += 1
cptrotfail += 1
else:
rot = []
listDS = recFindDS(rot, tabrot, Greduite2, 0)
......@@ -174,10 +184,8 @@ for blabla in range(n):
if(DS[0] == ((Sprim[1] - Sprim[0]) >> known_low)):
test = 1
cpt += test
#print(DS[0])
#print(12615681514276467327 * 2^64 + 8299778918817149495)
print(n)
print("cpt:")
print(cpt)
print("cptcaca:")
print(cptcaca)
print("cptrotfail:")
print(cptrotfail)
......@@ -170,7 +170,7 @@ void result_found(const u64 *X, u64 W0, u64 WC, u64 r)
u64 c = (W0 << (known_low - 1)) + WC;
char filename[255];
sprintf(filename, "solution-%08llx.txt", c);
sprintf(filename, "results/solution-%08llx.txt", c);
FILE *f = fopen(filename, "a");
if (f == NULL)
err(1, "cannot open solution file");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment