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
| %--------------------------------------------------------------------------%L'image à envoyer
M=imread('cameraman.tif','tif');
[K,N]= size(M)
M=double(M);
%imshow(uint8(M))
%--------------------------------------------------------------------------Génération des clefs publiques
%%-------------------------------------------------------------------------1/Choix d'une courbe elliptique: y^2 = x^3 + ax +b mod n
syms x
syms y
p=257;
EF=y^2;
EF== x^3 + 8*x +1;
EC = mod(y^2 == x^3 + 8*x +1,p);
%--------------------------------------------------------------------------2/Choix d'un point P
P=[71,42];a=8;b=1;
%--------------------------------------------------------------------------3/Choix d'un entier secret s
%%B=sP;
s = 96;
B = MULTIP(P,s,a,b,p)
Clepub=[EF,P,B]
%--------------------------------------------------------------------------
l=30;
x1=[];
for i=1:30
for j=1:30
x(i*j)=M(i,j)*l;
x=[x1;x];
end
end
x;
y1=[];
for i=1:length(x)
y(i)=powermod(x(i),(p+1)/4,p);
y=[y1;y];
end
y;
%_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-Chiffrement-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
%-
C2=[];
k=60;
C1= MULTIP(P,k,a,b,p);
C = MULTIP(B,k,a,b,p);
for i= 1:length(x)
D=[x(i) y(i)];
C_2=Addition(D,C,a,b,p);
C2=[C2;C_2];
end
C=[C2(1:length(x))];
CC=[];
C_int=double(C);
for i=1:length(x)
M=C_int(1:length(x));
CC=[CC;M];
C_int(1:length(x))=[];
end
figure
imshow(uint8(CC)) |
Partager