Signed-off-by: Marcin Woźniak <y0rune@aol.com>
This commit is contained in:
Marcin Woźniak 2021-01-05 17:25:55 +01:00
parent 5821fdf523
commit 6b39a7a071
Signed by: y0rune
GPG Key ID: F204C385F57EB348

View File

@ -11,9 +11,8 @@
load '../module.rb'
def main
k = 300
m = 73
n = m + SecureRandom.random_number(0..1000000)
k = 400
m = 7382908210982109821098
u = SecureRandom.random_number(30..50)
a,b,p,px,py,qx,qy,x = generowanieKluczyElGamalKrzywaEliptyczna(k)
@ -25,17 +24,50 @@ def main
puts ""
# BOB
c1, c2 = szyfrowanieElGamala(a,b,p,m,n,u,px,py,qx,qy)
pm = algorytmKodowania(a,b,p,m,u)
c1, c2 = szyfrowanieElGamala(a,b,p,u,px,py,qx,qy,pm[0],pm[1])
# ALICE
pmd = deKododwanieElGamala(a,b,p,c1[0],c1[1],c2[0],c2[1],x)
d = algorytmDeSzyfrowania(pmd[0],pmd[1],u)
puts "Deszyfowany punkt #{pmd.inspect}"
puts "Dekodowana wiadomość #{d.inspect}"
puts "\n\n---------------DANE DO ZADANIA----------------\nm = #{m} \na = #{a}\nb = #{b}\np = #{p}\npx = #{px}\npy = #{py}\nqx = #{qx}\nqy = #{qy}\nx = #{x}\nu = #{u}\nc1 = #{c1.inspect}\nc2 = #{c2.inspect}\n---------------------------------------------"
end
#puts generowanieKluczyElGamalKrzywaEliptyczna(2048).inspect
#puts wielokrotnoscPunktu(8,10,19,3,15,3).inspect
#puts algorytmSzyfrowania(8,10,19,29102901920190,29102901920199,50).inspect
#puts algorytmDeSzyfrowania(8,10,19,12,17,50)
#Puts algorytmDeSzyfrowania(8,10,19,12,17,50)
def prof
p = 2609851093885672531604546618282965491657570314241630591985918197877686507680174634344306143
a = 39746926425836399039258105470873774392122997653409098298906197201548801192257224379572749
b = 357758004741884143788834147448966908166771657009672776346195608808675430720026748380346214
px = 1752779174606701535340714968386694890708439813322474322723061659600059923305207235005963526
py = 692575814560566162056537964537393338270737177090733420494053855669625561475768305447331017
qx = 1859733423522807921537556587280278373018778723945077866335841026984756695533872750973383203
qy = 2221415723705529494603362237538702810871518537067269952747134368932432130149327465664405538
pmx = 1632858042793817840589568786779891550617922233361846684642975374690944475963011731075819538
pmy = 1425948989523949818696633854257999800509690944329987427951625560436648299955576658406402833
u = 30
x = 365201008216944469945066035191785204730196821748386113747483955067753230980
y = SecureRandom.random_number(0..liczenieOrd(p))
c1 = wielokrotnoscPunktu(a,b,p,y,px,py)
puts "c1 #{c1}"
yq = wielokrotnoscPunktu(a,b,p,y,qx,qy)
c2 = sumaPunktow(a,b,p,pmx,pmy,yq[0],yq[1])
puts "c2 #{c2}"
pmd = deKododwanieElGamala(a,b,p,c1[0],c1[1],c2[0],c2[1],x)
d = algorytmDeSzyfrowania(pmd[0],pmd[1],u)
puts "pmd #{pmd.inspect}"
puts "d = #{d}"
end
#puts prof
puts main.inspect