98 lines
2.9 KiB
Ruby
Executable File
98 lines
2.9 KiB
Ruby
Executable File
#!/usr/bin/ruby
|
|
# coding: utf-8
|
|
|
|
#######################################
|
|
#
|
|
# Marcin Woźniak
|
|
# s434812
|
|
#
|
|
########################################
|
|
|
|
load '../module.rb'
|
|
|
|
##################################################
|
|
# Zadania z konca wykladu suma punktow
|
|
#
|
|
# Niech E/F7 będzie postaci
|
|
# E : Y^2 = X^3 + 1
|
|
#
|
|
# Niech P=(1,3) Q=(2,4) R=(6,0)
|
|
#
|
|
# Obliczyc:
|
|
# 1) -Q
|
|
# 2) R + [0,0]
|
|
# 3) P + Q
|
|
# 4) 2R
|
|
#
|
|
# Rozwiązanie:
|
|
#a = 0
|
|
#b = 1
|
|
#p = 7
|
|
#
|
|
#xp = 1
|
|
#yp = 3
|
|
#
|
|
#xq = 2
|
|
#yq = 4
|
|
#
|
|
#xr = 6
|
|
#yr = 0
|
|
#
|
|
## 1) -Q
|
|
#puts punktPrzeciwny(xq,yq).inspect
|
|
#
|
|
## 2) R + [0,0]
|
|
#puts sumaPunktow(a,b,p,xr,yr,"e","e").inspect
|
|
#
|
|
## 3) P + Q
|
|
#puts sumaPunktow(a,b,p,xp,yp,xq,yq).inspect
|
|
#
|
|
## 4) 2R
|
|
#puts sumaPunktow(a,b,p,xp,yp,xp,yp).inspect
|
|
###################################################
|
|
|
|
##################################################
|
|
# Zadanie od profersora
|
|
a=239614427021073265587611886177902927263167863041565491257781227550405368115731464059190159
|
|
b=447169285435982716467332439542997876345372330045685811964291613238129105735899852114277221
|
|
p=1183779584357076950937981497685946292711107412152534481102525547387604378262522402526266939
|
|
px=285113634279465403319996581740169338329454608669814309137990174814243655992779447106132850
|
|
py=598700530906084162596261101440667782569915319623798143751082061599951188013331503150304328
|
|
|
|
|
|
puts "Zadanie 1 #{generatorKrzywej(p).inspect}"
|
|
puts "Zadanie 2 #{punktNaKrzywej(a,b,p).inspect}"
|
|
puts "Zadanie 3 #{czyPunktNalezyDoKrzywej(a,b,p,px,py).inspect}"
|
|
puts "Zadanie 4 #{punktPrzeciwny(px,py).inspect}"
|
|
puts "Zadanie 5"
|
|
pp=sumaPunktow(a,b,p,px,py,px,py)
|
|
qx,qy=pp[0],pp[1]
|
|
r=sumaPunktow(a,b,p,px,py,qx,qy)
|
|
puts "P+P=Q = #{pp.inspect}"
|
|
puts "P+Q=R = #{r.inspect}"
|
|
|
|
##################################################
|
|
#Zadania od Marcina
|
|
puts `clear`
|
|
p = 489198001832658669053371291694019055502521600295245000665130252689633682157211441103746103
|
|
a = 143655542375421547495538657783935617582804745476111687935604061101439410572992748159327949
|
|
b = 317483121238416221164186798475625852751072649807905602729473072669192329094502393489452530
|
|
px = 214920231222257412002472184644105947527864300425093926130634470978902408198296382507987372
|
|
py = 213782952948563488188771820496583435437623918801486982688994669228366002105132455299788553
|
|
|
|
puts "Zadanie1: #{generatorKrzywej(p).inspect}"
|
|
puts "Zadanie2: #{punktNaKrzywej(a,b,p).inspect}"
|
|
puts "Zadanie3: #{czyPunktNalezyDoKrzywej(a,b,p,px,py).inspect}"
|
|
puts "Zadanie4: #{punktPrzeciwny(px,py).inspect}"
|
|
puts "Zadanie5:"
|
|
pe = sumaPunktow(a,b,p,px,py,"e","e")
|
|
pmp = sumaPunktow(a,b,p,px,py,px,-py)
|
|
pp = sumaPunktow(a,b,p,px,py,px,py)
|
|
puts "P + e = #{pe.inspect}"
|
|
puts "P + (-P) = #{pmp.inspect}"
|
|
puts "P + P = #{pp.inspect}"
|
|
|
|
qx = 642259555221384310824793582418757985600466641224722883964129011723625337870528779957486982
|
|
qy = 217544632016156259911730007881694454319320868952565819223745628076715981593127804307986145
|
|
puts "P + Q = #{sumaPunktow(a,b,p,px,py,qx,qy)}"
|