addition of points in a curve
    4 views (last 30 days)
  
       Show older comments
    

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 Comments
  Bruno Luong
      
      
 on 30 Jul 2020
				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...
Answers (0)
See Also
Categories
				Find more on Language Fundamentals in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

