Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pcg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bouillaguet Charles
pcg
Commits
80c6e7b3
Commit
80c6e7b3
authored
5 years ago
by
Julia Sauvage
Browse files
Options
Downloads
Patches
Plain Diff
Version fplll qui marche a peu près dans 95% du temps
parent
1f29ada3
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Cunknown/FindDS.sage
+29
-22
29 additions, 22 deletions
Cunknown/FindDS.sage
with
29 additions
and
22 deletions
Cunknown/FindDS.sage
+
29
−
22
View file @
80c6e7b3
import time
import random as r
from fpylll import *
import fpylll as f
k = 64
known_up = 6
known_low = 13
...
...
@@ -34,17 +35,25 @@ def getG(n,mod):
def getGreduite(n,mod):
G = getG(n,mod)
return G.transpose().LLL().transpose()
Gr = G.transpose().LLL().transpose()
return Gr
def getGreduitelll(n,mod):
G = getG(n,mod)
Gr = G.transpose().LLL()
Glll = f.IntegerMatrix.from_matrix(Gr)
return Glll
def getInvG(Greduite):
return Greduite.inverse().n()
Greduite1 = getGreduite(nbiter - 1, 2^k)
invG1 = getInvG(Greduite1)
Greduite1 = getGreduitelll(nbiter - 1, 2^k)
G1 = getGreduite(nbiter - 1, 2^k)
invG1 = getInvG(G1)
Greduite2 = getGreduite(nboutput - 1, 2^(2 * k - known_low))
invG2 = getInvG(Greduite2)
Greduite2 = getGreduite
lll
(nboutput - 1, 2^(2 * k - known_low))
#
invG2 = getInvG(Greduite2)
def sortiesGenerateur():#OK !
...
...
@@ -93,14 +102,12 @@ def getDY(Y, WC, W0): #OK ! avec erreurs de retenues ~64bits (polC polW)
return DY
######FINDDS######
def FindDS64(uX, rot, W0,WC,
invG,
Greduite): #rajouter rot dans la version non test ? #OK! ~64bits
def FindDS64(uX, rot, W0,WC, Greduite
, G, invG
): #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
u = invG * tmp
tmp = vector([round(u_) for u_ in u])
DS64 = Greduite * tmp
DS64 = CVP.closest_vector(Greduite,tuple(tmp))
return DS64, Y[0]
######FINDROTI######
...
...
@@ -130,55 +137,53 @@ def FindRot(DS640,X, Y0, W0, WC): #OK !
return []
return tabrot
def findDS(rot, Greduite
, invG
): #OK!
def findDS(rot, Greduite): #OK!
rotprim = []
for i in range(nboutput):
rotprim.append((rot[i] - ((powA[i] * W0 + polA[i] * WC) >> (2 * k - known_up))) % (1<<known_up))
tmp = vector([(rotprim[i+1] - rotprim[i]) << (2 * k - known_up - known_low) for i in range(nboutput - 1)])
u = invG * tmp
return f.CVP.closest_vector(Greduite,tuple(tmp))
'''u = invG * tmp
tmp = vector([round(u_) for u_ in u])
return Greduite * tmp
return Greduite * tmp
'''
def reclistDS(rot, tabrot, Greduite,
invG,
i):
def reclistDS(rot, tabrot, Greduite, i):
DS = []
#print("taille tabrot", len(tabrot), "i", i)
if(i == nboutput):
DS = [findDS(rot, Greduite
, invG
)]
DS = [findDS(rot, Greduite)]
return(DS)
#print(tabrot[i])
for r in tabrot[i]:
rot.append(r)
DS += reclistDS(copy(rot), tabrot, Greduite,
invG,
i+1)
DS += reclistDS(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
n = 100
n = 200
#X, S,c = sortiesGenerateur()
for blabla in range(n):
X, S,c = sortiesGenerateur()
W0 = S[0] % (1 << known_low)
WC = c % (1 << known_low)
up =[]
rot = []
for i in range(nboutput):
up.append(S[i] >> (2 * k - known_up))
rot.append(S[i] >> (2 * k - 6))
uX = unrotateX(X,rot)
DS64, Y0 = FindDS64(uX,
up
, W0,WC,
invG1,
Greduite1)#OK!
DS64, Y0 = FindDS64(uX,
rot
, W0,WC, Greduite1
, G1, invG1
)#OK!
tabrot = FindRot(DS64[0],X, Y0, W0, WC)#a l'air OK!
test = 0
if(len(tabrot) == 0):
cptcaca += 1
else:
rot = []
listDS = reclistDS(rot, tabrot, Greduite2,
invG2,
0)
listDS = reclistDS(rot, tabrot, Greduite2, 0)
for DS in listDS:
Sprim = [(S[i] - polA[i] * (c % 1<<known_low) - powA[i] * (S[0] % 2^known_low)) % 2^128 for i in range(nboutput)]
if(DS[0] == ((Sprim[1] - Sprim[0]) >> known_low)):
...
...
@@ -187,5 +192,7 @@ for blabla in range(n):
#print(DS[0])
#print(12615681514276467327 * 2^64 + 8299778918817149495)
print(n)
print("cpt:")
print(cpt)
print("cptcaca:")
print(cptcaca)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment