-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdeffi_hell.java
More file actions
30 lines (28 loc) · 791 Bytes
/
deffi_hell.java
File metadata and controls
30 lines (28 loc) · 791 Bytes
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
public class deffi_hell {
private static long power(long a, long b, long p)
{
if (b == 1)
return a;
else
return (((long)Math.pow(a, b)) % p);
}
public static void main(String[] args)
{
long P, G, x, a, y, b, ka, kb;
P = 23;
System.out.println("The value of P:" + P);
G = 9;
System.out.println("The value of G:" + G);
a = 4;
System.out.println("The private key a for Alice:" + a);
x = power(G, a, P);
b = 3;
System.out.println("The private key b for Bob:" + b);
y = power(G, b, P);
ka = power(y, a, P);
kb = power(x, b, P);
System.out.println("Secret key for the Alice is:" + ka);
System.out.println("Secret key for the Bob is:" + kb);
System.out.println("19DCE111:- Ravi Patel");
}
}