addition of points in a curve
    4 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    

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 Commenti
  Bruno Luong
      
      
 il 30 Lug 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...
Risposte (0)
Vedere anche
Categorie
				Scopri di più su Language Fundamentals in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!