# Question:ELgamal procedure

## Question:ELgamal procedure

Maple

Hi I was wondering if anyone can help me with the following procedure, i am trying to write a procedure that can encrypt/decrypt messages encrypted using the method of ELGamal my current procedure runs but it takes too long to compute, and it can only decrypt.

My procedure is as follows:

my procedure for part c is as follows it seems to run but it takes a long time to carry out the procedure when i try to decrypt.

Elgamal := proc (ciphy, hkt, p, a, b)
local i, icdarray, s, q;
icdarray := Array(5 .. 388);
for i from 5 to 388 do
s := ciphy[i];
q := `mod`(1/hkt^proc3(a, b, p), p);
icdarray[i] := s*q;
end do;
return convert(icdarray, bytes);
end proc;

where proc3 is as follows

proc3 := proc (alpha, beta, p)
local k, R, i, j, N, A, t;
Description "baby step giant step procedure";
N := floor(sqrt(p-1))+1;
A := Array(0 .. N);
for j from 0 to N do
A[j] := `mod`(alpha&^j, p);
end do;
for i from 0 to N do
t := `mod`(beta*alpha&^(-N*i), p);
for k from 0 to N do
if t = A[k]
then return k+N*i;
end if;
end do;
end do;
end proc;

ciphertext:
[12432485341, 2579085006, 13736574369, 4105371047, 9573017222,

7824534168, 10017411248, 13292180343, 2356887993, 9573017222,

10017411248, 13765667419, 9795214235, 10017411248, 2801282019,

608404939, 4105371047, 13765667419, 11572790339, 13765667419,

11765894302, 10017411248, 13765667419, 4549765073, 10017411248,

13736574369, 2579085006, 4549765073, 10017411248, 4549765073,

13765667419, 2801282019, 830601952, 4105371047, 10017411248,

7824534168, 13765667419, 13736574369, 2801282019, 7824534168,

10017411248, 830601952, 9573017222, 4327568060, 13765667419,

6076051114, 8268928194, 13292180343, 10017411248, 7824534168,

386207926, 2801282019, 4105371047, 2579085006, 6076051114,

608404939, 13765667419, 6076051114, 830601952, 13765667419,

4105371047, 11765894302, 10017411248, 13765667419, 13292180343,

13736574369, 10017411248, 608404939, 10017411248, 7824534168,

2134690980, 13765667419, 4105371047, 11765894302, 2801282019,

4105371047, 13765667419, 2579085006, 608404939, 13292180343,

11543697289, 2579085006, 7824534168, 10017411248, 4549765073,

13765667419, 4994159099, 5853854101, 6076051114, 830601952,

4327568060, 6076051114, 5853854101, 10017411248, 7824534168,

13765667419, 4105371047, 6076051114, 13765667419, 9573017222,

13292180343, 10017411248, 13765667419, 4105371047, 11765894302,

10017411248, 13765667419, 5853854101, 6076051114, 7824534168,

4549765073, 13765667419, 11572790339, 13765667419, 4105371047,

11765894302, 2801282019, 4105371047, 13765667419, 4105371047,

11765894302, 10017411248, 13765667419, 4327568060, 2801282019,

608404939, 4549765073, 13292180343, 13736574369, 2801282019,

11543697289, 10017411248, 13765667419, 5853854101, 2801282019,

13292180343, 13765667419, 11765894302, 6076051114, 7824534168,

7824534168, 2579085006, 8268928194, 4327568060, 2134690980,

13765667419, 11543697289, 7824534168, 10017411248, 13736574369,

2579085006, 11543697289, 2579085006, 4105371047, 6076051114,

9573017222, 13292180343, 2385981043, 13765667419, 3245676045,

9573017222, 2801282019, 2579085006, 608404939, 4105371047,

6105144164, 13765667419, 5853854101, 11765894302, 10017411248,

608404939, 13765667419, 9573017222, 13292180343, 10017411248,

4549765073, 13765667419, 4105371047, 6076051114, 13765667419,

4549765073, 10017411248, 13292180343, 13736574369, 7824534168,

2579085006, 8268928194, 10017411248, 13765667419, 4105371047,

11765894302, 10017411248, 13765667419, 6076051114, 13736574369,

13736574369, 2801282019, 13292180343, 2579085006, 6076051114,

608404939, 2801282019, 4327568060, 13765667419, 386207926,

2579085006, 4327568060, 4327568060, 2801282019, 6298248127,

10017411248, 13765667419, 4105371047, 11765894302, 7824534168,

6076051114, 9573017222, 6298248127, 11765894302, 13765667419,

5853854101, 11765894302, 2579085006, 13736574369, 11765894302,

13765667419, 4105371047, 11765894302, 10017411248, 2134690980,

13765667419, 11543697289, 2801282019, 13292180343, 13292180343,

10017411248, 4549765073, 6105144164, 13765667419, 9795214235,

10017411248, 2801282019, 608404939, 4105371047, 13765667419,

830601952, 10017411248, 386207926, 10017411248, 7824534168,

11572790339, 7824534168, 2579085006, 4549765073, 4549765073,

10017411248, 608404939, 13765667419, 2801282019, 608404939,

4549765073, 13765667419, 4105371047, 9573017222, 9795214235,

8268928194, 4327568060, 10017411248, 4549765073, 6076051114,

5853854101, 608404939, 2385981043, 13765667419, 4994159099,

5853854101, 6076051114, 830601952, 4327568060, 6076051114,

5853854101, 10017411248, 7824534168, 13765667419, 5853854101,

2801282019, 13292180343, 13765667419, 2801282019, 13765667419,

4105371047, 6076051114, 9573017222, 7824534168, 2579085006,

13292180343, 4105371047, 6105144164, 13765667419, 4105371047,

11765894302, 10017411248, 13765667419, 830601952, 2579085006,

7824534168, 13292180343, 4105371047, 13765667419, 10017411248,

386207926, 10017411248, 7824534168, 13765667419, 13292180343,

10017411248, 10017411248, 608404939, 13765667419, 6076051114,

608404939, 13765667419, 4105371047, 11765894302, 10017411248,

13765667419, 5438553125, 2579085006, 13292180343, 13736574369,

5853854101, 6076051114, 7824534168, 4327568060, 4549765073,

2385981043, 13765667419, 4994159099, 6076051114, 9573017222,

7824534168, 2579085006, 13292180343, 4105371047, 6105144164,

13765667419, 8713322220, 2579085006, 608404939, 13736574369,

10017411248, 5853854101, 2579085006, 608404939, 4549765073,

13765667419, 11765894302, 2801282019, 4549765073, 13765667419,

4549765073, 10017411248, 13736574369, 2579085006, 4549765073,

10017411248, 4549765073, 6105144164, 13765667419, 9795214235,

10017411248, 2801282019, 608404939, 4105371047, 13765667419,

8075824231, 2579085006, 4549765073, 2579085006, 6076051114,

4105371047, 8075824231, 2385981043]

[1]: https://i.stack.imgur.com/xY3zd.png
[2]: https://i.stack.imgur.com/0eYFM.png
[3]: https://i.stack.imgur.com/PMk7s.png

﻿