addition of points in a curve

조회 수: 4 (최근 30일)
amina amzgh
amina amzgh 2020년 7월 29일
댓글: amina amzgh 2020년 7월 30일
I made a function which calculates the addition of two points in a curve, in my main program I want to calculate "kG = G + G + G + .... k times" knowing that k is a random number, example: G + G = r1 r1 + G = r2 r3 + G = r3 ... ect up to "rk" could someone help me calculate kG using my addition function
  댓글 수: 5
Bruno Luong
Bruno Luong 2020년 7월 30일
Vous n'auriez pas dû regarder au bon endroit, j'utilise une fonction qui fait l'addition de 2 points. Chez moi elle s'appelle EL_add. Elle fait plus que le dédoublement de point. C'est elle que vous devriez remplacer par votre fonction (et les petit détails entre le codage de votre courbe et la mienne). Si vous faites tourner le code vous obtiendriez le tableau de 1*G, 2*G, ..., maxC*G. Donc définissez maxC comme le "k" chez vous, faites tourner le code kG et dans le dernier point du tableau.
EL = struct('a', 148, 'b', 225, 'p', 5003);
% Point
G = [1355,2421];
% Compute C*G for C=1,2,...,maxC
maxC = 5003;
maxk = nextpow2(maxC);
CG = zeros(maxC,2);
j = 1;
CG(j,:) = G;
G2k = G;
% precompute the inverse of 1...p-1, and stores in table itab
p = EL.p;
itab = p_inverse(1:p-1, p);
for k=1:maxk
for i=1:j-1
j = j+1;
CG(j,:) = EL_add(G2k,CG(i,:),EL,itab); % <- REMPLACEZ PAR VOTRE FONCTION
if j == maxC
break
end
end
if j == maxC
break
end
G2k = EL_add(G2k,G2k,EL,itab);
j = j+1;
CG(j,:) = G2k;
end
CG
% etc...
amina amzgh
amina amzgh 2020년 7월 30일
ça ne marche toujours pas malheureusement

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Language Fundamentals에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by