-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHUFF_SMUL_magma_test.m
More file actions
68 lines (58 loc) · 1.06 KB
/
HUFF_SMUL_magma_test.m
File metadata and controls
68 lines (58 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
///SMULL WITH UNIFIED ADD !!!WORKING
clear;
uadd:=function(X1, Z1, Y1, T1, X2, Z2, Y2, T2)
UU:=X2+Z2;
VV:=Y2+T2;
AA:=X1*X2;
BB:=Y1*Y2;
CC:=Z1*Z2;
DD:=T1*T2;
EE:=X1+Z1;
FF:=Y1+T1;
GG:=AA+CC;
HH:=BB+DD;
II:=EE*UU;
JJ:=FF*VV;
KK:=BB;
LL:=AA;
MM:=DD-KK;
NN:=DD+KK;
PP:=CC-LL;
QQ:=CC+LL;
RR:=II-GG;
SS:=JJ-HH;
X3:=RR*MM;
Z3:=PP*NN;
Y3:=SS*PP;
T3:=QQ*MM;
return X3, Z3, Y3, T3;
end function;
K:=GF(2^256-587);
a:=K!1;
b:=K!1;
c:=K!2843372514693350191555057326962375992036895483176136989686999058312654159918;
d:=K!2365984729494867911035798843067087631836584685670553507882547214869756774841;
P<x,y>:=AffineSpace(K,2);
C<X,Y,Z>:=ProjectiveClosure(Curve(P,[d*y*(1+a*x^2)-c*x*(1+b*y^2)]));
W,CtoW:=EllipticCurve(C,C![0,0,1]);
WtoC:=Inverse(CtoW);
PP:=Random(W);
P:=WtoC(PP);
XP:=P[1];
ZP:=K!1;
YP:=P[2];
TP:=K!1;
XM:=K!0;
ZM:=K!1;
YM:=K!0;
TM:=K!1;
k:=7;
KK := IntegerToSequence(k,2);
for i in [1..#KK] do
if KK[i] eq 1 then
XM,ZM,YM,TM:=uadd(XM,ZM,YM,TM,XP,ZP,YP,TP);
end if;
XP,ZP,YP,TP:=uadd(XP,ZP,YP,TP,XP,ZP,YP,TP);
end for;
XM/ZM,YM/TM;
WtoC(k*PP);