Borrar filtros
Borrar filtros

Can i fit a loop in my code

2 visualizaciones (últimos 30 días)
sadiqa ilyas
sadiqa ilyas el 22 de Jul. de 2019
Hi i want to reduce the code size by using loops. I have used elliptic curves for generating the keys and i need 16 session keys.
close all
clear all
a=0;
b=17;
n=313;
A=[[36 6]; [117 3] ;[198 310] ;[68 86]];
k=size(A,1);
temp=A(4,:)
A11=multell(A(4,:),2,a,b,n);
A(5,:)=addell(A11,A(1,:),a,b,n);
A(6,:)=addell(A(5,:),A(2,:),a,b,n);
A(7,:)=addell(A(6,:),A(3,:),a,b,n);
A(8,:)=addell(A(7,:),A(4,:),a,b,n);
%k=k+4;
%end
B=[A(5,:); A(6,:); A(7,:); A(8,:)];
B1=dec2bin(B)
key1=reshape(B1,1,64)
%For key two
A2=[A(5,:); A(6,:); A(7,:); A(8,:)];
k=size(A2,1);
temp=A2(4,:)
A21=multell(A2(4,:),2,a,b,n);
A(9,:)=addell(A21,A(5,:),a,b,n);
A(10,:)=addell(A(9,:),A(6,:),a,b,n);
A(11,:)=addell(A(10,:),A(7,:),a,b,n);
A(12,:)=addell(A(11,:),A(8,:),a,b,n);
B2=[A(9,:); A(10,:); A(11,:); A(12,:)];
B21=dec2bin(B2);
key2=reshape(B21,1,64)
%For Key3
A3=[A(9,:); A(10,:); A(11,:); A(12,:)];
k=size(A3,1);
temp=A3(4,:)
A31=multell(A3(4,:),2,a,b,n);
A(13,:)=addell(A31,A(9,:),a,b,n);
A(14,:)=addell(A(9,:),A(10,:),a,b,n);
A(15,:)=addell(A(10,:),A(11,:),a,b,n);
A(16,:)=addell(A(11,:),A(12,:),a,b,n);
B3=mod([A(13,:); A(14,:); A(15,:); A(16,:)],256);
B31=dec2bin(B3);
key3=reshape(B31,1,64)

Respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by