How to use loop in my code for key generation

Hi. i want to generate 16 sub keys .Algorithm is as follows
K=[k1, k2, k3, k4]%initial key and are points on elliptic curve.
for first key,
k5=2*k4+k1
k6=k5+k2
k7=k6+k3
k8=k7+k4
K1=dec2bin[k5 k6 k7 k8]
similarly i have to generate 16 subkeys. Multiplication and addition is of elliptic curve addition and multiplication.
a=0;
b=17;
n=313;
A=[[36 6]; [117 3] ;[198 310] ;[68 86]];
k=size(A,1);
B=zeros(size(A))
temp=A(k,:)
A4=multell(temp,2,a,b,n);
A5=addell(A4,A(k-3,:),a,b,n);
A6=addell(A5,A(k-2,:),a,b,n);
A7=addell(A6,A(k-1,:),a,b,n);
%temp(A(k+1),:)
B=[A4 A5 A6 A7];
B1=dec2bin(B)
key1=reshape(B1,1,64)

 Respuesta aceptada

KALYAN ACHARJYA
KALYAN ACHARJYA el 19 de Jul. de 2019
Editada: KALYAN ACHARJYA el 19 de Jul. de 2019
#Edited
k=cell(1,8);
k{1}=[36 6];
k{2}=[117 3];
k{3}=[198 310];
k{4}=[68 86];
for i=5:8
k{i}=2*k{i-1}+k{i-4};
end

4 comentarios

sadiqa ilyas
sadiqa ilyas el 19 de Jul. de 2019
k1=[36 6] k2= [117 3] k3=[198 310] k4=[68 86]
All these are elments of matrix A
KALYAN ACHARJYA
KALYAN ACHARJYA el 19 de Jul. de 2019
Editada: KALYAN ACHARJYA el 19 de Jul. de 2019
k=cell(1,8);
k{1}=[36 6];
k{2}=[117 3];
k{3}=[198 310];
k{4}=[68 86];
for i=5:8
k{i}=2*k{i-1}+k{i-4};
end
K1=cell(1,4);
for i=1:4
K1{i}=dec2bin(k{i+4});
end
K1
#if you can avoid loops, it may recomended.
sadiqa ilyas
sadiqa ilyas el 19 de Jul. de 2019
thanks it works
KALYAN ACHARJYA
KALYAN ACHARJYA el 19 de Jul. de 2019
Editada: KALYAN ACHARJYA el 19 de Jul. de 2019
Welcome @Sadiqa

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Random Number Generation en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 19 de Jul. de 2019

Editada:

el 19 de Jul. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by