Ask Your Question
0

Problems with SAGE operations

asked 2012-06-15 19:55:16 +0200

vescapam gravatar image

I have defined in SAGE one Elliptic curve, two points: P and P_a and theree integers u1,u2 and n.

p=(10^34+1000).next_prime()

E=EllipticCurve(GF(p),[0,57]);

P= E(9128294291047160967288425267449898,3015386503039089432053383415473448)

P_a= E(4259903772238643554901244696272038,3809941931717614434052814194698091)

u1=32670546509638242125495495

u2=10120953885076574089031876

n=74226928212769886074449493

Q = Integer(u1)P+Integer(u2)P_a

v = mod(Q[0],n)

print v

Now i try to calculate the coordinates of a new point Q, and modular n of the first, called v.

Q = Integer(u1)P+Integer(u2)P_a

v = mod(Q[0],n]

The result that i obtained is 49823540439822066091848818, but desired is 2715371088067745779674921

Where is the mistake? I'm going crazy because i don't understand it.

Can you help me? Thank you very much.!!!!!!!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2012-06-16 06:53:14 +0200

achrzesz gravatar image

The following example (with your curve but changed Pa,u1,u2,r ) shows that "SAGE operations" are OK

p=(10^34+1000).next_prime()
E=EllipticCurve(GF(p),[0,57]);
x,y=(4259903772238643554901244696272038,3809941931717614434052814194698091)
E.is_on_curve(x,y)
#True
P=E(x,y)
n=P.order()
d=ZZ.random_element(n)   # Priv key
Pa=d*P                   # Pub key

kE=ZZ.random_element(n)  # Eph key
R=kE*P
r=Integer(R.xy()[0])     # first part of the signature
hx=ZZ.random_element(n)  # hash of the message
s=Mod((hx+d*r)*inverse_mod(kE,n),n)  # second part
w=s^-1
u1=Integer(Mod(w*hx,n))
u2=Integer(Mod(w*r,n))
Q=u1*P+u2*Pa
Integer(Q.xy()[0])==r    # Verification
#True
edit flag offensive delete link more

Comments

Thank you very much. You are a great SAGE programmer!!!

vescapam gravatar imagevescapam ( 2012-06-16 10:39:46 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-06-15 19:55:16 +0200

Seen: 316 times

Last updated: Jun 16 '12